Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Thresholding-Can I leave a certain grayscale range alone?

I would like to keep a range of grayscale in my bitmap image, but change everything above or below that range to a high or low number.
0 Kudos
Message 1 of 3
(2,954 Views)
Okay, let's say you want to make everything below 100 black, everything above 200 white, and keep the remaining pixels at their original values.

Make two additional copies of your original image. Threshold one from 0-100 and the other from 200-255. Apply each of the resulting binary images in succession as masks for the original image. Set the fill value to 0 in one case and 255 in the other.

There is probably another way to achieve this, but this method is fairly simple.

Good luck,

Brent R.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 3
(2,954 Views)
One way is to create a custom lookup table. You can create a for loop that loops 256 times, and wire the index out to create your lookup table. With no modifications, this is a straight linear mapping - everything stays the same. You can modify the value of the index as you create the lookup table, though. For example, replace all values less than 100 with 0 and all values greater than 200 with 255. When you apply the lookup table, the resulting image will be what you want. One big advantage of this method is that once you create the lookup table, you can apply it to multiple images.

Bruce
Bruce Ammons
Ammons Engineering
0 Kudos
Message 3 of 3
(2,954 Views)