Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

8-bit has colour?

Solved!
Go to solution

You read it right: my VI displays 8-bit data with colour. Well not exactly with colour, but let me explain.

I wanted to do some basic image processing and tried to following:

 

Grab an image of my webcam

Convert this image to 8-bit

Turn the 8-bit data into an array

Divide the array with a specified number (two, three, four etcetera)

Display the new array

 

However, this causes a flickering in my display. It does display the normal video with an 8-bit divided by the number, but it flickers back and forth between multiple modes, including normal 32-bit full colour view. About one in about every 5 or 6 flickers is a full colour view. Can anyone tell me what has gone wrong here?

0 Kudos
Message 1 of 9
(5,266 Views)

Hi

There is no destination image wired to your image cast. If you create another image of type U8 outside of the loop and wire that to the destination input of the cast you will be good. 

The output of the cast is overwriting the original image. The display points to the image and depending when it updates will result in a different image being displayed.

 

I am sure that we have all done this at one point or another.

 

Mike

0 Kudos
Message 2 of 9
(5,261 Views)

How can I do that? If I need the Cast Image to create an 8-bit display, then how can that work? I tried a couple things that might do what you mean, what you can see here. How can I create another image and use that as reference? I tried looping the entire thing back through an display, a cast image VI and a couple of other things, but none remove the stutter.

0 Kudos
Message 3 of 9
(5,256 Views)

I tried the following:

Labview stuttering image problem.png

I tried this along other things. I tried renaming the IMAQ image I call here to 'Reference', I tried putting it inside the loop, I tried many kinds of wiring the 8-bit signal back to the 'destination image', but no matter what I do, I keep the stuttering.

0 Kudos
Message 4 of 9
(5,246 Views)

For the array to image, use the output from the IMAQ Cast, not the original color image.

 

Bruce

Bruce Ammons
Ammons Engineering
0 Kudos
Message 5 of 9
(5,244 Views)

You mean like this?:

USB webcam n-bit not working.png

This does remove the flickering, but I can't remove its brightness by any number anymore. It now stays the same. I tried it with and without a seperate Imaq create inside and outside of the loop, but that doesn't work either

0 Kudos
Message 6 of 9
(5,241 Views)
Solution
Accepted by Choisai

You could create another image for the destination of the array to image.  Another option is to right click on your image display (front panel) and select Snapshot.  That will make a copy of the current state of the image for display.

 

Bruce

Bruce Ammons
Ammons Engineering
0 Kudos
Message 7 of 9
(5,237 Views)

Yes, thank you so much, it worked. But would you be so kind to explain why the snapshot works? For I have no idea why it works now. It also seems that I don't need to have a seperate 'IMAQ Create VI' for the destination now. Just setting it to 'Snapshot' removes the stutter and does everything I want. How come?

0 Kudos
Message 8 of 9
(5,233 Views)

Usually the front panel image control updates the image constantly independent of the code you are running on the block diagram.  So whatever is in the image buffer is just displayed at whatever rate your front panel updates at.  So when you are using the same buffer to (1) convert from U32 RGB to U8 and (2) feeding in your array after dividing by 4, it is possible that at some time either step may appear in the image display.

 

Snapshot mode tells the image display to not behave that way anymore.  Instead, whereever you have the indicator connected, it will make a copy of the data in the buffer at that time and display that copy.  The update will be tied directly to your code in the block diagaram.  For your application, this will work just fine.  For others it might be a problem if you want faster frame rates and these data copies take too long.

 

Hope this helps.

Randall Pursley
Message 9 of 9
(5,224 Views)