# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution
Highlighted

## Convert 2d Array to Jpeg using intensity graph color ramp

I have a 2d array of some n x m size that I want converted to a jpg with the same resolution (ie, I want the jpg to have n x m pixels). I am displaying this 2d array in an intensity graph. I am currently using flatten pixmap to convert my 2d array to an image and then saving it as a jpg. Unfortunately the colors are not coming out how I want. If I try to use the color table from the intensity graph the colors come out correct, but the wrong values are associated with the colors. I want the color scheme of the jpg to match exactly what I see on screen in the intensity graph, but I want the full resolution of the 2d array.

I have attached an example of what I am doing. IntensityGraphColors.vi has an intensity graph showing the 2d array with a particular z-scale color ramp, this vi just takes the 2d array and the color table from the intensity graph and saves it to a jpg. But when I save to a jpg the colors come out different, as shown in test.jpg.

Thanks for the help. I tried searching for similar questions but failed to find any solutions that did what I wanted.

Message 1 of 5
(1,568 Views)
Highlighted

## Re: Convert 2d Array to Jpeg using intensity graph color ramp

Why do you want to save with color instead of grayscale?

Message 2 of 5
(1,547 Views)
Highlighted

## Re: Convert 2d Array to Jpeg using intensity graph color ramp

Grayscale is fine, but I want to be able set the range at which the grayscale operates. Meaning, I want to be able to say an array value of say 50 is black, and an array value of 600 is white and then have it interpolate the grayscale through that range. I don't want it to just assume 0 is black and 256 is white. I hope that makes sense

Message 3 of 5
(1,537 Views)
Highlighted
Solution
Accepted by topic author supercheesepuffs

## Re: Convert 2d Array to Jpeg using intensity graph color ramp

Here is an example going from black to blue to white, which will hopefully point you in the right direction to do whatever you want with the "colors" input.

Please note, the colors input is ignored for 24-bit data.

Message 4 of 5
(1,530 Views)
Highlighted

## Re: Convert 2d Array to Jpeg using intensity graph color ramp

Thanks for the help! I've got it working now. Attached is my solution in case anyone else ever needs it

Message 5 of 5
(1,513 Views)