how can I rotate the image ?
4 次查看(过去 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.
0 个评论
采纳的回答
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';
0 个评论
更多回答(1 个)
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 个评论
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 Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!