필터 지우기
필터 지우기

how to use crop using coordinate?

조회 수: 2 (최근 30일)
reza hamzeh
reza hamzeh 2020년 1월 24일
편집: Walter Roberson 2020년 1월 24일
hi. i want to crop the red square from this pic using coordinate. lets suppose coordinate of the top-left point of the red square is w/2 and h/2
where w and h are width and hight of the pic respectively. and width and hight of the red square are 20 pixel. this is my code but it dosent work. plz help me.
pic=imread('b.jpg');
[w, h, numberOfColorChannels] = size(pic);
I=imcrop(pic,[w*0.5 h*0.5 20 20]);
imshow(I)
black.jpg
  댓글 수: 2
Spencer Chen
Spencer Chen 2020년 1월 24일
Would be great if you describe what did not work.
Rik
Rik 2020년 1월 24일
Also, it is probably a good idea to round your coordinates to integers.

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

채택된 답변

Walter Roberson
Walter Roberson 2020년 1월 24일
편집: Walter Roberson 2020년 1월 24일
You need
[h, w, numberOfColorChannels] = size(pic);
not
[w, h, numberOfColorChannels] = size(pic);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by