how can I rotate the image ?

4 ビュー (過去 30 日間)
jiji hr
jiji hr 2016 年 5 月 26 日
回答済み: Image Analyst 2016 年 5 月 30 日
Hello,
I have this function :
function spin = generate_spin_image(vertex, normal, indVertex, med)
%[vertex, faces] = read_off(namefile);
%med = computeMedianEdge(namefile);
%[normal,normalf] = compute_normal(vertex, faces);
binSize = med;
W = 25;
angleSupport = pi/2;
imageWidth = W*binSize;
p = vertex(indVertex,:);
numVertices = size(vertex,1);
%alpha = zeros(numVertices,1);
%beta = zeros(numVertices,1);
spin = zeros(W,W);
TabAlpha_1 = zeros(1,34817);
TabBeta_1 = zeros(1,34817);
for i=1:numVertices
x = vertex(i,:);
if acos(sum(normal(indVertex,:).*normal(i,:))) < angleSupport
alpha = sqrt(sum((x - p).^2) - (sum(normal(indVertex,:).*(x-p))).^2);
beta = sum(normal(indVertex,:).*(x-p));
TabAlpha_1(i) = alpha;
TabBeta_1(i) = beta;
is = floor((imageWidth/2 - beta)/binSize);
js = floor(alpha/binSize);
a = alpha/binSize - js;
b = (imageWidth/2-beta)/binSize - is;
if is >=1 && is <=(W-1) && js >=1 && js <=(W-1)
spin(is,js) = spin(is,js) + (1-a)*(1-b);
spin(is+1,js) = spin(is+1,js) + a*(1-b);
spin(is, js+1)= spin(is,js+1) + (1-a)*b;
spin(is+1,js+1) = spin(is+1,js+1) + a*b;
end
end
end
figure;
TabBeta_1 = TabBeta_1';
TabAlpha_1 = TabAlpha_1';
plot(TabBeta_1, TabAlpha_1, 'ro');
figure;
imagesc(spin');
colormap( flipud(gray) );
In the end I plot the array that contains the projection of the 3D coordinates of a vertex in 2D coordiantes (alpha, beta), and the image spin results from the computation of alpha and beta.
The problem I have is that it gives me this:
It seems to be good but the image (grayscale) is rotated compared to the projection (plot with red points), and I want it to be the same as the plot.
I hop I explained my problem clairly. I would be grateful for any help.

採用された回答

Image Analyst
Image Analyst 2016 年 5 月 30 日
The top (line 1) of an image is at the top while for a plot it's normally at the bottom. Set the 'ydir' property of the plot to be 'reverse' and they'll both go in the same direction.
plot(......
ax = gca;
ax.YDir = 'reverse';

その他の回答 (1 件)

Nut
Nut 2016 年 5 月 26 日
Hi,
I'm not sure but I think that the "view" function could help you:
Alternatively, if you need just a different view, maybe you can solve changing the signs of the coordinates of red points when you plot them.
  2 件のコメント
jiji hr
jiji hr 2016 年 5 月 27 日
It didn't works becaus if I understood very well, it is for 3D plots, and I have juste a 2D plot.
Any way I found the solution using
imrotate(spinImages.spinIm,180);
And thank you so much for your answer.
Nut
Nut 2016 年 5 月 30 日
Ok, good idea. I thought you need to rotate the red points, not the image. I was misunderstanding, sorry.
Kind regards.

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

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by