The problem about mirror image
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Y
el 11 de Sept. de 2017
Comentada: Adam
el 12 de Sept. de 2017
Hello, everyone. I read a code about mirror image from my reference booka hour ago and debug it, though it runs well, but there is something troubles me a lot.
if true
I=imread('C:\Users\yanghang\Pictures\0.jpg');
subplot(1,2,1);
imshow(I);
I=double(I);
h=size(I);
I_fliplr(1:h(1),1:h(2),1:h(3))=I(1:h(1),h(2):-1:1,1:h(3));%水平镜像
I1=uint8(I_fliplr);
subplot(1,2,2);
imshow(I1);
end
Firstly, Why there exists the format change? 'I' is uint8 before, then double then uint8 again. I want to express mirror in another way, so replace the
if true
% I_fliplr(1:h(1),1:h(2),1:h(3))=I(1:h(1),h(2):-1:1,1:h(3));
imrotate(I,-180);
set(gca,'###','reverse')% whether the second part should be the image?
end
3 comentarios
Adam
el 12 de Sept. de 2017
The Matlab Help is by far the best source and most of the time the only one you need, but a google search will often lead you to Matlab Answers threads also.
Respuesta aceptada
Image Analyst
el 12 de Sept. de 2017
You don't need all that complicated stuff with indexes and casting to double and uint8. Sometime a few versions ago, they made fliplr() smart enough to handle color images. So simply do:
rgbImage = imread('C:\Users\yanghang\Pictures\0.jpg');
subplot(1,2,1);
imshow(rgbImage);
title('Original Image', 'FontSize', 30);
flippedImage = fliplr(rgbImage);
subplot(1,2,2);
imshow(flippedImage);
title('Mirror Image', 'FontSize', 30);
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0, 0.04, 1, 0.96]);
0 comentarios
Más respuestas (0)
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!