LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

converting RGB to grayscale

Solved!
Go to solution

I am acquiring an image and the output appears to be a grayscale image, but the text states that it is in fact an RGB image. I'd like to save some space and convert it into a GrayScale image. I have labview 8.2 and I don't have vision. Is there any way to do this?

0 Kudos
Message 1 of 10
(16,573 Views)

Hi:

 

What do you mean by “I don’t have vision”? In the VI attached I could see that you are using a Vision Acquisition Express VI and also an IMAQ Write vi.

0 Kudos
Message 2 of 10
(16,511 Views)

I was able to download a trial of IMAQdx but I don't have the majority of vision.

0 Kudos
Message 3 of 10
(16,508 Views)

Hi,

 

    Here is a almost solution, try if you can get best color, i am viewing black and white :S.

 

VI Snippet.png

 

Best Regards,

Luis A. Mata C.
Ing. Electrónico
Whatsapp: +58-414-1985579
BBM Pin: 2B83E99A
Thanks: Kudos
0 Kudos
Message 4 of 10
(16,491 Views)

I only have LabView 8.2. Can you please upload an older version?

 

Thanks!

0 Kudos
Message 5 of 10
(16,489 Views)

If the RGB image is greyscale, it means that the R, G, and B components are the same for each pixel. Simply create an appropriate color map and retain one of the components as index into it.

Message 6 of 10
(16,480 Views)

Hi wiswana,

 

To convert to a grayscale image we will need the R, G, and B values from the image. The most common technique for converting to a grayscale image is to use a formula like the one below (see this thread for code and more discussion):

 

Grayscale = 0.299R+0.587G+0.114B

 

Note: these coefficients are subjective and can be changed depending on your tastes (this link talks about this in depth).

------------------------------
Bill E. | Applications Engineer | National Instruments
0 Kudos
Message 7 of 10
(16,478 Views)

I think you describing the conversion of a color image to a pleasing greyscale image.

 

The way I read the question is that the image is already greyscale, but just represented in 24bit color at the moment. I don't think your scaling is needed and would not make a difference.

 

Maybe I am reading the question wrong....

0 Kudos
Message 8 of 10
(16,470 Views)
Solution
Accepted by vviswana

Hi,

 

    Here is my code fixed at LV 8.0.

 

Front Panel.PNG

 

Best Regards,

Luis A. Mata C.
Ing. Electrónico
Whatsapp: +58-414-1985579
BBM Pin: 2B83E99A
Thanks: Kudos
Message 9 of 10
(16,450 Views)

I made the mistake of trying this on a picture of my face. It works great - the the image's values are flipped. (So you get the eerie, x-ray image effect).

 

If this isn't what you want, remove the 'not' vi from the loop, and you get quite a visually pleasing result. Thank you for the algorithm to convert color to grayscale, it was exactly what I needed!

Using Labview 2022, Windows 10
0 Kudos
Message 10 of 10
(11,414 Views)