Any way to free hand crop an image?

Illustration
Siddharth - 2022-02-21T11:08:44+00:00
Question: Any way to free hand crop an image?

Is there any way to free hand crop on an image? I have an organic shape I want to quickly crop not using the rectangular box that matlab has for cropping. Any way to go about this?  

Expert Answer

Profile picture of Neeta Dsouza Neeta Dsouza answered . 2025-11-20

How do you propose cropping a non-rectangular shape? Do you want to zero out parts that aren't within in your "cropped" region. An image always has to be rectangular.

 

doc imcrop
doc impoly
doc imfreehand

If you want to zero out the parts not in the free hand reason. use the createMask method of the freehand region to build a mask of the free hand region. Then negate it and zero everything in it out.

I = imread('cameraman.tif');
imshow(I);
h = imfreehand; %draw something 
M = ~h.createMask();
I(M) = 0;
imshow(I);

 


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!