Results 1 to 2 of 2

Thread: Count shapes in image

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,950

    Count shapes in image

    I have an image which has a number of shapes, all are the same color and on a white background. Is there a quick way of counting how many shapes there are?

    I don't want to know what shape they actually are (polygon, circle or whatever), I just want to know how many isolated shapes are present. Other than some kind of brute force method, I can't find any other way of doing this.

  2. #2
    PowerPoster boops boops's Avatar
    Join Date
    Nov 2008
    Location
    Holland/France
    Posts
    3,201

    Re: Count shapes in image

    Use a paint-bucket fill algorithm -- there's plenty to find on the web. Scan the image for the first coloured pixel you find, do a paint fill to get all the connected pixels, add 1 to your shape count and delete those pixels. Repeat until there are no coloured pixels left. Or does this count as brute force?

    BB

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