LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Offline Image analysis using images from directory

Hey Ram,

Here is a VI I wrote that does something like what you want. You provide two image paths and it will subtract them for you. However, it does it in RGB and not Grayscale.

Hope it helps.

Jack J.
Product Support Engineer
National Instruments

0 Kudos
Message 11 of 14
(959 Views)
Thanks Jack for the VI and the explanation.

I was looking at the user manual of NI-VISION today when I noticed a formula for converting an RGB image to grayscale.
*******************************
RGB to Grayscale
The following equations convert an RGB image into a grayscale image on
a pixel-by-pixel basis.
grayscale value = 0.299R + 0.587G + 0.114B
This equation is part of the NTSC standard for luminance. An alternative
conversion from RGB to grayscale is a simple average:
grayscale value = (R + G + B) / 3
********************************
I modified your VI to take an average of the R,G and B arrays and used the "Flatten Pixmap" and "Draw Flattened Pixmap" VIs to display the converted image.  To my surprise, I found the displayed image to be colored.  Attached, you will find the VI and the image I used.

I would appreciate if you can go through the VI and let me know of any modifications that have to be made.

Thanks.

Ram
Download All
0 Kudos
Message 12 of 14
(951 Views)
IMAQ subtract is still easier Smiley Happy
 
If you are going to be doing a lot of vision invest in the software.
 
Matt
Matthew Fitzsimons

Certified LabVIEW Architect
LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
0 Kudos
Message 13 of 14
(948 Views)

I whole heartedly agree with you Matt. Using Vision is much easier.

Ram, using the formula you found is a good idea. The reason you are still getting color images is that the picture control interprets the result of the equation a color values. So for example if you have a pixel that has R=50, G=100, B=150,  and we average that we get 100. But when you feed an U32 element of 100 to the picture, it interprets that as R=0, G=0, B=100 and you get a solid blue pixel. When you really want to show a grayscale picture, it means that all the values R, G and B should be the same. So you should really be wiring in R=100, G=100, B=100.

I modified my earlier VI to incorporate this new information 🙂

I think that should do it
 
Jack J.
Product Support Engineer
National Instruments
0 Kudos
Message 14 of 14
(937 Views)