Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Edge Detection in image to measure size [modified]

Edge Detection in image to measure size [modified]

Scheduled Pinned Locked Moved C#
help
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    shultas
    wrote on last edited by
    #1

    Hello Everyone- I am looking at making an application that will detect the square footage of a piece of wood that is placed on a table. I am thinking that the table will have a bright orange color, so the dark wood placed on it would provide a lot of contrast. I will use a camera to take a picture of the table (the table lets say is 6 FT by 6 FT) and analyze the image to figure out how big the piece of wood is that has been placed on this table. I am wondering if anyone can point me in the right direction here code wise (like search terms, etc). I've so far made it to Blob Analysis and have been reading about that. Any help or pointers into exactly what I need to learn to make this possible would be appreciated immensely! Thank you! EDIT: I also am wondering if it would be possible to somehow equate each pixel with a real life measurement, such as 1mm, and if it was possible to somehow calculate the pixels that were not orange, and come up with a measurement that way (Because some times the pieces of wood are not going to be square or rectangular ... but I figured I would get the sq/rect down first because I just figured that would be the easiest). I'm in the middle of reading an awesome multi-part article on this site about it, but just trying to figure out which way to go next. Thanks much!

    modified on Thursday, July 9, 2009 9:42 AM

    S 1 Reply Last reply
    0
    • S shultas

      Hello Everyone- I am looking at making an application that will detect the square footage of a piece of wood that is placed on a table. I am thinking that the table will have a bright orange color, so the dark wood placed on it would provide a lot of contrast. I will use a camera to take a picture of the table (the table lets say is 6 FT by 6 FT) and analyze the image to figure out how big the piece of wood is that has been placed on this table. I am wondering if anyone can point me in the right direction here code wise (like search terms, etc). I've so far made it to Blob Analysis and have been reading about that. Any help or pointers into exactly what I need to learn to make this possible would be appreciated immensely! Thank you! EDIT: I also am wondering if it would be possible to somehow equate each pixel with a real life measurement, such as 1mm, and if it was possible to somehow calculate the pixels that were not orange, and come up with a measurement that way (Because some times the pieces of wood are not going to be square or rectangular ... but I figured I would get the sq/rect down first because I just figured that would be the easiest). I'm in the middle of reading an awesome multi-part article on this site about it, but just trying to figure out which way to go next. Thanks much!

      modified on Thursday, July 9, 2009 9:42 AM

      S Offline
      S Offline
      Sun Rays
      wrote on last edited by
      #2

      Hey, is this the same[^] you are looking for ?

      Thanks, Sun Rays To get something you must have to try once. My Articles

      S 1 Reply Last reply
      0
      • S Sun Rays

        Hey, is this the same[^] you are looking for ?

        Thanks, Sun Rays To get something you must have to try once. My Articles

        S Offline
        S Offline
        shultas
        wrote on last edited by
        #3

        Hi There- That is the article that I am reading now! What I am trying to do is figure out how to take the edge detection from that article and apply it into my solution (ie, somehow take the edges and do some calculations to figure out the square footage). That's kind of where I am stumped, I don't know how to "link" the two. Thank you!!

        C 1 Reply Last reply
        0
        • S shultas

          Hi There- That is the article that I am reading now! What I am trying to do is figure out how to take the edge detection from that article and apply it into my solution (ie, somehow take the edges and do some calculations to figure out the square footage). That's kind of where I am stumped, I don't know how to "link" the two. Thank you!!

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          Basically, the edge detection filters will give you a high contrast result, which you can iterate over and find edges easily, because they are close to white, while the rest is basically black. The real issue is, knowing for sure that there's only two objects with edges in your image. I've done this sort of thing before, to calibrate the size of a photo in an xray scanner, so I could them measure other images. We scanned a sheet which had a series of dots on it. I didn't use any filters, I just walked the image looking for black pixels. Once this was done, we used the mapping of pixels to mm to provide measurements in a measure tool inside the software.

          Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

          S 1 Reply Last reply
          0
          • C Christian Graus

            Basically, the edge detection filters will give you a high contrast result, which you can iterate over and find edges easily, because they are close to white, while the rest is basically black. The real issue is, knowing for sure that there's only two objects with edges in your image. I've done this sort of thing before, to calibrate the size of a photo in an xray scanner, so I could them measure other images. We scanned a sheet which had a series of dots on it. I didn't use any filters, I just walked the image looking for black pixels. Once this was done, we used the mapping of pixels to mm to provide measurements in a measure tool inside the software.

            Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

            S Offline
            S Offline
            shultas
            wrote on last edited by
            #5

            First of all, your article series is AWESOME and I thank you for it as well as the help you've given me over the past few weeks! I am wondering if this scenario would work. Your input would be greatly appreciated! The camera is set to produce a 1024x768 image. The camera looks down onto a table that is 10' by 10' (100 Square Feet). I position the camera so that the image it captures exactly covers this table. The table is painted a bright orange color (R-255,G-162,B-59). (Now I'm just trying to work this out in my head, I don't know if this will work, but what I am thinking is...) The camera is looking on the table, so we know that the 1024x768 image that the camera is going to produce will cover exactly 100 Square Feet, every time. So, a grand total of 786,432 pixels. 100 Square Feet would be 30,480 sq millimeters. Each pixel would equate to approximately 0.03875732421875 of a millimeter. (I don't know if this is correct or logical or would work I'm just thinking out loud). I open up the image. I walk through the image using GetPixel, pixel by pixel, and check the RGB value of that pixel. If it is close to 255/162/59, i disregard it. Any other color would add the 0.038... number to the global count. After it is all said and done, I should have a value of how many millimeters in the entire space is "in use" and be able to calculate the total area of the wood or stones that are currently on the table. Basically a family member contacted me. He sells stone (they may be mosaic, so not necessarily always rectangular). I'm trying to think of a way to take pictures of the stone as he puts them into a bin in order to calculate the square footage on those stones that he is selling (ie, he sold 250 SQ feet to someone "by eye" and the person actually got out a measuring tape and measured all the pieces and realized there was only 240 SQ feet and had a hissy). So I was thinking if this method of analyzing an image pixel by pixel, when you know exactly how big the area is every time of that image, would work. Thanks much for the response!!

            OriginalGriffO 1 Reply Last reply
            0
            • S shultas

              First of all, your article series is AWESOME and I thank you for it as well as the help you've given me over the past few weeks! I am wondering if this scenario would work. Your input would be greatly appreciated! The camera is set to produce a 1024x768 image. The camera looks down onto a table that is 10' by 10' (100 Square Feet). I position the camera so that the image it captures exactly covers this table. The table is painted a bright orange color (R-255,G-162,B-59). (Now I'm just trying to work this out in my head, I don't know if this will work, but what I am thinking is...) The camera is looking on the table, so we know that the 1024x768 image that the camera is going to produce will cover exactly 100 Square Feet, every time. So, a grand total of 786,432 pixels. 100 Square Feet would be 30,480 sq millimeters. Each pixel would equate to approximately 0.03875732421875 of a millimeter. (I don't know if this is correct or logical or would work I'm just thinking out loud). I open up the image. I walk through the image using GetPixel, pixel by pixel, and check the RGB value of that pixel. If it is close to 255/162/59, i disregard it. Any other color would add the 0.038... number to the global count. After it is all said and done, I should have a value of how many millimeters in the entire space is "in use" and be able to calculate the total area of the wood or stones that are currently on the table. Basically a family member contacted me. He sells stone (they may be mosaic, so not necessarily always rectangular). I'm trying to think of a way to take pictures of the stone as he puts them into a bin in order to calculate the square footage on those stones that he is selling (ie, he sold 250 SQ feet to someone "by eye" and the person actually got out a measuring tape and measured all the pieces and realized there was only 240 SQ feet and had a hissy). So I was thinking if this method of analyzing an image pixel by pixel, when you know exactly how big the area is every time of that image, would work. Thanks much for the response!!

              OriginalGriffO Offline
              OriginalGriffO Offline
              OriginalGriff
              wrote on last edited by
              #6

              It sound logical, but you would get a different result depending on how the stone / wood is oriented. Instead of using the whole image, just use a 768 * 768 portion of it, and each pixel can then be square (and 3.96875mm on a side, so your size calculation is a little iffy - 10 feet = 3048mm so 100 sq feet would be 3048 * 3048 sq mm).

              No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones

              "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
              "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups