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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Algorithms
  4. Very simple edge detection.

Very simple edge detection.

Scheduled Pinned Locked Moved Algorithms
data-structureshelp
3 Posts 2 Posters 23 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.
  • G Offline
    G Offline
    Genbox
    wrote on last edited by
    #1

    Hi. I have a multidimensional integer array that represents the colors of a image: 0 0 1 0 0 0 0 0 1 0 0 0 0 1 0 1 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 (in this case, white = 0 & black = 1) This color map can vary in size, but I don't think that tributes to the solution here. What I need is a edge detection that detects only the side of the black image; 0 2 1 2 0 0 0 2 1 2 0 0 2 1 0 1 2 0 2 1 0 1 2 0 0 2 1 2 0 0 0 2 1 2 0 0 2 = detected edge, 1 = black, 0 = white. I was trying to traverse the hole color map, row by row, pixel by pixel on each side of the rectangle, and when a black color was found, the loop would break and save the position it was at, like this: textureData[,] - Contains the color map. for (int x = 0; x < texture.Width; x++) { for (int y = 0; y < texture.Height; y++) { if (textureData[x, y] != 0) { edgePoints.Add(new Point(x , y)); break; } } } This works for finding one side, but i can't seem to make a loop for other sides. Please help me.

    L 1 Reply Last reply
    0
    • G Genbox

      Hi. I have a multidimensional integer array that represents the colors of a image: 0 0 1 0 0 0 0 0 1 0 0 0 0 1 0 1 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 (in this case, white = 0 & black = 1) This color map can vary in size, but I don't think that tributes to the solution here. What I need is a edge detection that detects only the side of the black image; 0 2 1 2 0 0 0 2 1 2 0 0 2 1 0 1 2 0 2 1 0 1 2 0 0 2 1 2 0 0 0 2 1 2 0 0 2 = detected edge, 1 = black, 0 = white. I was trying to traverse the hole color map, row by row, pixel by pixel on each side of the rectangle, and when a black color was found, the loop would break and save the position it was at, like this: textureData[,] - Contains the color map. for (int x = 0; x < texture.Width; x++) { for (int y = 0; y < texture.Height; y++) { if (textureData[x, y] != 0) { edgePoints.Add(new Point(x , y)); break; } } } This works for finding one side, but i can't seem to make a loop for other sides. Please help me.

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi, you should not break out of the for loop; instead you should record every transition: whenever 0 is followed by 1 you have a positive edge, whenever 1 is followed by 0 you have a negative edge. So the sequence 0 0 1 1 1 1 0 1 1 0 0 0 has two positive and two negative edges. You can apply this in any direction you want, typically you only need two directions (left->right and top->bottom). Of course a negative edge in left->right direction would be the same as a positive edge in right->left direction. Hope this helps :)

      Luc Pattyn [My Articles] [Forum Guidelines]

      G 1 Reply Last reply
      0
      • L Luc Pattyn

        Hi, you should not break out of the for loop; instead you should record every transition: whenever 0 is followed by 1 you have a positive edge, whenever 1 is followed by 0 you have a negative edge. So the sequence 0 0 1 1 1 1 0 1 1 0 0 0 has two positive and two negative edges. You can apply this in any direction you want, typically you only need two directions (left->right and top->bottom). Of course a negative edge in left->right direction would be the same as a positive edge in right->left direction. Hope this helps :)

        Luc Pattyn [My Articles] [Forum Guidelines]

        G Offline
        G Offline
        Genbox
        wrote on last edited by
        #3

        Yeah, that would make the detection more simple. Thanks.

        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