Any way to free hand crop an image?

S
Siddharth · Feb 21, 2022 · 2K views
Question
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 PhD Expert
Answered Aug 24, 2026

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);

 

100% Run Guarantee 3-Hour Fast-Track Delivery

Need a Custom Version or Complete Simulation for This Problem?

Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.

Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!