Steve on Image Processing
June 29th, 2007
imfinfo, imread can automatically detect the image format
Didja know? Functions imfinfo and imread do not depend exclusively on the filename extension (for example, .jpg, .png, .tif, etc.) to determine the image file format. I thought about this because a user sent us an image file yesterday with no extension. The user didn't mention what type of file it was, so I just handed the file to imfinfo:
>> imfinfo SEMparticles
ans =
Filename: 'SEMparticles'
FileModDate: '29-Jun-2007 09:12:35'
FileSize: 277598
Format: 'png'
FormatVersion: []
Width: 603
Height: 390
BitDepth: 24
ColorType: 'truecolor'
FormatSignature: [137 80 78 71 13 10 26 10]
...
The automatic format detection works by opening the file, reading the first few bytes, and looking for distinguishing byte patterns. (See the FormatSignature field in the output shown above.)
If the filename does have a recognized image format extension, then imfinfo and imread check the file against that format first.
If you're bored and looking for something amusing to do for the next two minutes, save a JPEG file with a .tif extension and see if you can get MATLAB to read it.
8:49 am |
Posted in Uncategorized |
Permalink |
You can follow any responses to this entry through the RSS 2.0 feed.
You can skip to the end and leave a response. Pinging is currently not allowed.
Leave a Reply
|
hi steve,
I tried changing the extension of a jpeg to tiff. MATLAB did read that as jpeg. however,i was wondering what could be the reason for the “Format signature” to not show anything. All i get is “”.
thanks
Srikanth—That’s normal with JPEG files.
Hi Steve,
Is there any method to read/access individual file information like the image width or height using ‘imfinfo’ or any other matlab functions. In the sense, I am able to view it in the browser - the file information but I need to load the image width and height into another variable.
Any method to do this …. ?
Thank you,
Regards,
Kaushik
Kaushik—Why can’t you just use imfinfo?
Hi Steve;
i want to convert 417×315(height x width) binary image in to 512×512(height x width) and then compress to (256×256), is there any matlab functions to pad and compress the binary images?
Damodar—imresize, padarray, or ordinary matrix indexing, depending on exactly what effects you are trying to achieve.
Thanks Steve,
I played around with ‘imfinfo’ and found the solution.
rgds,
Kaushik