Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Wrong colours using IMAQ JPEG Decode.vi

I am using IMAQ JPEG Decode.vi to convert a jpeg stream from my camera to an IMAQ image directly. This way I don't have to save any images to file before i process them in my application. However there is a problem. The mentioned VI seems to alter the colour information in some way, such that the image displayed has different appearance from reality. The algorithms I use (Vision modules), also have different effects on the images with changed colours. Does anybody have an idea of what is causing this problem and what could be done to avoid/correct it? I have attached to slightly different pictures with correct and wrong coloration.
Download All
0 Kudos
Message 1 of 17
(5,011 Views)
Try using the JPEG Compression VIs posted on another discussion forum thread:
http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&RNAME=ViewQuestion&HOID=506500000008000000647A0000&ECategory=Vision

When I ran this with a saved jpeg, the colors looked fine.

Hope this helps-
Julie
0 Kudos
Message 2 of 17
(5,012 Views)
Thanks for the answer.

It works with saved files for me too, but I guess the compression done by the camera is different from the encode JPEG VI. Another peculiarity is that if I save the image to a jpeg file and reopen it (using labview VIs) the colors look fine - this is a solution I can use, but it is very slow. I wonder if the IMAQ Read file is using the same decoding algorithm as the one in decode JPEG?
0 Kudos
Message 3 of 17
(5,013 Views)
The problem is that the red and blue color planes are switched. After switching them back, everything looks fine. I don't know why they are being switched, but I know how to correct it.

One way to solve this is to manually switch the color planes. You can use one IMAQ vi that extracts all three color planes, and a second one that combines them back into an RGB image (after reversing the Red and Blue images). I suspect this is a very fast operation, and it could be done on either end of your system.

Bruce
Bruce Ammons
Ammons Engineering
0 Kudos
Message 4 of 17
(5,015 Views)

wow.. a 2003 thread with 2010 same problem..

i get an image from my camera in jpeg format i use jpeg decode .vi but it seems that blue and red are incorrect (as described above) i tried colour plane extract but i couldn't use them correct to produce the correct image from them..

How can i change blue channel with red channel?

Thanks 

0 Kudos
Message 5 of 17
(4,407 Views)
You need to use IMAQ ExtractColorPlanes in conjuction with IMAQ ReplaceColorPlane.  Once you extract the planes, wire the red plane to the blue plane input of the replace function and vice versa.  If you have trouble with this, post the code that you're using.
Alex Person
NI-RIO Product Support Engineer
National Instruments
0 Kudos
Message 6 of 17
(4,408 Views)

A word of warning:  I think some people have complained of a memory leak when using decode JPEG on color images.  You might want to keep an eye on your memory usage and make sure it isn't growing steadily.

 

It sure would be nice if NI added a built in version of this routine that would extract the color planes correctly.  It wouldn't be too difficult - just convert the existing read from file to read from a string instead.  I keep seeing people that need this functionality, but NI does not seem to see them. 

 

Bruce

Bruce Ammons
Ammons Engineering
0 Kudos
Message 7 of 17
(4,408 Views)

"A Person" i tried this but it gives me an error saying that the object from the jpeg decode .vi is not an image..!! although if i link to image.ctl i can show the image on FP or save it as image.

 

 Bruce Ammons is there any other way to do this..? i can't understand why labview doesn't have this functionality.. it's frustrating..

0 Kudos
Message 8 of 17
(4,402 Views)

Bruce Ammons wrote:

 

It sure would be nice if NI added a built in version of this routine that would extract the color planes correctly.  It wouldn't be too difficult - just convert the existing read from file to read from a string instead.  I keep seeing people that need this functionality, but NI does not seem to see them. 

 


Hi Bruce,
I thought we added some public functions to do this during the last release but apparently that was not the case. I have noted it and hopefully we'll be able to get it into a future release. Please keep in mind that the actual implementation of any new function is only about 5% of the work needed to get some new VI onto the palette (there's specification docs, testing, public documentation, icon design, more documentation, etc..) that make it hard to "slip in" small new features, so I can't guarantee when such functionality might be available...
In the meantime, be sure to not let us forget that this would be a valuable feature for you! 😉 
Eric 

 

0 Kudos
Message 9 of 17
(4,401 Views)

Karpa:

 

Can you show us the code you are using by posting the VI or a screenshot so we can help you troubleshoot it better?

Alex Person
NI-RIO Product Support Engineer
National Instruments
0 Kudos
Message 10 of 17
(4,396 Views)