The problem about mirror image
Afficher commentaires plus anciens
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 commentaires
set(gca,'###','reverse')
needs 'XDir' or 'YDir' (or 'ZDir', but not for an image) as the second argument if you want to flip the axis.
To flip the image itself you would do what the code does (well, I haven't checked if it is correct, but applying the flip to the data itself rather than the graphics).
I never like to spend too long looking at code that people post from some unknown source asking why it does what it does though because there is no guarantee that random code is in any way sensible so trying to explain its logic is sometimes just a pointless task! If you are following an example from Matlab help or some other obviously reputable source it is useful to include that to at least give us an idea the code is not just bad code from someone who doesn't know what they are doing.
Y
le 11 Sep 2017
Adam
le 12 Sep 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.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur 图像 dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!