Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

16bit to 8bit image conversion problem

Solved!
Go to solution

Hello, I am trying to cast an image that is 16bit to 8 bit for pattern matching. I run into a problem when the image is cast to 8bit, the entire image is black, creating an error which correctly states that the contrast is to low (which makes sense since there is no values). Using a other programs I am able to convert 16bit to 8bit fine. I tried playing with the shift optiond a few times in the cast image vi to no avail. Both the 16bit and the 8bit image are unsigned. I will attach both the images and a picture of the code below.

Download All
0 Kudos
Message 1 of 9
(5,174 Views)

The error comes from the IMAQ LEarn Pattern VI. Learning a pattern requires an image that is suitable for pattern matching. Low contrast images are frequently rejected by this VI. See the Vision Concepts Manual for details.

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

Indeed, but the issue I am facing is before the image is sent to the learn pattern VI. The 8bit image is black, hence there will be no contast. 

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

@dbrittain wrote:

[...]The 8bit image is black, hence there will be no contast. 


That's why you cannot use Pattern Matching without preprocessing the image in a certain way. 

You might be better of enhance the contrast - maybe before converting it to an 8bit image.

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

I will try that. My intution however is that the conversion process itself is not reporting the correct values for the pixels as it is floored to black.

0 Kudos
Message 5 of 9
(5,139 Views)

Sorry for me not having looked earlier at your 16bit image:  The image has a that weak contrast that I do not expect any successful pattern matching with = I do not see any part of the image that I(!) would select a template from. 

I have not worked with texture VIs that come with NI Vision.  Did you check these?

0 Kudos
Message 6 of 9
(5,134 Views)
Solution
Accepted by topic author dbrittain

I figured it out, I had to manually convert to 8bit to get the right values for the pixels. The 8bit image looks similiar to the 16bit one now, allowing me to do pattern matching in my vi. It seems as if using unsigned 16bit images and trying to convert to 8bit via the Cast Image function sometimes there pixel values are not converted correctly. 

0 Kudos
Message 7 of 9
(5,119 Views)

Are you sure that converting to 8bit to get the right values for the pixels first can work well? and can this solution be applied to all the image format?

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

With regard to Pattern Matching the action is appropriate: Pattern Matching requires 8bit images.

I do not understand your expectation when asking

 


@CarllyleIMAGE wrote:

... and can this solution be applied to all the image format?


Can you put some light on it?

0 Kudos
Message 9 of 9
(5,024 Views)