MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

### Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

# How can i find the resolution of an image?

Asked by Carole on 16 Nov 2012

Hi, how i can find the resolution of an image with matlab (number of pixels in millimeter). thanks

## Products

No products are associated with this question.

Answer by Thomas on 16 Nov 2012
Edited by Thomas on 16 Nov 2012

Use 'imfinfo'

E.g.

` info = imfinfo('new1.jpg')`
```info =
```
```         Filename: [1x95 char]
FileModDate: '01-Oct-2001 17:19:44'
FileSize: 27387
Format: 'jpg'
FormatVersion: ''
Width: 600
Height: 650
BitDepth: 24
ColorType: 'truecolor'
FormatSignature: ''
NumberOfSamples: 3
CodingMethod: 'Huffman'
CodingProcess: 'Sequential'
Comment: {[1x69 char]}```

There you can fine the resolution widthxheight bit depth etc..

Eric on 16 Nov 2012

That would make the pixels 264.62 microns across and the height of the detector (650 such pixels) 6.8 inches. I don't know whose camera this is, but that is almost assuredly not right.

-Eric

Walter Roberson on 16 Nov 2012

Good point, Eric. Carole, is the image of a single spot or is it of a larger area that you moved along?

Carole, XResolution is an optional EXIF tag. In most cases it is not known or not meaningful.

Carole on 16 Nov 2012

Sorry for the stupid questions but I like to understand. So what's the solution to convert a diameter of a region in pixel to millimeter. is there a trick using a regle of three for example? or what is the parameter necessary to make this conversion?

Answer by Walter Roberson on 16 Nov 2012

Most often, you cannot figure out what the resolution of an image is.

If you are using a better-quality camera in auto-focus mode, the EXIF information might include the distance to the focus. If you have that and the lens aperture, then by knowing the height and width in pixels, you can calculate the angle subtended by the pixel range, and thus the angular resolution. (Perhaps you do not need the aperture; I have forgotten the details of the calculation.)

If you are using a medical device such as CT or MRI, then the images for those are usually created as DICOM images, for which there is DICOM meta-data that includes the resolution in the PixelWidth tag.

Carole on 16 Nov 2012

I do not know the resolution. I want to calculate the resolution from the image. Is this possible??

Eric on 16 Nov 2012

It looks to me like the device has no imaging capability (<http://www.delasco.com/pcat/1/Diagnostic/Delta20/Delta20/>). You need to pair it with another camera. I would say your best bet would be to do your own calibration of the systems. You could buy a resolution target (something like an Air Force 1951 resolution target from Edmund Optics) that has small features of known sizes. Image them and determine what the resolution is that way.

-Eric

Answer by Carole on 17 Nov 2012
Edited by Carole on 17 Nov 2012

I'm looking for the solution to convert a diameter of a region in pixel to millimeter. is there a trick using a regle of three for example? or what is the parameter necessary to make this conversion? I have these informations but I don't know how can I use it:

-the resolution of the device is 41.1 megapixel

-1 megapixel = 0.264 mm

-1 dpi = 3.937 pixels/mm

Walter Roberson on 17 Nov 2012

3.779527559 is exactly the figure for 96 pixels per inch. Which is a common screen resolution, but not a common camera resolution. The magnification is irrelevant: pixels divided by 96 equals inches.

The only time magnification would be important would be if the image you get is of a 10x magnification of the 96 pixels/inch. In that case, 96*10 image pixels would be 1 inch of original size. Alternately, it could be the case that the original surface is magnified 10x and then the 3.779 pixels/mm (96 dpi) is what the magnified image is recorded as, so getting an actual resolution of 37.79 pixels/mm.

Carole on 17 Nov 2012

I don't know the length of any object in the image. Can I use the length and height of the image. There is no other solution ??? I foud in other images (using the same device) that a width of an object is 10 pixels or approximately 0.22 mm. Can i use this parameter?

Walter Roberson on 18 Nov 2012

How about you tell us the make and model of what you are using, so we can see if we can understand the manual?

Answer by Image Analyst on 18 Nov 2012
Edited by Image Analyst on 18 Nov 2012

Carole, Sure, go for it. So multiply any lengths in pixels by 0.022 to get length in mm, and multiply and area in pixels by 0.022^2 to get area in mm^2. Of if you know the length and height of the total image field of view then you can use that too. For example, if the height = 960 pixels and it's 21 mm. Then the spatial calibration factor is 21/960 = 0.021875 mm per pixel. So let's say an object is 342 pixels long, well that's 342 * 0.021875 = 7.48125 mm long. If the area = 20,000 pixels, it's 20,000 * 0.021875^2 = 9.57 mm^2 in area.

Image Analyst on 20 Nov 2012

Carole, how did you say this earlier:

```I get this result
```
```Width: 750
Height: 498
BitDepth: 24
```

Evidently you have some kind of camera hooked up to this loupe and are able to take pictures somehow. Please take a picture of something with the reticule in place, and upload it, so we can measure the spatial calibration.

Walter Roberson on 20 Nov 2012

Especially a picture of something of known size, such as a ruler.

Image Analyst on 20 Nov 2012

The how did you get the pictures? Did you get them from that dermascope or not? If not, where did they come from and what does the dermascope have to do with anything?

And the print size has nothing at all to do with any kind of distance in your image. I could print a picture of a galaxy and a picture of a virus both on the same size paper printout with the same size image pixel dimensions. But of course their spatial calibration is vastly different.