Solved

Convert 16 bit image to 12 bit image

Posted on 2011-03-22
8
848 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Fortunately, the DICOM standard is publicly available:

ftp://medical.nema.org/medical/dicom/2009/
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 11

Expert Comment

by:lenordiste
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

771 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

11 Experts available now in Live!

Get 1:1 Help Now