LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

convert data to grayscale image

Hello,

I'm working with Labview 7.0 and Imaq Vision.
I would like to display a picture from an array containing 8 bits data. I have created a dll that fills my array, and now I'd like to convert it in picture.
My problem is that I would like to obtain a grayscale picture, and I don't manage to do it.
I have managed to display a "blue" picture (using 32 bits data). Using 8 bits data, the picture is multicoloured.

Could you help me in doing this because I have no idea of how doing it.
Enclosed are the 2 (indepedent) VIs I have already made (using 32 or 8 bits data) with the dll (I'm using a dll because I'll need to diplay other pictures coming from hardware later).

Thank you to help me if you have an idea,

Delphine
0 Kudos
Message 1 of 9
(3,633 Views)
Hello Delphine,

without looking at your vi's:
In 32bit-mode you got a blue picture. That's because of RGB-interpretion of your data. You supplied only the lowest 8 bit, this gives you the blue color. To get "gray" you have to supply R, G and B. All you have to do is to "multiply" your 8bit to 24bit: join 3 U8 values to a U32 for each pixel.

In 8bit-mode you got a multicolored picture. That's probably because you didn't supply a colortable. If you would supply a colortable with all gray values your picture should be fine.
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 9
(3,620 Views)
You said that you are using Imaq Vision, but you keep using the basic LabVIEW picture display, which is an awfull tool. Complicated and terribly slow. Things would have been much simpler with the Imaq display tools, where you can easily define/choose the color palette to be used. I am not sure either that a ddl would have been required.

CC
Chilly Charly    (aka CC)
0 Kudos
Message 3 of 9
(3,616 Views)
Thanks for your answer.

I'm using a dll because when this part will work, I will add other functions (to acquire data from hardware) for which I need a dll. So I've directly start using a ddl.

Concerning Imaq Vision, I tried to use it in the VI but I didn't manage. Could you help me doing this?

Thanks,

Delphine
0 Kudos
Message 4 of 9
(3,613 Views)
Try that...

CC
Chilly Charly    (aka CC)
0 Kudos
Message 5 of 9
(3,609 Views)
Thanks for your response but I only have Labview 7.0.
Could you send me the same file in this version please? I will help me a lot.

Thank you,

Delphine
0 Kudos
Message 6 of 9
(3,605 Views)
I'm trying to do the two solutions you spoke about.
Concerning the color table, could you explain me how to create a grayscale one? I tried to do it but I didn't manage.

Thanks,

Delphine
0 Kudos
Message 7 of 9
(3,601 Views)
Not sure that the subs have been saved properly, but here is a 7.0 version

CC
Chilly Charly    (aka CC)
0 Kudos
Message 8 of 9
(3,601 Views)
It works!!!
Thank you a lot for your fast response!

Delphine
0 Kudos
Message 9 of 9
(3,596 Views)