How to crop the ROI of a set of dicom images?

19 views (last 30 days)
Hello, i am trying to run a for cycle to crop the ROI of several dicom images (in a fixed position). I've tried creating a mask and cropping which didn't work. Is it possible to run the same ROI through every image?
for i = 20:100
I=dicomread(filename); %contains names of all dicom images
I=im2double(I);
g=imshow(I,[0 600]);
my_vertices = [367 343;367 164;140 164;140 343];
h = drawpolygon('Position',my_vertices);
BW = imcrop(h,g);
%BW = createMask(h,g);
%BW=uint16(BW);
J=I*BW;
figure,imshow(J, []);
end
Thanks!

Accepted Answer

KSSV
KSSV on 9 May 2022
Read about imcrop, imcrop3. You can achieve it by providing the vertices of ROI.

More Answers (1)

Image Analyst
Image Analyst on 9 May 2022
You can use imcrop. Otherwise use drawrectangle to draw a box. If you use drawpolygon you'll have to get the bounding box first, then crop using indexing or imcrop().

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!