Solved

Convert 16 bit image to 12 bit image

Posted on 2011-03-22
8
859 Views
Last Modified: 2012-08-14
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
Comment
Question by:Veerabhadraiahhv
  • 3
  • 3
  • 2
8 Comments
 
LVL 23

Expert Comment

by:Jens Fiederer
ID: 35189710
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
 
LVL 11

Expert Comment

by:lenordiste
ID: 35193452
jensfiederer is right, you need to know what those bits are used for. How is your image encoded (or not...) ? BMP, JPG, PNG ... ?
0
 
LVL 4

Author Comment

by:Veerabhadraiahhv
ID: 35196810
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
 
LVL 23

Expert Comment

by:Jens Fiederer
ID: 35197692
Fortunately, the DICOM standard is publicly available:

ftp://medical.nema.org/medical/dicom/2009/
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 11

Expert Comment

by:lenordiste
ID: 35202007
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
 
LVL 4

Author Comment

by:Veerabhadraiahhv
ID: 35277525
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
 
LVL 23

Accepted Solution

by:
Jens Fiederer earned 500 total points
ID: 35279161
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
 
LVL 11

Expert Comment

by:lenordiste
ID: 35285278
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now