• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1036
  • Last Modified:

Convert 16 bit image to 12 bit image

Hi Experts,

I new to C# and image processing. I have a 16 bit image stored in a byte array.
Anybody could help me to convert this to 12 bit image.
0
Veerabhadraiahhv
Asked:
Veerabhadraiahhv
  • 3
  • 3
  • 2
1 Solution
 
Jens FiedererCommented:
Just throw away 4 bits!

Actually, not all "image"s are built alike - you'll want to know what the bits are used for.

Odds are your existing image uses either 5 bits for each color with a spare bit used either for intensity or transparency, or 4 bits for each color and 4 bits for intensity, and your target image wants 4 bit for color.  You have to know, though.
0
 
lenordisteCommented:
jensfiederer is right, you need to know what those bits are used for. How is your image encoded (or not...) ? BMP, JPG, PNG ... ?
0
 
VeerabhadraiahhvAuthor Commented:
I have a DICOM image, it may be signed image or unsigned image.
I need to convert these images to 12 bit DICOM image.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Jens FiedererCommented:
Fortunately, the DICOM standard is publicly available:

ftp://medical.nema.org/medical/dicom/2009/
0
 
lenordisteCommented:
there seems to exist free/open source libraries to work with DICOM. Have you had the chance to look at those:
http://opendicom.sourceforge.net/
http://sourceforge.net/projects/dicom-cs/
0
 
VeerabhadraiahhvAuthor Commented:
I got the answer and thanks for your  comments.
I'm using the following code to convert 16 bit images to 12 bit image.

             if (pixelVal > 4095)
                {
                    pixelVal = 4095;
                }
0
 
Jens FiedererCommented:
So you are just throwing away the high order 4 bits.

The other approach would be to discard the low order bits

pixelVal = pixelVal >> 4;

One way discards subtle differences, the other could result in some images where all the bits are 4095.
0
 
lenordisteCommented:
jensfiederer's approach seems more appropriate. Try with a large sample of images (especially those above 4095) and see which turns out best.
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

  • 3
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now