how to make sure image resolution?

Hi everyone, i have one problem about image resolution. I have took an image which has resolution 4000 pixels of width and 3000 pixels of height (the appearanced is landscape when viewed in photo viewer). Unfortunately, when I load in Matlab (using imread), the resolution is changing itself. Its become 3000 pixels of width and 4000 pixels of height, and when it show using imshow its become potrait. I appreciate if anyone could help me out figuring how it can be happened. Thanks and best wishes

 Respuesta aceptada

Rik
Rik el 23 de Mayo de 2019

1 voto

Some cameras store the orientation in the EXIF data, which Matlab generally ignores. In my PhotoAnnotation tool I used an external tool to extract this from the file, but depending on the release you're using you might be able to use native Matlab tools.

3 comentarios

dms
dms el 23 de Mayo de 2019
Hi Rik, thank you anyway for your valuable response. Could you give me any suggestion how to prevent those problem in advanced?
Rik
Rik el 23 de Mayo de 2019
Walter has posted this code in a previous question:
IM = imread('YourFile.jpg');
info = imfinfo('YourFile.jpg');
if isfield(info,'Orientation')
orient = info(1).Orientation;
switch orient
case 1:
%normal, leave the data alone
case 2:
IM = IM(:,end:-1:1,:); %right to left
case 3:
IM = IM(end:-1:1,end:-1:1,:); %180 degree rotation
case 4:
IM = IM(end:-1:1,:,:); %bottom to top
case 5:
IM = permute(IM, [2 1 3]); %counterclockwise and upside down
case 6:
IM = rot90(IM,3); %undo 90 degree by rotating 270
case 7:
IM = rot90(IM(end:-1:1,:,:)); %undo counterclockwise and left/right
case 8:
IM = rot90(IM); %undo 270 rotation by rotating 90
otherwise
warning(sprintf('unknown orientation %g ignored\n', orient));
end
end
dms
dms el 23 de Mayo de 2019
Thanks a lot for your help Rik. I'll try it first.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Display Image en Centro de ayuda y File Exchange.

Preguntada:

dms
el 23 de Mayo de 2019

Comentada:

dms
el 23 de Mayo de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by