Bug with 'imread' - is there any way around this?

7 次查看(过去 30 天)
Issue: when you use windows to rotate an image, Matlab's 'imread' function does not acknowledge the image rotation and instead loads the image in its original (un-rotated) form. 'imfinfo' also reports the incorrect (unrotated) height/width.
Matlab version: 2017b
Windows version: Windows 10 (fully up to date, not using windows insider / fast track builds)
Images rotated using: Built-in Windows photo viewer/editor
Image types affected: .jpg images (and possibly others, I have only tried this with jpeg's so I dont know if other image types are affected too)
Other Miscellaneous Computer stats: i7-3610qm, 16gb ram, 850 EVO ssd, gtx-660m (I dont see why these would matter for this particular bug, but just in case)
I have verified that the images load correctly with multiple other programs (including other programs that were not developed by Microsoft) and Matlab is the only program that does not load the images correctly.
.
If there any good way around this? I dont know of any other image loading functions in Matlab other than imread (and whatever jpeg-specific loading function that imread calls to actually load the image). Is there an alternate image loading function I could use to load the image (or at the least extract the correct dimensions so I can determine if an image needs to be rotated automatically)?
The only ways I see to get around this are 1) load the data as binary with 'fread' and then learn enough about jpeg compression (and about how 90-degree rotations get coded into them) to pull out the correct dimensions, or 2) setup some sort of user-interactive loop through all the images you want to use and manually choose a rotation (or lack thereof) for each image. However, I would much rather just find a function that actually works correctly for loading jpegs.
Thanks.
.
PS Im not sure if there is an official bug reporting page for Matlab, but if there is let me know and I can add this bug to it if it hasnt already been reported (or, if Matlab staff sees this, feel free to add it for me).
  2 个评论
Bojan Matovski
Bojan Matovski 2018-7-9
I just witnessed the same issue with couple of images of mine. I didn't even figure it out that it's due to the rotation in windows, since it has been long time since I last edited those images. Would be happy if a solution is found.
Walter Roberson
Walter Roberson 2018-7-9
When rotations are implemented by just changing the Orientation field, then MATLAB will not recognize the rotation. MATLAB does not pay any attention to the headers, other than the headers that describe data type, number of channels, indexed or grayscale, and image size.

请先登录,再进行评论。

采纳的回答

Walter Roberson
Walter Roberson 2017-12-26
When you do the imfinfo() check to see if there is an Orientation field. If not check to see if there is a DigitalCamera field; if there is it will be a struct that contains the EXIF information, which might include an Orientation field. If the Orientation field is not present in either place the image should not be rotated.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Computer Vision with Simulink 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by