Detecting object on image

J

Jole

Hi!

For example I have something like this http://yfrog.com/73objectj
White background and rectangle object on it and it is black.

The question is how to detect this rectangle object on image and
get his dimensios?

Any link or idea how to start!?

Thanks.
 
J

Jeff Johnson

Jole said:
For example I have something like this http://yfrog.com/73objectj
White background and rectangle object on it and it is black.

The question is how to detect this rectangle object on image and
get his dimensios?

Any link or idea how to start!?

There's a site dedicated to robot AI that I ran across once and I remember
one of the code modules dealt with pattern recognition (because the robots
had cameras and needed to "see"). Ah, yes, http://www.aforgenet.com/
 
S

Stuart Golodetz

Hi!

For example I have something like this http://yfrog.com/73objectj
White background and rectangle object on it and it is black.

The question is how to detect this rectangle object on image and
get his dimensios?

Any link or idea how to start!?

Thanks.

This is a segmentation problem -- plenty of approaches will work. The
simplest is what I've called Method 1 (below), but if your real images
are more complicated than the one you've shown, you might want to look
into more sophisticated methods. A few suitable search terms are:

- Thresholding segmentation
- Region growing
- Watershed segmentation
- Snakes segmentation
- Level sets segmentation
- K-means clustering
- Normalized cuts
- etc.

Hope that helps a bit,
Stu

p.s. Method 2 is *not* a sensible approach. FWIW.

###
Method 1 -- the appropriate way for a simple image like this
###

Walk the image in scanline order from the top-left until you find a
black pixel -- this is the top-left of the rectangle. Do the same in
reverse scanline order from the bottom-right -- this is the bottom-right
of the rectangle. From that point on, it's easy to calculate anything
else you want (like the dimensions).

###
Method 2 -- an extremely silly way for fun :)
###

- Construct a set S containing every pixel in the image.
- Until you find a black pixel or S is empty:
- Pick a random pixel from S.
- Remove it from S.

Assuming there was at least one black pixel in the image, you now have a
seed! (Otherwise, fail.)

- Run a region growing algorithm, starting from your seed. The grow
condition should just say "the adjacent pixel must be black".

- Fit an axis-aligned bounding box to the region you just grew (easy --
just iterate over all the pixels in the region and calculate the
{min|max} {x|y})
 
J

James A. Fortune

Hi!

For example I have something like thishttp://yfrog.com/73objectj
White background and rectangle object on it and it is black.

The question is how to detect this rectangle object on image and
get his dimensios?

Any link or idea how to start!?

Thanks.

Based on a comment in one of Rod Stephens' books, try something like:

Shift the image by a pixel and create a new bitmap by subtracting the
resulting RGB components from the RGB components of the original
image, ignoring the edge pixels. Use absolute values. Repeat for the
other seven major compass directions. Then average the RGB values of
the eight bitmaps. That might provide decent multidirectional edge
detection.

Many of the image filters mentioned by Rod Stephens are based on
applying Engineering principles to images. Colors that change
gradually are the low frequency areas of the image. Colors that
change rapidly are the high frequency areas of the image. Many image
effects, such as blurring, are produced using spatial filtering, where
a weighted average of nearby pixels in an original bitmap is used to
produce an area effect.

James A. Fortune
(e-mail address removed)

Laplacian edge detection kernels are similar to those of high-pass
filters, except the sum of the coefficients is zero rather than 1.
This makes the values of most output pixels black, and places where
the filter detects a high-frequency feature are brighter. -- Rod
Stephens
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top