LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how can convert 2D array to color picture

Solved!
Go to solution

hi

i have a 2d array and want to convert it to a picture.
but i want to crate a color picture.

that the color of each element match the attachment pic.
for example if the element in the 2d array is 10 the color is red.
and if the element in the 2d array is -15 the color is blue

thanks.

color

0 Kudos
Message 1 of 20
(7,600 Views)

I believe using "Intensity Graph/Chart" is an option available to you.

You can also refer to the shipped examples : labview\examples\general\graphs\intgraph.llb

 

If you can attach your data, I can try to make an example code.


I am not allergic to Kudos, in fact I love Kudos.

 Make your LabVIEW experience more CONVENIENT.


0 Kudos
Message 2 of 20
(7,574 Views)

hi dear moderator

than you for your answer.
i want to convert my 2d array to pic same as matlab.
for example see this vi that i attached for you.

i want the result be same ac this pic(attach).
but i cant do this in labview

thank you so much

 

 

r

 

 

0 Kudos
Message 3 of 20
(7,537 Views)

You are almost there. All you need is add a color array to the bottom of flatten pixmap. 

0 Kudos
Message 4 of 20
(7,534 Views)

You need to add an array of colors where the value is a certain color and the array index corresponds to the input value 0..255). In your case, ~element #140 should be red and element #0 should be blue... and anything in-between accordingly.

 

Here's a quick example, but of course the color ramp (taken from a shipping example) is not exactly right, so you need to do a little bit of work. 😄 I changed the scaling a little bit (x180 instead of x100) and also simplified your code. I have no idea why you think you need so many loops! 😮

Message 5 of 20
(7,527 Views)

hi dear altenbach

thank you so much for your help it's very usefull.

in the main vi, my element in 2d array is almost between -300 to 300 and min&max of array is change in every case(because use random in it).
and when i use this rainbow, a white or balck area is creat.(i think that mean the element is lower or upper than range)

how can i set rainbow range with my min &max?

thanks

 

 

0 Kudos
Message 6 of 20
(7,518 Views)

You cannot have negative values in a picture. Just offset and scale the data so it is 0..255.

 

... Or you could use an intensity graph instead.

0 Kudos
Message 7 of 20
(7,516 Views)

altenbach wrote:

... Or you could use an intensity graph instead.


Here's a quick example. Now you can easily add or remove markers and change their color to any range you want. Of course if you want negative numbers, use a different datatype. Rest stays the same.

 

 

Download All
Message 8 of 20
(7,506 Views)

what is intensity graph instead?

0 Kudos
Message 9 of 20
(7,500 Views)

@hamedi wrote:

what is intensity graph instead?



Check
second reply of this topic.


I am not allergic to Kudos, in fact I love Kudos.

 Make your LabVIEW experience more CONVENIENT.


0 Kudos
Message 10 of 20
(7,494 Views)