How to crop the ROI of a set of dicom images?
19 views (last 30 days)
Show older comments
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!
0 Comments
Accepted Answer
More Answers (1)
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().
0 Comments
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!