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 7085285
In Process

The Archive Base Latest Questions

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

I´m trying to compute the perimeter of a region in binary images. When a

  • 0

I´m trying to compute the perimeter of a region in binary images. When a region is simply connected, i.e. it has no “holes”, everything is quite simple: I just check for every pixel if it belongs to the region and has at least a neighbor which is not belonging to the region… I have a variable that counts the number of pixels satisfying this condition.

In the case of region with holes I use a different way. I start from a pixel in the border and “jump” to a neighbor (increasing a counter) if it is itself a border pixel. The procedure, with some more quirks, ends when I go back to the initial pixels. Something like this:

int iPosCol = iStartCol, int iPosRow = iStartRow;
do 
{
  //check neighbors, pick point on the perimeter
  //condition: value == label, pixel at the border.
  check8Neighbors(iPosCol, iPosRow);
  updatePixPosition(iPosCol, iPosRow);
}
while ( iPosC != iStartC || iPosR != iStartR );

The problem is that this method won´t work if the holes in the region are close to the border (1-pixel distance).

Are there standard ways of computing perimeter of non simply connected regions, or am I approaching the problem in the wrong way?

  • 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-28T07:24:22+00:00Added an answer on May 28, 2026 at 7:24 am

    So here is my proposition:
    Let’s assume you want to find the border of a black region(for simplicity).
    First add one extra white column and one extra white row on all sides of the image. This is done to simplify corner cases and I will try to explain where it helps.

    Next do a breadth first search from any pixel in your region. The edges in the graph are defined as connecting neighbouring cells in black color. By doing this BFS you will find all the pixels in your region. Now select the bottom-most(you can find it linerly) and if there are many bottom-most just select any of them. Select the pixel that is below it – this pixel is white for sure because: we selected the bottom-most of the pixels in our region and if the pixel was black the BFS would have visited it. Also there is a pixel below our bottom-most pixel because of the extra rows and columns we added.

    Now do another BFS this time passing through white nighbouring pixels(again the fact that we added additional rows and columns helps here). This way we find a white region that surrounds the black region we are interested in from everywhere. Now all the pixels from the original black region that are neighbouring any of the pixels in the newly found white region are part of the border and only they are part of it. So you count those pixels and there you go – you have the perimeter.

    The solution is complicated by the fact that we do not want to count borders of the holes as part of the perimeter – had this condition not be present we could just count all the pixels in the initial black region that are neighbouring any white pixel or the border of the image(here we do not need to add rows and colums).

    Hope this answer helps.

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

Sidebar

Related Questions

I'm just digging a bit into Haskell and I started by trying to compute
I was just trying to debug the following exception: Exception has been thrown by
Im trying to compute a 24 hour rms (root mean squared) from a dataset
I'm trying to compute confidence intervals for groups with a common model using lmList
I am trying to compute the hash of a byte array in Java. To
I'm trying to compute item-to-item similarity along the lines of Amazon's Customers who viewed/purchased
I'm trying to compute the average of a field over various subsets of a
I am trying to compute (360 / 24) / 60 I keep getting the
I am trying to compute and count the number of rows inside a C#
I have been trying to compute the total sum of all these ord s

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.