471,357 Members | 1,177 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,357 software developers and data experts.

Detect location boxes (or lines) on an image

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.
Jun 27 '08 #1
10 8390
On Fri, 02 May 2008 08:31:06 -0700, Benny <be***********@gmail.comwrote:
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
Jun 27 '08 #2
On May 2, 11:46*am, "Peter Duniho" <NpOeStPe...@nnowslpianmk.com>
wrote:
On Fri, 02 May 2008 08:31:06 -0700, Benny <bennyandli...@gmail.comwrote:
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.
Jun 27 '08 #3
On Fri, 02 May 2008 10:19:58 -0700, Benny <be***********@gmail.comwrote:
A form is scanned, lets take a W2 for example.
Is that a typical form? That is, all forms will have the same kind of
printing and layout as the W2?
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.
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
Jun 27 '08 #4
On May 2, 12:34*pm, "Peter Duniho" <NpOeStPe...@nnowslpianmk.com>
wrote:
On Fri, 02 May 2008 10:19:58 -0700, Benny <bennyandli...@gmail.comwrote:
A form is scanned, lets take a W2 for example.

Is that a typical form? *That is, all forms will have the same kind of *
printing and layout as the W2?
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.

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#)?
Jun 27 '08 #5
On Fri, 02 May 2008 11:54:46 -0700, Benny <be***********@gmail.comwrote:
[...]
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
Jun 27 '08 #6
On May 2, 2:04*pm, "Peter Duniho" <NpOeStPe...@nnowslpianmk.com>
wrote:
On Fri, 02 May 2008 11:54:46 -0700, Benny <bennyandli...@gmail.comwrote:
[...]
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.
Jun 27 '08 #7
"Benny" <be***********@gmail.comwrote:
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.
Or you could try posting on a newsgroup that's actually relevant, like
comp.graphics.algorithms. The fact that you're using C# as a language
doesn't automatically make every problem a C# problem. Maybe you have a
dog, but that doesn't mean you should ask on rec.pets.dogs about how to
detect a box in an image.

Eq.
Jun 27 '08 #8
On May 2, 8:54 pm, Benny <bennyandli...@gmail.comwrote:
On May 2, 12:34 pm, "Peter Duniho" <NpOeStPe...@nnowslpianmk.com>
wrote:
On Fri, 02 May 2008 10:19:58 -0700, Benny <bennyandli...@gmail.comwrote:
A form is scanned, lets take a W2 for example.
Is that a typical form? That is, all forms will have the same kind of
printing and layout as the W2?
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.
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?
this is a classical pattern recognition task. believe me, you wouldn't
want to implement every detail for recognizing rectangles/squares
yourself unless you can simplify the problem to a trivial case. it is
usually done using image processing libraries. however, I am pretty
sure there are not much if any C# libraries that offer such
functionality. the most effective way is to use one of many c++
libraries (IPP, OpenCV, etc) via interop.

-- henon

-------------------
my c# blog: http://www.eqqon.com/index.php/User:Henon

Jun 27 '08 #9
On May 2, 11:24 pm, "Paul E Collins" <find_my_real_addr...@CL4.org>
wrote:
"Benny" <bennyandli...@gmail.comwrote:
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.

Or you could try posting on a newsgroup that's actually relevant, like
comp.graphics.algorithms. The fact that you're using C# as a language
doesn't automatically make every problem a C# problem. Maybe you have a
dog, but that doesn't mean you should ask on rec.pets.dogs about how to
detect a box in an image.

Eq.
detecting a box in an image is not a language specific problem.
however, it *is* some sort of a c# problem because there are no c#
libs around for this kind of task (at least I don't know any good ones
that are directly usable from c#). so the real problem is, which of
the available libraries can be easily made use of from within c#. ;)

-- henon
-----------------

my c# blog: http://www.eqqon.com/index.php/User:Henon
Jun 27 '08 #10
Maybe

http://code.google.com/p/aforge/

a C# lib for image processing.... you can use blob counter class to extract
shapes from images

hope that this helps

Regards

"henon" wrote:
On May 2, 11:24 pm, "Paul E Collins" <find_my_real_addr...@CL4.org>
wrote:
"Benny" <bennyandli...@gmail.comwrote:
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.
Or you could try posting on a newsgroup that's actually relevant, like
comp.graphics.algorithms. The fact that you're using C# as a language
doesn't automatically make every problem a C# problem. Maybe you have a
dog, but that doesn't mean you should ask on rec.pets.dogs about how to
detect a box in an image.

Eq.

detecting a box in an image is not a language specific problem.
however, it *is* some sort of a c# problem because there are no c#
libs around for this kind of task (at least I don't know any good ones
that are directly usable from c#). so the real problem is, which of
the available libraries can be easily made use of from within c#. ;)

-- henon
-----------------

my c# blog: http://www.eqqon.com/index.php/User:Henon
Jun 27 '08 #11

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by aiki727 via DotNetMonster.com | last post: by
5 posts views Thread by Martin Larsen | last post: by
13 posts views Thread by laredotornado | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.