LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

save grayscale as rainbow

Solved!
Go to solution

Hi

 

How can i save a grayscale sgl as rainbow?

 

i analyze the image in grayscale but for presentation i need to show it in rainbow.

 

my code doesnt work, however

 

save grayscal SGL as rainbow.png

0 Kudos
Message 1 of 12
(7,822 Views)

update, i change the image type to U16

 

I manage to save the image, however still in grayscale format

 

save grayscal SGL as rainbow.png

0 Kudos
Message 2 of 12
(7,813 Views)

this is first method to save and show rainbow image 

 

Message 3 of 12
(7,751 Views)

also test this 

 

but if you just  want show image in rainbow just right click on image go to palette and select rainbow 

0 Kudos
Message 4 of 12
(7,745 Views)

Hello Hatef,

 

what if my image is a grayscale sgl image?

0 Kudos
Message 5 of 12
(7,712 Views)
convert your image to rgb32 bit
it will be work you can not save sgl with know format like png but because you want save data in rainbow you can do it by convert your image to rgb 32 bit so use conver image and use rgb 32bit type
0 Kudos
Message 6 of 12
(7,700 Views)
Solution
Accepted by topic author coloredsound

This turns out to be a fairly "deep" question that gets into numerous topics not particularly well covered in the IMAQ documentation (or not always as accessible as one would like).  There are several related sub-topics:

  • Displaying GrayScale Images on "normal" PC Displays.
  • Efficient "colorization" of GrayScale image.
  • Use of LookUp Tables (LUT) in Image Colorization.

At various times, I've dabbled with elements of this problem, but never quite "got it".  However, some comments and posts by Hatef Fouladi and some digging around the LabVIEW Vision Documentation led me to a better understanding of this question, and a potential "partial" solution (I call it that because it might not directly answer the question posed by the Original Poster).

 

I'm going to beg your indulgence -- both for myself, my students, and this Forum, I want to try to supply some of the "missing Documentation", which will require about a day or two of work.  I can tell you that I have a tentative working routine that can take a "Gray Gradient" and, after applying the "Rainbow" LUT, turn it into a PNG that ... looks like a Rainbow.

 

But while writing this Response and about to "apologize" for making you wait, I realized that while I had, indeed, "colorized" my Image (as verified by displaying it on the Screen), I'd forgotten that the goal was to save the PNG as a colorized Image.  So I added the PNG Write function, saw the "Color Palette" input, and said, "Hmm, I wonder ...", which leads me to this:

Gray Rainbow.png

I chose to work with U8 Grayscale Images.  A difficult-to-find note here, from the LabVIEW 2010 Vision Manual, explains that PC displays can only show 256 levels of Gray, so U16 Images need to be "remapped" to a U8 range before visualizing as Grayscale.

 

The nested For loops generate a 128-by-128 pixel "Gray Gradient, with 0 (black) in the upper left corner and 254 (white, almost) in the lower right.  That's the Image I will use, writing it out as Gray.png.  The IMAQ Write File 2 (IMAQ functions changed a few years ago, many taking a "2" suffix) has a Color Palette input, and IMAQ provides a few standard LUTs (which it calls "Palettes"), including "Rainbow", using the IMAQ GetPalette function.  I wired this up into a second Write File 2 function, and the results are shown below.

Gray.pngRainbow.png

I still intend to write this up further, but this "solution" is so simple, and what I'm hoping to explain is sufficiently complex, that I may take a little more time to "do it right".  I will (eventually) post it here (or, at least, those are my Good Intentions).

 

Bob Schor

 

Message 7 of 12
(7,688 Views)

As a non-LabVIEW solution, you can use a free program called ImageJ which I believe is used in many fields of science. It has some nice lookup tables that you can apply to an image.

0 Kudos
Message 8 of 12
(7,670 Views)

@Gregory wrote:

As a non-LabVIEW solution, you can use a free program called ImageJ which I believe is used in many fields of science. It has some nice lookup tables that you can apply to an image.

 


 with Imagej  you have to work and save file with tif format if you want 32bit GS  image. if you use other format  to save image' image  will be convert to U8 automatically before save

 

 

tif.png

 

also there is no rainbow tools LUT tool of imagej 

instead we can use one of method that you can see it in image 2 
lut.png

 

 

but for labview you have to save image in binary mode or inside the text as matrix 
many years ago I develop an image processing software with labview and with ability and style of image j but with more feature's  and with persian language. I call it Image M  one of my problem that Imagej could handle it but in labview it was so hard to do it was to save 32bit GS image and I have to save it in binary file with my written software Image M

Message 9 of 12
(7,645 Views)

Hi All,

 

Thank you for your reply, 

 

After I study your posts, finally I managed to convert grayscale sgl to rainbow

 

the trick is to rescale the image

 

here i attached my code and result

 

grayscale sgl to rainbow.png

 

grayscale sgl to rainbow.png

 

0 Kudos
Message 10 of 12
(7,594 Views)