Convert image in to blinking LED on processing

Dear guys, i m a very beginner for processing.i m looking for a help from you.i have connect a SD card and a LED on my arduino board.
I know processing can get a pixel array from that image which have saved in SD.
therefore i want to get the binary stream of each pixel values in the pixel array sequently through the serial connection.I want to blink my LED which have connected on my arduino according to each binary stream of pixel value…
I know any clever guy can write this whole code easily…
Please help me to write this for me……

Dear shonerudeetha .
Normaly members don’t ask for others to write code for a particurlary aplication. Yo have to come up with some code and ask where it went wrong. I would like to you to watch this video where you learn how to load an image and pick the brightness of a pixel. Then you can send that value to the usb port or over bluetooth if you like to the arduino. As a second learning stage you can eventually send the image from the arduino ( if it is stored there) to the processing sketch…

1 Like

You have posted this request 3 times now.

Please delete duplicate posts.

These are the other duplicate posts:
https://discourse.processing.org/t/how-to-convert-image-into-a-blinking-led/15019
https://discourse.processing.org/t/how-to-convert-image-into-blinking-led/15020

:slight_smile:

1 Like

Duplicate posts deleted.

@shonerudeetha, if you try and need help, post your specific sketch here and what part you are stuck on to get more advice.

dear @noel
how to get pixel values from the array seperately?

Firstly you have to say, what pixel value. For instance, if you want to make a led matrix, and you want to work with three color leds, you need to extract every rgb value. If you want a grayscale matrix you need to extract the brightness value.

@noel
no my mission is connect a LDR in another arduino board.i want to send all the pixel values to the other side through my ldr.then i want to build my previous image in other side.therefore i want to send all the pixel value s binary stream through my LED to my other side through my LDR.i want to build a code to convert pixel values into binary stream .through the led to ldr can send only binary values by blinking.help me to convert all the pixel values in to binary stream serialy.
it s very simple for you please…

To me this doesn’t sound like a processing problem.
You have data on a sd-card read the data, and send it to another arduino. Why would you decode the image on a computer (e.g. with processing) send the data back to arduino and then send it?

The image-file on the sd-card ist binary, you could maybe just send the data directly without the conversion.

1 Like

Your topic title doesn’t show what you are talking about. You have to be very clear about what you want. And you even didn’t respond if it is a colored or grayscale matrix.

I feel so stupid because I don’t understand none of your question. If you don’t want to decode on the computer then why do you need Processing?

Exactly, my point was that if he only wants to send the image-data, then there is no need to use processing. That can be done directly with the arduino-boards. (And the arduino-forum is maybe the better place to ask for help on the project).

But maybe i just got something wrong in the problem description.

If you can’t describe it well in words design the schema and post it as picture.

@benja
Then how can i transfer my image through LED and the LDR?Can i do with this only arduino??without processing??

@noel
then what should i do?

Maybe I understand what you want now.
You want a pixel array of an image that you can store on your SD card of your arduino. And then acces that array there to display on your matrix.
Below the code for obtaining the values.

PImage img; 
void setup() { 
  size(200, 200); // Note that the size is the same as image
  img = loadImage("your_image_in_data_folder.jpg"); // just to facilitate;to be able to use width and height
}                                  
void draw() { 
  loadPixels(); 
  img.loadPixels(); 
  /*  This part of the code with colored matrix
  for (int y = 0; y < height; y++ ) { 
    for (int x = 0; x < width; x++ ) { 
      int loc = x + y*width; // The functions red(), green(), and blue() pull out the three color components from a pixel.
      float r = red(img.pixels [loc]); 
      float g = green(img.pixels[loc]); 
      float b = blue(img.pixels[loc]);
      //  Here you write these values to the port with a separator character
      // after each rgb group so that the order can be recognized in the arduino code
      pixels[loc] = color(r, g, b);
    }
  }
  */  
// This part of the code for grayscale matrix
   for (int i=  0; i < img.pixels.length; i++) {
     color c = img.pixels[i];
     float value = brightness(c); // Write this value to the port
     pixels[i] = color (value, value, value);
   }
  updatePixels();
}
1 Like

@noel
then how can i convert those pixel values in to binary ?this code give only load the image only.then how can i convert?

Once again you have to be more clear.
Everything is binary. What data type are you working with on the arduino? Byte, integer? You have to say this first because these data types ara interpreted differently on arduino and and Processing. An integer has 2 bytes on Arduino and 4 in Processing. Also you didn’t answer if it’s colored or mono.

@noel
data type is integer and i want mono images

Be sure to have a color picture in your data folder without alpha channel (transparency) and that the size of the sketch has the same size of the image.
If everything goes well, you will have a text file in your sketch folder with all the brightness integer values of each pixel. Note that it is one array reading the pixels from left to right until bottom. If you want to rearrange them in the arduino sketch you have to use a for loop with width and height.
The text file you can save on the SD card and use it with the SD lib for Arduino here

PImage img; 
String [] my_pixel_array;

void setup() { 
  size(200, 200); // Be sure that the size is the same as image size
  img = loadImage("my_picture_in_data_folder.jpg");
  my_pixel_array = new String[img.width*img.height];                                 
  loadPixels(); 
  img.loadPixels();
  for (int i=  0; i < img.pixels.length; i++) {
    color c = img.pixels[i];
    float value = brightness(c);
    my_pixel_array[i] = str(int(value));
    pixels[i] = color(value, value, value);
  }
  updatePixels();
  saveStrings("my_values.txt", my_pixel_array);
}
1 Like

@shonerudeetha Well you didn’t tell if you succeeded.
How are you going to implement your binary stream? Will it be your own design, like Alexander Graham Bell did in 1880 with his Photophone . Or are you going to use a let’s say a Manchester encoding method, commonly used on Legacy Ethernet networks. How are you planning your synchronization pattern? Let us know!