0

i have an array in c:

unsigned char image_in[256*256] = {
     72,  57,  55,  67,  79,  58,  52,  72,  96,  81,  72,  76,  93, 107,  91,  84,  95,  66,....IT GOES ON AND ON 256x256.....}

each value is the 8bit rgb of the indexed pixel.

now the question is how do i show this picture? i can use C or matlab or whatever..

Wops
  • 983
  • 9
  • 23
  • If all you want to do is display this image once, I suggest you write it to a file using the very simple [PNM](http://netpbm.sourceforge.net/doc/pnm.html) format and then use (mostly) any image viewer. – Adiel Mittmann Apr 30 '12 at 17:04
  • write it to file in what format exactly? without ','? with any special header? – Wops Apr 30 '12 at 17:34
  • PNM files are useful because they have a simple format. The header is simple, the contents are structured in a simple manner. Check the link to get to know the format: [PNM](http://netpbm.sourceforge.net/doc/pnm.html) – Adiel Mittmann Apr 30 '12 at 17:40
  • you want to show this image within the program where it's defined, or you just want to see it? and you can copy the values and paste somewhere else? – Castilho Apr 30 '12 at 17:51
  • i can put it wherever i want. just wanna see the pic. – Wops Apr 30 '12 at 21:06

1 Answers1

2

Wops, the question is really not well formulated - there are many missing details, like: do you require a greyscale/RGB image? Do you want to do this programmatically (namely from your C-code), or just a quick one-time snapshot? Can you copy the values to some *.csv file or to a Matlab script (see Casliho's comment)?

If you just want to show the image as grayscale in Matlab, call the imshow function:

m = randint(256,256,256); % This creates a random 256x256 array of integers - replace with your values
imshow(m);                % This creates a greyscale image

From the plot object you will be able to export the image to many formats (*.jpg, *.png etc.)

bavaza
  • 10,319
  • 10
  • 64
  • 103
  • thanks for the reply, the file is an RGB file 8bit. each value is a pixel (a 8bit represent the RGB within this pixel). imshow() in matlab doesent work for me. – Wops Apr 30 '12 at 21:05
  • @Wops - imshow can display RGB. You simply make the input a 256x256x3 array. See the documentation. – bavaza May 01 '12 at 04:33