Friday, December 12, 2014

Analyze: Width Distribution using EDM

 Estimating the largest width as in the previous post [Link] is interesting but in most cases, we want a distribution of widths...

2. Distribution of widths

A new test image (Fig.1) ...

Fig.1: Test image
In a first approximation, the easiest method - because the object is horizontal - is to invert the image (Edit > Invert), select all the image with Ctrl + A, and compute a plot profile with Analyze > Plot Profile (or Ctrl + K) as shown in Fig. 2. The plot profile is calculated by adding all the horizontal profiles contained in the rectangular selection.

Fig. 2: Plot of Fig. 1. The values correspond to the vertical distances.

2.1. Method #1: Using EDM
Usually, the object is not parallel to the horizontal axis and we need a more general approach.
Download the test image in Fig. 1, open it in ImageJ, and duplicate it before computing the EDM (Fig.3)...

Fig. 3: Euclidean Distance Map of image of Fig.4

From the original image (Fig. 1), duplicate it again and compute the skeleton (or median axis) with Process > Binary > Skeletonize (Fig. 4)

Fig. 4: Skeleton of image of Fig.1
Now, we want to extract the pixel values of the EDM belonging to the medial axis. This can  be done by combining the skeleton and the EDM with a AND operator (Process > Image Calculator). The skeleton appears as a gray level median axis whose pixel values correspond to the half distance (Fig. 5).

Fig. 5: Result of the operation NOT(Skeleton) AND EDM

Finally, to get the half distances, you have to write a small script whose synopsis is:
loop y=0 to image_height
  loop x= to image_width
    if (pixel(x,y) !=0)
      append pixel(x,y) in array
print array

Hope that helps.

<<  Largest Width : PreviousNext: Using stripes >>

2. Other crazybiocomputing posts

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

No comments:

Post a Comment