MATLABで画像表示するときに画像が横向きになってしまうのを直したい
8 ビュー (過去 30 日間)
古いコメントを表示
スマホで撮影した写真をMATLABで表示した際に,横向きになってしまい,スマホで撮影した写真のまま表示させたいと考えています.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1232047/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1232052/image.png)
何か良い方法があれば教えていただきたいです.
よろしくお願いします.
0 件のコメント
採用された回答
Kojiro Saito
2022 年 12 月 15 日
スマホの画像には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)
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で イメージ算術 についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!