Any way to free hand crop an image?

14 ビュー (過去 30 日間)
Siddharth
Siddharth 2013 年 6 月 19 日
コメント済み: ali seraj 2020 年 8 月 11 日
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?

採用された回答

Sean de Wolski
Sean de Wolski 2013 年 6 月 19 日
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);
  8 件のコメント
Warid Islam
Warid Islam 2019 年 7 月 23 日
Hi,
I found tha MATLAB does not recommend getPosition method. They recommend to use ROI classes. I tried using the ROI.FREEHAND class but I get the following error:
Unrecognized method, property, or field 'roi' for class 'images.roi.Freehand'.
Error in fh4 (line 6)
pos = images.roi.Freehand(); % get position for that ROI
ali seraj
ali seraj 2020 年 8 月 11 日
thank you

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by