В приведенном ниже сценарии я создаю маску на основе координат и строю их в исходном положении, а также начиная с позиции 0,0.Как построить другой центр маски (mask1venter) по центру?
Код:
xCoord = [354 500 100 363];
yCoord = [309 500 600 360];
if max(xCoord)>max(yCoord)
matrixLength = max(xCoord);
else
matrixLength = max(yCoord);
end
xCoordMin = xCoord-min(xCoord);
yCoordMin = yCoord-min(yCoord);
xCoordCenter = xCoord-round((max(xCoord))/2);
yCoordCenter = yCoord-round((max(yCoord))/2);
mask1 = poly2mask(yCoord,xCoord,matrixLength,matrixLength);
mask1Min = poly2mask(yCoordMin,xCoordMin,matrixLength,matrixLength);
mask1Center = poly2mask(yCoordCenter,xCoordCenter,matrixLength,matrixLength);
imshowpair(mask1,mask1Min)