Why is matlab seeing images rotated?

8 views (last 30 days)
Jan
Jan on 15 Dec 2022
Commented: Jan on 18 Dec 2022
Hi,
I'm trying to do some image analysis but I noticed matlab is seeing my images rotated by 90 degrees clockwise. Here is imfinfo:
ans =
struct with fields:
Filename: 'C:\Users\janko\OneDrive\MUNI\Bakalářka\fotky_k_analyze\DSC_7967.jpg'
FileModDate: '08-Dec-2022 16:52:46'
FileSize: 1479464
Format: 'jpg'
FormatVersion: ''
Width: 6000
Height: 4000
BitDepth: 24
ColorType: 'truecolor'
FormatSignature: ''
NumberOfSamples: 3
CodingMethod: 'Huffman'
CodingProcess: 'Sequential'
Comment: {}
Make: 'NIKON CORPORATION'
Model: 'NIKON D5300'
Orientation: 8
XResolution: 300
YResolution: 300
ResolutionUnit: 'Inch'
Software: 'Ver.1.03 '
DateTime: '2022:12:08 16:52:45'
YCbCrPositioning: 'Centered'
DigitalCamera: [1×1 struct]
GPSInfo: [1×1 struct]
ExifThumbnail: [1×1 struct]
in Windows explorer, it's seen as width = 4000 and Height = 6000. Why is there this difference and how can I force matlab to see them right?

Accepted Answer

Image Analyst
Image Analyst on 15 Dec 2022
Notice the Orientation field. It's 8, indicating the camera was rotated when the photo was snapped. Some programs read that field and automatically rotate the image for you before displaying it. Other programs, like MATLAB don't. You can use functions like imrotate, flipud, or fliplr to get the image in an orientation you want. Hopefully all your photos have the same orientation field, because I'm not sure off the top of my head to read the orientation flag (might be imfinfo ??).
  1 Comment
Jan
Jan on 18 Dec 2022
Thanks, I didn't know that. Yes, I have all of them rotated in same direction

Sign in to comment.

More Answers (1)

DGM
DGM on 15 Dec 2022
Edited: DGM on 15 Dec 2022
See this thread:
Attached is an updated version of the function used for reading the images. This should automatically rotate/flip the image as implied by the orientation tag.

Categories

Find more on Convert Image Type 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!