Steve on Image Processing with MATLAB

Image processing concepts, algorithms, and MATLAB

Note

Steve on Image Processing with MATLAB has been archived and will not be updated.

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.

|
  • print

댓글

댓글을 남기려면 링크 를 클릭하여 MathWorks 계정에 로그인하거나 계정을 새로 만드십시오.