Friday, December 12, 2014

Analyze: Calculating the width of an object



After the length [Link], the other important parameter to measure is the width of the object of interest. This can be deduced from the euclidean distance map (EDM). Here are some examples...

1. Largest width

Let's start with this binary image (Fig.1) . If you have a gray-level image, it is mandatory to enhance your image and to threshold it to get a binary image.

Fig.1: 256x256 8-bit test image created with the brush tool of 16 pixels diameter.

Note: In this case, we assume the object of interest has a constant width.

First, duplicate the test image (Image > Duplicate... or Ctrl+Shift+D) and compute the Euclidean Distance Map (EDM) with Process > Binary > Distance Map  and you'll get a gray-level image where each pixel value corresponds to the shortest distance from the edges of the object of interest.

Note: Because, the EDM operation belongs to mathematical morphology, the convention is: black corresponds to True and white to False pixels. Thus, the object of interest must be in black surrounded by a white background.

Fig.2: Euclidean Distance Map of the image of Fig.1

Now, compute the histogram in Analyze > Histogram (or use Ctrl + H). Then, look at the maximum values. Here, we have 9 (table of Fig.3) but there is only 142 pixels and this could be due to artifacts of computation whereas 1338 pixels have a value of 8. This value corresponds to the largest distance from the boundaries of the object and is equal to the half width of the object. Thus, multiply this value by 2 to get the largest width of your object, here 8 x 2 = 16 pixels.

Fig.3: Histogram and corresponding values of the EDM (Fig. 2).

Thank you for reading this post.




2. Other crazybiocomputing posts

Further readings are available in ...
  • Analysis Series  [Link]
  • Image Processing TOC [Link]

No comments:

Post a Comment