LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

analyzing certain color patterns in Lab View

Hi,

I was wondering how I would go about

1) reading in a .jpeg,
2) discerning whether a pixel is a certain color (ie, red) and
3) outputting that coordinate to a text file?

I have been trying to find help on how to read actual pixel points and their
corresponding properties (ie, color, x, y), unfortunately, I haven't been
able to search any online literature.

Thanks for taking your time to read through this message.

Thanks,
Paul

--



Paul Rigor
pryce@ucla.edu
Go Bruins!!!
"attack each problerm with as much passion as you would pleasure" -anon
anime?
_____
0 Kudos
Message 1 of 7
(3,610 Views)
The first soluiton I'am thinking of is to code a litlle activeX control to do this task (in Visual Basic you have Point to get information about the color of a x,y point).
0 Kudos
Message 2 of 7
(3,610 Views)
I'm back with details ...
please find attached VIs and pictures (unzip them in c:\temp\) with a short example for analyzing bmp and jpg formats for 24bit pictures. Also, I inserted a short comment for each one on the front panel.
0 Kudos
Message 3 of 7
(3,610 Views)
To read a .jpeg image file, you can use "Read JPEG File.vi", located in the Functions pallette:

Graphics & Sounds -> Graphic Formats

To display the image, use "Draw Flattened Pixmap.vi", located also in the Functions pallette:

Graphics & Sounds -> Picture Functions

The way the pixels are represented in the picture depend on the "depth" of your image. The image is stored in the "flattened image data" output of the "Read JPEG File" vi. 4 to 8 bits depth images need a color table. For images with those depth, the value in the "flattened image data" array indicate the address of the color in the color table. For example, if the first value is 23, it means that the color of that pixel is located in the position 23 of the color table.

1 and 24 bits depth image include t
he color information in the image itself. In a 24 bits depth image, three consecutive values indicate the color of the pixel.

You can simplify the search of the pixel value by converting the "flattened image data" array into a 2D array. To do that, use "Unflatten pixmap.vi", located in:

Graphics & Sounds -> Graphic Formats

Now, you will have the image in a 2D array, where each cell contain the actual value of the pixel.

Remeber that the value of the pixel is in RGB format: you need to convert the pixel into hexagesimal to read the RGB components. In a 24 bits depth image, three consecutive numbers (cells) correspond to the R, G and B values of the color of a single pixel.

To display the color, you can use a color indicator. I don't know where is the color indicator in the Controls pallette. To create one, what I do is that I open "Draw Circle by Radius.vi", right-click the color input and select "Create Indicator". The indicator diplay the color of the pixel, not the value, but yo
u can manipulate its value as it is an unsigned long.

Best regards;
Enrique Vargas
www.vartortech.com
0 Kudos
Message 4 of 7
(3,610 Views)
A short note: Another way of getting a color indicator is to use a Framed Color Box in the Numerics pallette and change it to an indicator. /Mikael
0 Kudos
Message 5 of 7
(3,610 Views)
All this time and I never look there!!

Thanks a lot Mikael!
www.vartortech.com
0 Kudos
Message 6 of 7
(3,610 Views)
> I was wondering how I would go about
>
> 1) reading in a .jpeg,
> 2) discerning whether a pixel is a certain color (ie, red) and
> 3) outputting that coordinate to a text file?
>
> I have been trying to find help on how to read actual pixel points and their
> corresponding properties (ie, color, x, y), unfortunately, I haven't been
> able to search any online literature.
>


If you read the JPEG in using the Picture VIs, the output will contain
all of the data uncompressed into a packed binary format of bytes.
The bytes come in triplets and are the R, G, and B. You can check this
by checking the array size. It should be approximately 3x the width
times the height of the bitmap.

Anyway, this should get you close once you figure out how to compute

the index.

Greg McKaskle
0 Kudos
Message 7 of 7
(3,610 Views)