image processing

  • Thread starter Andreas Viklund via DotNetMonster.com
  • Start date
A

Andreas Viklund via DotNetMonster.com

Hi!
I am developing an application in ASP.NET that takes an image, that have
been created with a digital camera or camera phone, and processes it, to
get data from it. The image taken by the user will be of a square in some
kind of magazine or newpaper, with a white background and the border of the
square should be black.

What I am trying to do is to find the square, or the corners of the square,
in the image, using ASP.NET code. If the user always took the picture
directly above the square without any rotation and blur this would not be a
big problem. But that is hardly not the case most of the times.

What I have managed to do so far is to convert the image to gray scale and
then made some kind of thresholding so I will end up with just white and
black pixels. This will make the square very visible in the image, but so
will other dark object, even if alot is taken out in the tresholding.

Finding one of the corners in the square, and always be positively sure
that you have found it, would solve alot. Then I think I can manage to do
the rest. In my solution now, I will sometimes find a corner, but it does
not work for many images.

Does some one have an idea of how to solve this problem? I have tried
different ways of search for objects in the image by looking at all pixels,
but I really dont know how to see the difference between the corner of the
square and an object.

Is it possible to search for patterns in the image? like if I search the
image after objects that are similar to a corner of a square.

I would really like some help with this problem. All kinds of ideas are
welcomed!

Best Regards

Andreas Viklund
UMEA, Sweden
 
K

Kevin Spencer

Hi Andreas,

You've got quite a problem on your hands. Let's try to analyze it and see
what pops out:
What I am trying to do is to find the square, or the corners of the
square,
in the image, using ASP.NET code. If the user always took the picture
directly above the square without any rotation and blur this would not be
a
big problem. But that is hardly not the case most of the times.

Here's the first problem: People don't do what they're supposed to do (as
you seem to be aware). Not only is the user not always going to get the
picture directly above the square, but, impish beings that humans are, I
would venture to guess that some of these images might not even have a
square in them. Why, they might even be porn pictures!

The blur issue also creates a difficult situation. If the edges of the
square could be counted on to be crisp, it wouldn't be a problem. You would
just start with each outside edge, get all the pixels in a line, see if they
were all black, and after that move in towards the center until they are NOT
all black. This would give you the inside position and measurements of the
square. Of course, that would be assuming that the square is aligned
correctly, which is hardly a certainty.
Is it possible to search for patterns in the image? like if I search the
image after objects that are similar to a corner of a square.

Yes, it's possible. Pattern-recognition is a rather sophisticated science,
but if you have the algorithms and/or the time and resources, you can write
an app that can find patterns in any image. In this case, the pattern is
relatively simple: a square. But as we mentioned, the blur and alignment
issues could make it very difficult. The alignment issue could be handled by
doing various transforms until one found the alignment, or it could be done
by finding a straight black line (assuming that the blur was NOT an issue,
and assuming that there IS a square in the image.

It would help if we knew more about what sort of images these are, and what
they're used for. So far, you've described the square nicely enough, but
what is in the rest of the image? Knowing that could make the job of finding
your pattern much easier (or harder!).

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.
 
A

Andreas Viklund via DotNetMonster.com

Hello,

if you follow these links you can see a before and after picture of the
image processing I have done so far on one type of image.

http://www.badaboom.se/test/earring2.jpg

http://www.badaboom.se/test/process.jpg

I first converted the image to grayscale and then turned all the pixels to
either white or black. that makes alot of objects disapear. but if you
look at this image:

http://www.badaboom.se/test/shoes.jpg

it has alot more blur and it is not perfectly aligned. Therefor its much
harder to find the square. any suggestions?


could you also explain more how a pattern algoritm would be implemented?

best regards

Andreas Viklund
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top