Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert a 16-bit image to 8-bit one?

I want to convert a 16-bit image (10-bit depth) to 8-bit by some user defined dynamic range, like 5%-90% instensity or some specified values. The winddisplaymapping seems to work but only for display. I am thinking of combinning image operator functions with the cast function, but there still one thing confused me: the histgoram function can give a result of 16-bit image, but the histogram array only range from 0-255, which should be 0-1023 in my case. Not sure how it converts the data to 255. It would be better if I can have a full range histogram. So how to convert it better and faster?
0 Kudos
Message 1 of 4
(3,867 Views)

Hello Ishi,

 Thank you for contacting National Instruments.  It sounds like you are trying to convert a 10 bit image to an 8 bit image.  Casting the image to the new type (16 bit to 8 bit) is the best way, though it will cut off your bottom 8 bits.  So, I would make sure that the image data is stored in the first 10 bits not the last (e.g. XXXXXXXX XX000000 which will just cut off the last 2 bits, not 000000XX XXXXXXXX which would cut off all but two bits of your image data).  You can shift the bits using the Programming >> Numeric >> DataManipulation >> Logical Shift VI.
 I'm unsure what you mean by intensity percentages.  Can you provide a more detailed explanation of what you are trying to do with your 8 bit image once you have it?  From what I could tell, it sounds like you want to choose an upper and lower limit for your intensity values and threshold it at those values (change all pixels above and below that range to a certain color/byte value), we have several Threshold IMAQ VI's that you can use to do so.  Thank you.

-Allison S.
Applications Engineering

 

-Allison S.
Calibration Services
Product Support Engineer
0 Kudos
Message 2 of 4
(3,845 Views)
Yes, that's what I want. Meanwhile, I also like to have a full range of the histogram, from 0 to 1023 in my case. But I don't know how. Thanks
0 Kudos
Message 3 of 4
(3,843 Views)
Ishi,
    The Histograph function automatically adjusts to the range of data (it will show that it's ranging from 0 to 1023 in your case) but the default number of classes is only 256.  The input on the top of the Histograph VI called Number of Classes lets you change the number of classes.  If you change it to 1024 it will sort into 1024 classes, not just 256 classes spread through out 0-1023.  I am attaching a simple VI that creates a 10bit image and then runs it through a Histograph.  Let me know if this is all you need, thank you 🙂
-Allison S.
-Allison S.
Calibration Services
Product Support Engineer
0 Kudos
Message 4 of 4
(3,828 Views)