The problem about mirror image
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
Adam
2017-9-12
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.
采纳的回答
Image Analyst
2017-9-12
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 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!