why X and Y coordinates must have the same size ?

조회 수: 13 (최근 30일)
Reema Alhassan
Reema Alhassan 2018년 6월 26일
댓글: Walter Roberson 2018년 6월 28일
hello,
I have an image and a shape and I need to clip the image based on the coordinates of the shape but when I do this I am having an error says: x and y must be the same size how can I make them equal? or any idea of solving this issue please ?
Thanks
  댓글 수: 5
Reema Alhassan
Reema Alhassan 2018년 6월 26일
편집: Reema Alhassan 2018년 6월 26일
yes,this is the error
Walter Roberson
Walter Roberson 2018년 6월 26일
What shows up for
size(x1)
size(y1)
size(x2)
size(y2)

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

채택된 답변

Walter Roberson
Walter Roberson 2018년 6월 26일
I suggest using poly2mask() to create mask (binary image) that you can then multiply by the original image to get the clipped image. You might always want find the bounding box of the mask and use that to crop the result.
Your x and y coordinates will need to be the same length for poly2mask.
That might involve deliberately repeating some coordinates. For example to express y ranging from 10 to 20 at x = 7, coming from (0,0), then you cannot just code x = [0 7], y = [0 10 20] -- each y must be matched with an x. You would instead code x = [0 7 7], y = [0 10 20]
  댓글 수: 11
Reema Alhassan
Reema Alhassan 2018년 6월 28일
my problem is that the geotiff image is very large so I need to clip it first based on the boundingBox of the shape to make it smaller and then apply the function inpolygon() but I couldn't find a way to clip it and make a new geotiff image if you know how to do this could you help me please?
Thanks
Walter Roberson
Walter Roberson 2018년 6월 28일
"Expecting input number 1, X, to be finite"
is an error you are getting because you are feeding in a polygon that has NaN inside it, to mark the end of a segment such as to move over to draw a lake or island. You need to break up your inputs to poly2mask, creating several masks and or'ing them together.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Read, Write, and Modify Image에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by