LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

modifying colors in images

I am trying to create a vi in Labview 7.1 that will upload an image from a jpeg file, modify the color and luminance of the image, and then output the image as a jpeg file. I am currently able to input and output the image to a file, but I am having difficulty modifying the colors of images. I read in a manual that the color control was a 32 bit array, but when I try to make my own array and wire it to the color control on the image block, it breaks the wire and won't let me make the condition. How do you design a proper array to set color and which array elements correspond to red, blue, green, hue, luminance, and saturation of the image? I am able to manually adjust the color and set my own color in rectangles, but I wanted to create an automated process with an array to automatically generate a range of colors.

The other problem I was having was getting the image to be displayed on the visual panel of Labview. I can import and export the jpeg file, but I cannot get it to be displayed on the grid. I would greatly appreciate any assistance and advice you have.

Thanks,

Daniel
0 Kudos
Message 1 of 4
(4,347 Views)
If you are going to do some heavy image manipulation, you may wish to look into a LV toolkit called IMAQ, which allows you to go that way.
If not, you can start by using the standard picture VIs (Graphics & Sound palette), which I assume you already do to read and write the file.

LV treats a picture in one of three formats:
1. Picture - the blue wire. You will need to to use this for any manipulation using the picture VIs.
2. Pixmap. A 2D numeric array in which each cell holds the color value of the coresponding pixel.
3. Flattened pixmap. A cluster holding all the picture information in which the pixel data is stored as 1D array.
There are VIs for converting all these formats.

To replace colors you can simply use Replace Array Subset to replace specific cells either in the 1D or 2D array or use the Draw point VI. The main problem you will have is that you will need to calculate everything on your own. If you want to modify the entire image, you can go over the array in a loop and (for example) increase all values by 1000 and see what that does.

All of this can be found from reading the help files for the VIs (right click>>Help), which is what I suggest you do to learn more about this.

You can display an image simply by converting to the first format right clicking the VI output (picture) and selecting Create>>Indicator. because it's a picture format, a picture indicator will automatically be created.

It sound as if you don't have much experience in LV. Also, try searching this site and google for LabVIEW tutorials. Here and here are a couple you can start with. You can also contact your local NI office and join one of their courses.
In addition, I suggest you read the LabVIEW style guide.

___________________
Try to take over the world!
Message 2 of 4
(4,331 Views)
I'm attaching the VI I used to modify color. My biggest problem is I don't know how the colors array is set up. I read in a manual that the colors aray is a 1D array of 32 bit signed integers, but I'm not sure which bit corresponds to red, blue, and green, and the luminance and saturation. I also don't know how to create an array divided into bits. I'm able to modify color, but I don't have a lot of control over how the colors are modified. I would appreciate any feedback on my vi and how I could set up a 32 bit signed array with my own calculated values
0 Kudos
Message 3 of 4
(4,319 Views)
I modified your VI a lot. A few points:
1. You should really keep things organized or the VI is impossible to read. Look at the style guide I linked to.
2. You did some unneccesary conversion from pixmap to picture and back.
3. The VI shows 2 ways - one by modifying the 2D array and one by modifying the 1D image (not colors) array. Notice the different representations. If you right click any of the VIs regarding the pixmap and select help, you will see a description of the cluster which tells you that a 24 bit image does not have a color array (because it uses all the colors available in the default palette) and that each pixel is described by 3 bytes (i.e. 3 elements of the array - RGB), so you will need to write some logic for how to change each of them. The 2D array version is simpler because it uses one U32 for each pixel and the index correponds to the pixel, but you need to know how much to change. You can use the RGB to color VI to determine that.

___________________
Try to take over the world!
0 Kudos
Message 4 of 4
(4,306 Views)