COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### Measuring object width in an image, thanks

• Email
• Follow

```Dear all,

I have a problem expecting good ideas. As you can see from the image (http://farm9.staticflickr.com/8298/7745154244_9b28e31afa_c.jpg), I want to measure the diameter of the cylinder in the image. My idea is to measure the distance between the two ending points of the red curve in the white rectangle. Please note that there was no the while rectangle in an original image. So, how can I measure the distance between the two ending points from the image?

Any ideas are highly appreciated, thank you very much.
```
 0
Reply Digistar 8/9/2012 8:10:14 AM

See related articles to this posting

```How about using improfile to let the user pick it interactively?
```
 0
Reply imageanalyst (7622) 8/9/2012 11:32:14 AM

```Thanks a lot, but that is not possible. The project needs the algorithm to run automatically.

"Image Analyst" wrote in message <k0073u\$b22\$1@newscl01ah.mathworks.com>...
> How about using improfile to let the user pick it interactively?
```
 0
Reply Digistar 8/9/2012 12:59:13 PM

```Can somebody help me? Thanks a lot.

"Digistar You" <digistar2003@163.com> wrote in message <jvvr96\$7j0\$1@newscl01ah.mathworks.com>...
> Dear all,
>
> I have a problem expecting good ideas. As you can see from the image (http://farm9.staticflickr.com/8298/7745154244_9b28e31afa_c.jpg), I want to measure the diameter of the cylinder in the image. My idea is to measure the distance between the two ending points of the red curve in the white rectangle. Please note that there was no the while rectangle in an original image. So, how can I measure the distance between the two ending points from the image?
>
> Any ideas are highly appreciated, thank you very much.
```
 0
Reply Digistar 8/10/2012 6:40:23 AM

```Ask for help again, :)
"Digistar You" <digistar2003@163.com> wrote in message <jvvr96\$7j0\$1@newscl01ah.mathworks.com>...
> Dear all,
>
> I have a problem expecting good ideas. As you can see from the image (http://farm9.staticflickr.com/8298/7745154244_9b28e31afa_c.jpg), I want to measure the diameter of the cylinder in the image. My idea is to measure the distance between the two ending points of the red curve in the white rectangle. Please note that there was no the while rectangle in an original image. So, how can I measure the distance between the two ending points from the image?
>
> Any ideas are highly appreciated, thank you very much.
```
 0
Reply Digistar 8/10/2012 2:34:16 PM

```Why not just mask out stuff known not to be part of the cylinder, then sum vertically to get the average profile, then threshold to find where the edge of the cylinder starts and stops.  Should be very easy.  Can you upload the original image (without the white box)?
```
 0
Reply imageanalyst (7622) 8/11/2012 12:47:07 AM

```I think the problem lies in that non-cylinder is not easily detected. I have uploaded an original image (http://farm9.staticflickr.com/8431/7771948574_6eca7b0741_k.jpg). Do you have any ideas how to measure the diameter of the cylinder? Thank you so much.

"Image Analyst" wrote in message <k04a2b\$cij\$1@newscl01ah.mathworks.com>...
> Why not just mask out stuff known not to be part of the cylinder, then sum vertically to get the average profile, then threshold to find where the edge of the cylinder starts and stops.  Should be very easy.  Can you upload the original image (without the white box)?
```
 0
Reply Digistar 8/13/2012 7:38:06 AM

```"Digistar You" <digistar2003@163.com> wrote in message <k0aasu\$br2\$1@newscl01ah.mathworks.com>...
> I think the problem lies in that non-cylinder is not easily detected. I have uploaded an original image (http://farm9.staticflickr.com/8431/7771948574_6eca7b0741_k.jpg).
==============

The non-cylinder feature seems to always consist of a bright narrow band perpendicular to the cylinder. You could use RADON to detect and then exclude it. There should be a spike in the radon projection view whose rays are parallel to the band.

Once you've found the band, you also have info about the tilt of the cylinder (if it is indeed always perpendicular to the band) and can get a more exact version of the average profile that ImageAnalyst was talking about. The average profile will be in the projection view 90 degrees from the one where the band spikes.
```
 0
Reply mattjacREMOVE (3193) 8/13/2012 9:44:06 AM

```Thanks Matt for the ideas. However, in my project, the problem is that the ends of the narrow red bands do not already match the edges of the cylinder. For example, I have uploaded another image (http://farm9.staticflickr.com/8296/7772735060_57e3bffcc3_k.jpg). Thus, it seems I have to detect the red narrow band in the middle first, and then try to measure its diameter. This seems to be not very easy. Do you have any suggestions? Thanks a lot.

"Matt J" wrote in message <k0ai96\$354\$1@newscl01ah.mathworks.com>...
> "Digistar You" <digistar2003@163.com> wrote in message <k0aasu\$br2\$1@newscl01ah.mathworks.com>...
> > I think the problem lies in that non-cylinder is not easily detected. I have uploaded an original image (http://farm9.staticflickr.com/8431/7771948574_6eca7b0741_k.jpg).
> ==============
>
> The non-cylinder feature seems to always consist of a bright narrow band perpendicular to the cylinder. You could use RADON to detect and then exclude it. There should be a spike in the radon projection view whose rays are parallel to the band.
>
> Once you've found the band, you also have info about the tilt of the cylinder (if it is indeed always perpendicular to the band) and can get a more exact version of the average profile that ImageAnalyst was talking about. The average profile will be in the projection view 90 degrees from the one where the band spikes.
```
 0
Reply Digistar 8/13/2012 10:47:06 AM

```"Digistar You" <digistar2003@163.com> wrote in message <k0alva\$dch\$1@newscl01ah.mathworks.com>...
> Thanks Matt for the ideas. However, in my project, the problem is that the ends of the narrow red bands do not already match the edges of the cylinder. For example, I have uploaded another image (http://farm9.staticflickr.com/8296/7772735060_57e3bffcc3_k.jpg). Thus, it seems I have to detect the red narrow band in the middle first, and then try to measure its diameter. This seems to be not very easy. Do you have any suggestions? Thanks a lot.
================

That doesn't seem relevant. Even in this new image, it looks like the radon projections of the bands will still spike strongly along rays perpendicular to the cylinder. You should be able to find the long background band easily and maybe even the smaller band defining the diameter of the cylinder (it always seems to to be the 2nd most intense band).
```
 0
Reply mattjacREMOVE (3193) 8/13/2012 1:47:09 PM

```I agree with Matt.  Actually this image looks even easier than your first o=
ne because there is far less clutter.  It looks like a laser beam coming up=
at an angle and hitting a rod/shaft/cylinder so you should be able to narr=
ow down the position somewhat, due to a known range of diameters, and just =
crop out that portion, making the alignment and profiling even easier.
```
 0
Reply imageanalyst (7622) 8/13/2012 11:32:10 PM

```Hi Matt, thank you so much for your time. I couldn't completely understand your suggestions, I guess the reason is that I didn't fully understand the meaning of Radon transform. I have read many explanations about the Radon transform, and now I think I should know what it does. I have used Matlab radon function to perform the Radon transform on the second image, and then got the result (http://farm9.staticflickr.com/8425/7779863888_1e30c421dc.jpg). According to the result (peak point at theta=89 degrees), I know the tilt of the red bands, based on which I may calculate the average profile later based on ImageAnalyst's suggestion.

However, currently I still do not understand how to detect the background features (e.g. the long background band) using Radon. If you have time, could you please explain it or provide some codes / pseudo codes? Thank you so much, and I really appreciate your and ImageAnalyst's help.

"Matt J" wrote in message <k0b0gt\$hlm\$1@newscl01ah.mathworks.com>...
> "Digistar You" <digistar2003@163.com> wrote in message <k0alva\$dch\$1@newscl01ah.mathworks.com>...
> > Thanks Matt for the ideas. However, in my project, the problem is that the ends of the narrow red bands do not already match the edges of the cylinder. For example, I have uploaded another image (http://farm9.staticflickr.com/8296/7772735060_57e3bffcc3_k.jpg). Thus, it seems I have to detect the red narrow band in the middle first, and then try to measure its diameter. This seems to be not very easy. Do you have any suggestions? Thanks a lot.
> ================
>
> That doesn't seem relevant. Even in this new image, it looks like the radon projections of the bands will still spike strongly along rays perpendicular to the cylinder. You should be able to find the long background band easily and maybe even the smaller band defining the diameter of the cylinder (it always seems to to be the 2nd most intense band).
```
 0
Reply Digistar 8/14/2012 8:24:07 AM

```"Digistar You" <digistar2003@163.com> wrote in message <k0d1v7\$inc\$1@newscl01ah.mathworks.com>...
>
> According to the result (peak point at theta=89 degrees), I know the tilt of the red bands, based on which I may calculate the average profile later based on ImageAnalyst's suggestion.
==============

RADON tells you more than this. The horizontal coordinate of the bright peak tells you that the band is tilted by 89 degrees. The vertical coordinate tells you the perpendicular distance (in pixels) of the band from the center of the image. Based on the figure you posted, it looks like the band is something like 150 pixels from the center?

Another thing you could do is use IMROTATE to correct for the 89 degree tilt and make the cylinder perfectly vertical. Then if you do

[~,rownum]=max(sum(image>0,2));

the resulting rownum should be the row number where the bright band approximately lies.
```
 0
Reply mattjacREMOVE (3193) 8/14/2012 3:38:06 PM

```Dear Matt, thank you so much for your time and detailed explanations. Now I completely understand your suggestions. I have also tested the algorithm on a few simple images, which works well. I will see if it works with more complex images. Thank you very much.

Also many thanks to ImageAnalyst!

"Matt J" wrote in message <k0drcu\$pg5\$1@newscl01ah.mathworks.com>...
> "Digistar You" <digistar2003@163.com> wrote in message <k0d1v7\$inc\$1@newscl01ah.mathworks.com>...
> >
> > According to the result (peak point at theta=89 degrees), I know the tilt of the red bands, based on which I may calculate the average profile later based on ImageAnalyst's suggestion.
> ==============
>
> RADON tells you more than this. The horizontal coordinate of the bright peak tells you that the band is tilted by 89 degrees. The vertical coordinate tells you the perpendicular distance (in pixels) of the band from the center of the image. Based on the figure you posted, it looks like the band is something like 150 pixels from the center?
>
> Another thing you could do is use IMROTATE to correct for the 89 degree tilt and make the cylinder perfectly vertical. Then if you do
>
> [~,rownum]=max(sum(image>0,2));
>
> the resulting rownum should be the row number where the bright band approximately lies.
```
 0
Reply Digistar 8/15/2012 3:31:14 PM

13 Replies
38 Views

Similar Articles

12/9/2013 8:52:40 PM
[PageSpeed]