LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

gray scale color table

Solved!
Go to solution
I want to make a picture out of an 8-bit unsigned integer 2D matrix of data. I can successfully do that using the "draw unflattened pixmap" function. However, it requires a color map. If you don't wire the color map, it uses the default labview color map. I want to use a gray scale color map (numbers between 0 and 255 corresponding to colors ranging from white to black). I am not sure how to make this color map and implement it. I appreciate any help.
0 Kudos
Message 1 of 10
(8,041 Views)

Make a 1-D array of U8: 0x00, 0x01, 0x02, 0x03, ..., 0xFF

 

 

George ZOU

http://www.geocities.com/gzou999

 

George Zou
0 Kudos
Message 2 of 10
(8,034 Views)
Thank you very much for the suggestion. But I am not sure what the x stands for in 0x00 and what is FF? Is it hexadecimal? If yes, then what is x? I appreciate the help.
0 Kudos
Message 3 of 10
(8,020 Views)

Hi Jahan,

 

yes, "0x" stands for hexadecimal numbers! Just right-click any numeric control/indicator/constant, select hexadecimal representationand the x is shown at the left border...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 10
(8,018 Views)

Thank you very much for the help. But still I am not understanding this correctly.

 

1)- First of all why hexadecimal?

 

2)- Second: I am using a loop to generate a 1D array of unsigned 8 bit integers from 0 to 255. I am using the loop counter "i" to do that. I tried to convert the loop counter to hexadecimal, but I was not sure how.

 

3)- Also, I could not get an 0x to appear at the left corner of a number after I changed the representation to hexadecimal.

 

4)- I did not find a function that takes a number and converts it to hexadecimal. I am using LabVIEW 7. Where is this function?

 

 

Sorry for asking too many questions. I hope you will have time to answer.

0 Kudos
Message 5 of 10
(8,016 Views)

Jahan wrote:

Thank you very much for the help. But still I am not understanding this correctly.

 

1)- First of all why hexadecimal?


I don't think George had any particular reason. Sometimes it's just easier to represent numbes in hexadecimal format. It's still the same number, it's just displayed differently. Hex FF = decimal 255. Same number.

 


2)- Second: I am using a loop to generate a 1D array of unsigned 8 bit integers from 0 to 255. I am using the loop counter "i" to do that. I tried to convert the loop counter to hexadecimal, but I was not sure how.

 You don't need to do that. The values of the numbers is what's important, and as I indicated it will still be the same whether you display it in decimal or hexadecimal format. 

 


3)- Also, I could not get an 0x to appear at the left corner of a number after I changed the representation to hexadecimal.


 You need to enable the "radix" display. When you right-click on the constant or control and select Properties it's on the Appearance page, marked "Show radix".

 


4)- I did not find a function that takes a number and converts it to hexadecimal. I am using LabVIEW 7. Where is this function?


There isn't one because there's no need to do so. The value of the number doesn't change. There are, however, functions to convert from/to hexadecimal strings, but that's something different.

 

 

 

0 Kudos
Message 6 of 10
(7,999 Views)
0 Kudos
Message 7 of 10
(7,992 Views)
The part about making each R, G,and B values the same is what was missing from George's response. Yes, to get a grayscale color map you can just have a loop to generate the 256 entries and use the RGB to Color VI to get your color by setting the R, G, and B values to the same value (i.e., the iteration loop). Is there a better way? Well, I suppose you could just have the resultant array as a block diagram constant. That would eliminate having to generate it "on the fly".
0 Kudos
Message 8 of 10
(7,976 Views)
Solution
Accepted by topic author Jahan

Jahan wrote:

Yes, this is technically correct (top). (Typically you can do it once, then right-click the indicator and "change to constant" and delete the loop code.)

 

You might also flatten the rgb tool code to the diagram (bottom). This has the advantage that the entirel loop will be calculated once at compile time and internally folded into a constant so the loop actually never spins during execution of the program (See also). (Of course this particular loop is trivial and nothing to worry about, performance wise. ;)) 

 

 

 

Message Edited by altenbach on 03-14-2009 09:57 AM
Message 9 of 10
(7,971 Views)
Thank you all for your help and suggestions. I will do the constant array trick to eliminate extra spinning of the loop. Cheers. On my front, I consider the problem solved (for the time being):smileyvery-happy:
0 Kudos
Message 10 of 10
(7,960 Views)