Recently, when processing CT images, CT images scan the human body layer by layer, and there are many unnecessary parts in the image, such as the ribs, as a result, there are many unnecessary parts of the 3D reconstruction image. Very difficult to handle.
As a result, I thought of a simple method to set unnecessary pixels to black for a dicom image. Originally intended to be implemented with VC ++ 6.0 + VTK, debugging is too troublesome, it is easy to directly use matlab for processing.
1. Read/write Dicom format images
I = dicomread ('e: \ CT \ 37222. dcm '); % read image metadata = dicominfo ('e: \ CT \ 37222. dcm '); % storage Information imagesc (I); % display image dicomwrite (I, 'e: \ CT \ 37222. dcm ', metadata); % write Dicom Image
2. Select the required rectangular area on the Dicom Image
This code implementation is very simple, and it also takes some twists and turns to find this method.
[Xv, yv] = ginput (2); %. In this way, you can select two points on the image, save the X coordinates to xv, and save the y coordinates to yv.
If many dots form a rectangular area, you can use in = inpolygon (x, y, xv, yv); to judge, x, whether the y coordinate is in the area surrounded by selected points.