Detect location boxes (or lines) on an image

  • Thread starter Thread starter Benny
  • Start date Start date
B

Benny

I am wondering if anyone has a [rather] simple approach to detecting
the location of boxes and/or lines on an image. For example, if I
have an image of a form, and want to find out where all of the boxes
and/or lines the form contains for input, how would one find the
location of them? I have seen many more complicated examples such as
detecting edges and highlighting them but none as simple as finding
them and returning a position.
 
I am wondering if anyone has a [rather] simple approach to detecting
the location of boxes and/or lines on an image.  For example, if I
have an image of a form, and want to find out where all of the boxes
and/or lines the form contains for input, how would one find the
location of them?  I have seen many more complicated examples such as
detecting edges and highlighting them but none as simple as finding
them and returning a position.

Well, if you have an algorithm that highlights in some way detected  
elements in an image, you could modify it simply to return coordinate  
information about those elements.

Beyond that, it's not really possible to suggest alternatives.  We don't 
know nearly enough about your input data to know whether there's some sort 
of shortcut you could take to analyzing the image.  Edge detection is  
certainly one possibility, but if you have more information about the  
input data it's possible you could take advantage of that to simplify the  
problem.

Pete

Thanks for your reply Pete. The problem is simply this:

A form is scanned, lets take a W2 for example. That scanned document
is saved as an image. With that image I want to use a C# application
to detect areas on the form that require input, using our example:
First Name has a box to fill in. I want to find the cooridinates of
that box and use it for future reference.

Please tell me if my example helps clarify the need.
 
Is that a typical form?  That is, all forms will have the same kind of  
printing and layout as the W2?



Only slightly.

The fact is, edge detection algorithms should help you to find straight  
lines that make graphical boxes and underlines found on forms.  What is it  
about those that you are having problems with?  What have you tried so  
far?  Why doesn't it work?

This newsgroup isn't really appropriate for "I've got this big, general  
problem that I want someone else to solve".  It's more a forum for helping  
people with very specific issues that might come up while writing a C#  
program using the .NET Framework.

If you have such specific issues that you need assistance with, I'm sure  
help can be provided.  But your question is pretty broad.  It's not really  
clear what exactly you're looking for help with, other than perhaps having 
someone else solve the entire problem.

Pete

The reason i posted in the C# forum is because I am a C# developer
looking for a solution to detect these areas of an image using C#. I
don't need an entire solution, per say, just an idea where to look or
an example of a simple method to use C# to detect lines in an image.
The only reason I can't be more specific is because I have not worked
with images in C# so have no point of reference to what specifically I
am looking for.

To outline, the two things I need to know is this:
Using C#, how do I detect a box (or a square) within an image?

Once I have that reference to the box, how do I determine the location
of that box (using C#)?
 
[...]
To outline, the two things I need to know is this:
Using C#, how do I detect a box (or a square) within an image?

I don't understand why you say you "don't need an entire solution", and  
then follow that up with a broad question like that?  How would one answer  
that question without providing the entire solution?
Once I have that reference to the box, how do I determine the location
of that box (using C#)?

I also don't understand that question.  If you've detected a box and have  
a reference to it, doesn't that imply that you already know the location?

As a general bit of advice: in C#/.NET, you have two basic ways to get at  
image data.  You can access individual pixels using the GetPixel() method  
of the Bitmap class.  Or you can use LockBits() of the Bitmap class to  
retrieve a byte-array representation of the image data.  Probably you're 
going to want the latter for performance reasons.

You can keep hoping for a tutorial on edge-detection here, but I suspect  
you'd be better off researching specific algorithmic details and using  
this newsgroup for the aspects of the problem that are actually specific  
to C# and/or .NET.

Pete

A general "Here's a good link for edge detection using C#" would have
been good enough. Quite honestly, I believe that even your bit on how
to retrieve the image data is more informative than "we can't come up
with a whole solution for you." Since it is a broader topic a broad
reference would really have been suffice. I guess I will proceed
wasting time digging through the 10k results from Google since the
advice/reference given is slim to none. Thanks anyways.
 

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

Back
Top