Ask Your Question
0

Convert DCMTK DicomImage into Mat OpenCV

asked 2016-07-22 11:28:40 -0600

I have some project that require me to get the most accurate data so that I can perform simple image thresholding to segments the bone area only. The DICOM library I use is DCMTK, and here is the way I did it:

Mat image = Mat(int(mono->getHeight()), int(mono->getWidth()), CV_16UC1, (Uint16 )(mono->getOutputData(16/ bits per sample */)));

Strangly, if the depth is 13, the image I get is pretty good, but when the image depth is 17, the image contrast is getting low.

here is the image of the 13bits depth I get image description

and here is the image of 17bits image description

how can I get the same result as the 13bits image from the 17bits image? In my current method, after the matrix has been saved, I turn the pixel value range into range 0-1 first, and then I normalize it by maximinzing the pixel range (sometimes the pixel value is 0.4=0.6 so I maximize it using linear interpolation to range 0-1). Sometimes this method is working, but since I use a static threshold value to recognize the bone, in many cases, this method failed to give the proper bone value.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-07-22 14:28:19 -0600

Tetragramm gravatar image

You say it's a 17 bit image. Since that can't be stored in 16 bits, how is it being stored? You may need to change your data type from CV_16U to CV_32S. 16U is a 16 bit, unsigned pixel. 32S is a 32 bit, signed pixel. I expect that's the most likely data type to store 17 bit data in. The signed/unsigned difference shouldn't matter, if it's 17 bits then it won't affect the sign bit, so it will be fine.

For your conversion you are, I assume, converting to float or double. You can then use the function normalize(fltImage, normImage, 1, 0, NORM_MINMAX) to do what you described in one step.

Let's get your images good before we worry about the threshold. That's probably best for another question if you try everything you can think of and can't get it to work.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-07-22 11:28:40 -0600

Seen: 1,629 times

Last updated: Jul 22 '16