Why is matlab seeing images rotated?
8 views (last 30 days)
Show older comments
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?
0 Comments
Accepted Answer
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 ??).
See Also
Categories
Find more on Convert Image Type in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!