Detect location boxes (or lines) on an image

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Benny

    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.
  • Peter Duniho

    #2
    Re: Detect location boxes (or lines) on an image

    On Fri, 02 May 2008 08:31:06 -0700, Benny <bennyandlinds@ 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

    Comment

    • Benny

      #3
      Re: Detect location boxes (or lines) on an image

      On May 2, 11:46 am, "Peter Duniho" <NpOeStPe...@nn owslpianmk.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.

      Comment

      • Peter Duniho

        #4
        Re: Detect location boxes (or lines) on an image

        On Fri, 02 May 2008 10:19:58 -0700, Benny <bennyandlinds@ 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

        Comment

        • Benny

          #5
          Re: Detect location boxes (or lines) on an image

          On May 2, 12:34 pm, "Peter Duniho" <NpOeStPe...@nn owslpianmk.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#)?

          Comment

          • Peter Duniho

            #6
            Re: Detect location boxes (or lines) on an image

            On Fri, 02 May 2008 11:54:46 -0700, Benny <bennyandlinds@ 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

            Comment

            • Benny

              #7
              Re: Detect location boxes (or lines) on an image

              On May 2, 2:04 pm, "Peter Duniho" <NpOeStPe...@nn owslpianmk.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.

              Comment

              • Paul E Collins

                #8
                Re: Detect location boxes (or lines) on an image

                "Benny" <bennyandlinds@ 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.a lgorithms. 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.


                Comment

                • henon

                  #9
                  Re: Detect location boxes (or lines) on an image

                  On May 2, 8:54 pm, Benny <bennyandli...@ gmail.comwrote:
                  On May 2, 12:34 pm, "Peter Duniho" <NpOeStPe...@nn owslpianmk.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

                  Comment

                  • henon

                    #10
                    Re: Detect location boxes (or lines) on an image

                    On May 2, 11:24 pm, "Paul E Collins" <find_my_real_a ddr...@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.a lgorithms. 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

                    Comment

                    • =?Utf-8?B?YWFybWVudGE=?=

                      #11
                      Re: Detect location boxes (or lines) on an image

                      Maybe



                      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_a ddr...@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.a lgorithms. 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
                      >

                      Comment

                      Working...