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

2 views (last 30 days)
大輝 隅岡
大輝 隅岡 on 15 Dec 2022
Commented: Kojiro Saito on 19 Dec 2022
スマホで撮影した写真をMATLABで表示した際に,横向きになってしまい,スマホで撮影した写真のまま表示させたいと考えています.
 
何か良い方法があれば教えていただきたいです.
よろしくお願いします.

Accepted Answer

Kojiro Saito
Kojiro Saito on 15 Dec 2022
スマホの画像には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 Comments
Kojiro Saito
Kojiro Saito on 19 Dec 2022
解決して良かったです。

Sign in to comment.

More Answers (0)

Categories

Find more on MATLAB 入門 in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!