How to do the grid sampling in the rotated square area of an image

1 回表示 (過去 30 日間)
HONG CHENG
HONG CHENG 2018 年 11 月 1 日
コメント済み: HONG CHENG 2018 年 11 月 4 日
As the following image shows, I want to do grid sampling in the rotated square area of an image.
I need to get a matrix with a certain size and the values of this matrix are the grid pixel value of the image.
Is there an algorithm can do this? or is there a function in Matlab? I found some functions in the Matlab Answer, but all of them are not for the rotated square area as the second image shown.

採用された回答

KSSV
KSSV 2018 年 11 月 1 日
YOu can rotate the image in the way you want.
M = 50; N = 50 ;
x = linspace(0,1,M) ;
y = linspace(0,1,N) ;
[X,Y] = meshgrid(x,y) ;
th = 45 ;
R = [cos(th) -sin(th) ; sin(th) cos(th)] ;
coor = [(X(:)-mean(X(:))) (Y(:)-mean(Y(:)))]*R ;
Xi = mean(X(:))+reshape(coor(:,1),M,N) ;
Yi = mean(Y(:))+reshape(coor(:,2),M,N) ;
figure
hold on
plot(X,Y,'.r')
plot(Xi,Yi,'.b')
  1 件のコメント
HONG CHENG
HONG CHENG 2018 年 11 月 4 日
Thanks for your kind answer.
However, I want to get the coordinates of the rotated grid points. In your case, I can draw the same square area on the top of origin image.
But I am trying to get the grid coordinates of a smaller area. With the meshgrid coordinate system, I don't know how to determine the position of the smaller area.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGeometric Transformation and Image Registration についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by