Results 1 to 22 of 22

Thread: *UPDATED* find coordinates on a picture...

  1. #1

    Thread Starter
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755

    *UPDATED* find coordinates on a picture...

    hi!
    i want to make a program where the user can load a picture
    and click the backgroundcolor, then the program calculated the cordinates around the picture....
    hmm...
    it a bit more complicated than that...

    just look at this picture and you'll understand!





    the coordinates can be printed in a textbox or in a txt file or anything!

    please help me with this!
    Attached Images Attached Images  
    Last edited by cyborg; Apr 22nd, 2002 at 09:29 PM.
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  2. #2

    Thread Starter
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    please help me!
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  3. #3
    Fanatic Member Alien_poo's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    668
    LOL! nice animation....

    the only way I would see to do this si to scan every little pixel one by one and store it's color in an array...
    "A RESPECTED scientist has put forward the stunning - if unsavoury - possibility that humans are descended from sewage dumped overboard by aliens."
    "First we read that we are the creation of God, then scientists say we are descended from apes. Now they say we're some sort of alien poo. How much further can we sink?"
    - Robert Matthews, Science Correspondent

  4. #4

    Thread Starter
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    yeah...but then?

    and i dont know how to do arrays...
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  5. #5

    Thread Starter
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    i've made a program that can open files like this drawn by hand...
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  6. #6
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    What you want is impossible. How would a program even know whre to start tracing? How would it know what parts to trace? Maybe with a simple picture like you had(A Black Smiley Face on a red background) it would be possible but still very difficult, and there would be no way to write an algorithm that would work for any picture.



    It's just not possible.
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  7. #7

    Thread Starter
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    oh....forgit to mention:
    the program is not ment to draw lines!
    just store coordinates in a textbox or textfile...
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  8. #8

    Thread Starter
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    it IS possible!
    i've used another program that does the same thing...

    i dont know how it works, but it works!
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  9. #9

    Thread Starter
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    have you used the floodfill api?
    how can that function know where to paint?
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  10. #10

    Thread Starter
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    i know i can make a program that draws lines around those objects, but i can do one that does it in the right order...
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  11. #11

    Thread Starter
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    when the user clicks on the background color the program knows where to look...
    between that color and a color thats not equal to the BG color...
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  12. #12
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    Not even photoshop can do what you are asking I seriously doubt you'll find an answer on this VB forum
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  13. #13
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    If i understand you correctly, you want to detect everywhere where there is a change in colour, from the background to something else?? Am i correct?

    If so, your logic would go something like this.

    VB Code:
    1. Option Explicit
    2. Dim i As Integer, j As Integer
    3. Dim BackGroundColour As Long
    4. Private Type typPixel
    5.     x As Integer
    6.     y As Integer
    7. End Type
    8. Dim Edge() As typPixel
    9. Private Sub FindEdges
    10.     Pic.ScaleMode = 3 'Pixel
    11.     For i = 2 To Pic.ScaleHeight
    12.         For j = 1 To Pic.ScaleWidth
    13.             If Pic.Point(j, i) = BackGroundColour And Pic.Point(j, i - 1) <> BackGroundColour Then
    14.                 ReDim Preserve Edge(UBound(Edge) + 1)
    15.                 Edge(UBound(Edge)).x = j
    16.                 Edge(UBound(Edge)).y = i
    17.             End If
    18.         Next j
    19.     Next i
    20.    
    21.     For i = 1 To Pic.ScaleHeight - 1
    22.         For j = 1 To Pic.ScaleWidth
    23.             If Pic.Point(j, i) = BackGroundColour And Pic.Point(j, i + 1) <> BackGroundColour Then
    24.                 ReDim Preserve Edge(UBound(Edge) + 1)
    25.                 Edge(UBound(Edge)).x = j
    26.                 Edge(UBound(Edge)).y = i
    27.             End If
    28.         Next j
    29.     Next i
    30.    
    31.     For i = 1 To Pic.ScaleHeight
    32.         For j = 2 To Pic.ScaleWidth
    33.             If Pic.Point(j, i) = BackGroundColour And Pic.Point(j - 1, i) <> BackGroundColour Then
    34.                 ReDim Preserve Edge(UBound(Edge) + 1)
    35.                 Edge(UBound(Edge)).x = j
    36.                 Edge(UBound(Edge)).y = i
    37.             End If
    38.         Next j
    39.     Next i
    40.    
    41.     For i = 1 To Pic.ScaleHeight
    42.         For j = 1 To Pic.ScaleWidth - 1
    43.             If Pic.Point(j, i) = BackGroundColour And Pic.Point(j + 1, i) <> BackGroundColour Then
    44.                 ReDim Preserve Edge(UBound(Edge) + 1)
    45.                 Edge(UBound(Edge)).x = j
    46.                 Edge(UBound(Edge)).y = i
    47.             End If
    48.         Next j
    49.     Next i
    50. End Sub

    This will check every pixel, and against the ones next to it, for a change in colour. You may need to do diaganols, but that won't be too difficult.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  14. #14
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Yes I would suggest an approach as used by SLH.
    That is the only sensible way to approach the problem.
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  15. #15

    Thread Starter
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    yeah! SLH....you know what i want....but i also (if its possible) want the program to sort the coordinates as the .gif animation shows...

    i get the
    "Subscript out of range"
    error on
    "ReDim Preserve Edge(UBound(Edge) + 1)"

    what wrong?
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  16. #16
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Sorry, try this code:

    VB Code:
    1. Option Explicit
    2. Dim i As Integer, j As Integer
    3. Dim BackGroundColour As Long
    4. Private Type typPixel
    5.     x As Integer
    6.     y As Integer
    7. End Type
    8. Dim Edge() As typPixel
    9. Private Sub FindEdges
    10.     [B]ReDim Edge(0)[/B]
    11.     Pic.ScaleMode = 3 'Pixel
    12.     For i = 2 To Pic.ScaleHeight
    13.         For j = 1 To Pic.ScaleWidth
    14.             If Pic.Point(j, i) = BackGroundColour And Pic.Point(j, i - 1) <> BackGroundColour Then
    15.                 ReDim Preserve Edge(UBound(Edge) + 1)
    16.                 Edge(UBound(Edge)).x = j
    17.                 Edge(UBound(Edge)).y = i
    18.             End If
    19.         Next j
    20.     Next i
    21.    
    22.     For i = 1 To Pic.ScaleHeight - 1
    23.         For j = 1 To Pic.ScaleWidth
    24.             If Pic.Point(j, i) = BackGroundColour And Pic.Point(j, i + 1) <> BackGroundColour Then
    25.                 ReDim Preserve Edge(UBound(Edge) + 1)
    26.                 Edge(UBound(Edge)).x = j
    27.                 Edge(UBound(Edge)).y = i
    28.             End If
    29.         Next j
    30.     Next i
    31.    
    32.     For i = 1 To Pic.ScaleHeight
    33.         For j = 2 To Pic.ScaleWidth
    34.             If Pic.Point(j, i) = BackGroundColour And Pic.Point(j - 1, i) <> BackGroundColour Then
    35.                 ReDim Preserve Edge(UBound(Edge) + 1)
    36.                 Edge(UBound(Edge)).x = j
    37.                 Edge(UBound(Edge)).y = i
    38.             End If
    39.         Next j
    40.     Next i
    41.    
    42.     For i = 1 To Pic.ScaleHeight
    43.         For j = 1 To Pic.ScaleWidth - 1
    44.             If Pic.Point(j, i) = BackGroundColour And Pic.Point(j + 1, i) <> BackGroundColour Then
    45.                 ReDim Preserve Edge(UBound(Edge) + 1)
    46.                 Edge(UBound(Edge)).x = j
    47.                 Edge(UBound(Edge)).y = i
    48.             End If
    49.         Next j
    50.     Next i
    51. End Sub

    NB: This code will take a couple of seconds on a large image (well, even a small one).

    As for drawing lines, it would be easy to highlight the edges, but to make it join them up, would require A LOT of thinking....
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  17. #17

    Thread Starter
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    yeah!
    nice!
    this code gets me the coordinates

    but do you know any way to sort them?
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  18. #18
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    What do you mean by 'sorted', do you want the program to calculate the best way to join then up (like in your pic)?? If so that would be very difficult.


    P.S. Just out of interest, are you making a program that shows where a 'jig-saw' would need to cut (because that's what it looks like).
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  19. #19

    Thread Starter
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    yes, i mean that the program should find the best way to draw the lines...

    and no! im making a transparent region generator for winamp skins!
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  20. #20
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    How are you going to use the lines created to generate a transparency region, surely it'll end up being the same region as the bacoground??

    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  21. #21

    Thread Starter
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    winamp loads the transparecy regions in a strange way...
    you have to do a file that looks like this fore example:


    if there is a line with 6 different coordinates
    (170,36)
    (200,36)
    (226,36)
    etc...

    it has to look like this:


    [Normal]
    NumPoints = 6
    PointList = 170,36,200,36,226,36,239,36,255,36,34,63


    this is the line where winamp is going to "cut" off the background
    Last edited by cyborg; Apr 23rd, 2002 at 02:40 PM.
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  22. #22
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Ok, as i've said a couple of times in this post, i'll have a think
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width