MATLABで画像表​示するときに画像が横​向きになってしまうの​を直したい

スマホで撮影した写真をMATLABで表示した際に,横向きになってしまい,スマホで撮影した写真のまま表示させたいと考えています.
 
何か良い方法があれば教えていただきたいです.
よろしくお願いします.

 Respuesta aceptada

Kojiro Saito
Kojiro Saito el 15 de Dic. de 2022

3 votos

スマホの画像にはEXIFのメタデータが含まれるので、Orientationの値を見て縦向き(6)だったらimrotateする方法でうまくいくと思います。
imageFile = 'IMG_xxx.jpg';
img = imread(imageFile);
% Get image meta information
info = imfinfo(imageFile);
% If an image is jpeg and contains exif
if isfield(info, 'Orientation')
if info.Orientation == 6
img = imrotate(img, -90);
end
end
imshow(img)

2 comentarios

大輝 隅岡
大輝 隅岡 el 19 de Dic. de 2022
回答ありがとうございます.
無事解決できました.ありがとうございました.
Kojiro Saito
Kojiro Saito el 19 de Dic. de 2022
解決して良かったです。

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Etiquetas

Preguntada:

el 15 de Dic. de 2022

Comentada:

el 19 de Dic. de 2022

Community Treasure Hunt

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

Start Hunting!