Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7060495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:21:35+00:00 2026-05-28T04:21:35+00:00

The Requirements I’m not sure how to describe this so I’ll give an example

  • 0

The Requirements
I’m not sure how to describe this so I’ll give an example that should be easier to explain.

I have a small (maximum 50×50 pixels) 1bit/pixel bitmap (black and white).
Only one pixel is added at a time.
Find the largest (by area) polygon that exists using the black pixels as the edges.

The actual scenario isn’t actually graphics related and uses a 2D Boolean array but the logic would be the same I imagine.

The Desired Behavior

The problem
I am not sure how to get the largest polygon when it is completed. I can do the filling if I can just get the polygon. In the above image I have highlighted the polygon that should be selected.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:21:36+00:00Added an answer on May 28, 2026 at 4:21 am

    It turns out it was much more simple than I was expecting. I guess I was trying to make things overcomplicated. Because of the small dimensions and the fact that it will not run that frequently, speed is not a really an issue.

    I don’t have access to exactly how I did it right now but this is the general idea.

    Each pixel is stored as an instance of SomePixelType.
    There is a Stack<SomePixelType> of pixels called visitedPixels.
    A pixel is considered a possible polygon edge if:

    • It has between 2 and 7 (both inclusive) black neighbouring pixels.
    • It is not in the visitedPixels collection.

    SomePixelType has a method named GetNextPixel.

    When GetNextPixel is called it will search neighbouring pixels (starting directly up and going clockwise) for a possible polygon edge and return it. Calling it again will continue searching from the last match. Once all neighbouring pixels have been checked it will return null.

    When a pixel is set this method would be called.

    public Stack<SomePixelType> GetPolygonEdges(SomePixelType justSetPixel)
    {
        visitedPixels.Clear();
    
        if(!justSetPixel.IsPossiblePolygon)
            return null; // Not a possible edge. No closed polygon could of been completed.
    
        visitedPixels.Push(justSetPixel);
    
        SomePixelType currentPixel = justSetPixel;
        while(visitedPixels.Count > 0)
        {
            currentPixel  = currentPixel.GetNextPixel();
            if(currentPixel == null) // No possible neighbouring polygon edges.
            {
                currentPixel = visitedPixels.Pop(); // Backtrack
                continue;
            }
            if(currentPixel == justSetPixel)
                return visitedPixels;
    
            visitedPixels.Push(currentPixel);
        }
        return null; // Not closed.
    }
    

    From here on it is fairly easy to fill in. As the question was about finding the polygon I will stop at this step.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two requirements, and im not sure is those things possible in AS3.
My requirements are that Ads have a definite size, could be different media types
Here are my requirements: I have a DIV which should display an image (JPEG).
I have following requirements: create a cookie for server domain that cookie will expire
Are there any requirements gathering tools that have a voting system built in? Using
Requirements are as follows: Grouping hierarchies should be swappable, for example Country > City
I have the following requirements for an application that many people will be using
I have some following requirements, I don't know can we do this in iPhone
Requirements: function arguments: - $day, $month function should return the year. Is this possible
Basic Requirements I have a SL app that can be run in-browser or out-of-browser.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.