imcrop can not work for a .fig file

조회 수: 3 (최근 30일)
Winston
Winston 2020년 3월 24일
댓글: Walter Roberson 2020년 5월 24일
When I use this function,
I = openfig('filename.fig');
J = imcrop(I,rect)
output:
Error using imcrop>checkCData (line 412)
Invalid input image.
Error in imcrop>parseInputs (line 256)
checkCData(a);
Error in imcrop (line 93)
[x,y,a,cm,spatial_rect,h_image,placement_cancelled] = parseInputs(varargin{:});
But when use another (below), it works.
[J,rect2] = imcrop(___)
Can another people help? thanks.
  댓글 수: 4
Walter Roberson
Walter Roberson 2020년 3월 24일
I notice that you have a matlab.ui.Figure, also known as a uifigure, which is produced by App Designer. I did not know that you could get a .fig from App Designer. Using CurrentAxes and so on is for old style figures. I do not have any uifigure around to test with.
Adam
Adam 2020년 3월 25일
Sorry, corrected that now. I thought the property was 'Axes' first, then double-checked, found it was 'CurrentAxes' and didn't realise I hadn't removed the first attempt!

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2020년 3월 24일
편집: Walter Roberson 2020년 3월 24일
https://www.mathworks.com/help/images/ref/imhandles.html can be used to locate the images in fig. Note that more than one could potentially be returned in general.
  댓글 수: 10
Winston
Winston 2020년 5월 24일
They are
ans =
7618074
ans =
9306097
ans =
'double'
ans =
51 51
J{K} = imcrop(I(K).CData, [44, 166, 50, 50]); is used, no idea about why the cropped gives 51*51
Walter Roberson
Walter Roberson 2020년 5월 24일
imshow(J{1} ,[])
imcrop includes the border, except when it does not include the border. I filed a bug report on it years ago.
I recommend using matrix indexing instead of imcrop when you already know where you want to crop.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

태그

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by