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 CenterFile Exchange에서 图像에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!