how to manual crop an ultrasound image
Afficher commentaires plus anciens
I have an ultrasound iamge and I should a rectangual ROI manually like Ithis image:

but when I use imcrop it does not plot the image to choose an ROI. However, by giving the location of the rectangle it will work:
to make it more clear I mean using this line of the code:
e1=imcrop(I,[0 1100 368 3000]);
but I need to do this ROI selection in the same way as the above image.
I attached my image.
Réponse acceptée
Plus de réponses (1)
Mathias Smeets
le 2 Août 2022
I always use this code to draw a roi:
figure; imshow(image); axis equal
title('Crop image based on first image taken')
set(gcf, 'WindowState', 'maximized');
% set(gcf, 'Position', get(0, 'Screensize'));
roi = drawrectangle;
f = msgbox('Press on OK if finished cropping','Finished?');
uiwait(f)
Hope this helps :)
7 commentaires
2NOR_Kh
le 2 Août 2022
Mathias Smeets
le 3 Août 2022
cropped_image = imcrop(image, roi.Position)
maybe your problem is just inserting roi instead of roi.Position?
Mathias Smeets
le 3 Août 2022
If this doesn't work try
roi = roi.roi;
cropped_image = imcrop(image, roi.Position);
DGM
le 6 Août 2022
imcrop() supports interactive selection of a rectangular area without the need to use images.roi objects. Just call imcrop() using the short syntax:
[croppedimage roirect] = imcrop(myimage);
That will open a figure with the image displayed. You can mark out a rectangular area, adjust as needed. Right-click -> crop image. The output is the cropped image and the coordinates of the selected area. Said coordinates can be re-used if necessary.
The image is improperly-scaled for its class. It should be expected that it won't display correctly unless it's scaled appropriately. I can only guess what the scale is supposed to be.
[croppedimage roirect] = imcrop(mat2gray(e3)); % normalize to current extrema
or
[croppedimage roirect] = imcrop(uint8(e3)); % presume that the image is uint8() cast as double
Even if it's desired to keep the current class and scaling, you can use the above to get the rectangle coordinates and then apply that to the unaltered array.
[~,roirect] = imcrop(mat2gray(e3));
croppedimage = imcrop(e3,roirect);
Catégories
En savoir plus sur Image Processing Toolbox dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
