The problem about mirror image

5 ビュー (過去 30 日間)
Y
Y 2017 年 9 月 11 日
コメント済み: Adam 2017 年 9 月 12 日
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 件のコメント
Y
Y 2017 年 9 月 11 日
Thanks a lot. Could U recommend some reliable sources ? I only know Matlab help. Thanks again.
Adam
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
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 件)

カテゴリ

Help Center および File Exchange图像 についてさらに検索

Community Treasure Hunt

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

Start Hunting!