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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:39:26+00:00 2026-06-12T22:39:26+00:00

As I test scikit-image methods ,I came across skimage.measure.perimeter(image) but couldn’t explain the output

  • 0

As I test scikit-image methods ,I came across skimage.measure.perimeter(image) but couldn’t explain the output of this function.

import numpy as np  
image=np.zeros((100,100))  
image[10:30,10:30]=1                   # this creates a white square  
from skimage.measure import perimeter  
x=perimeter(image)  
print x                               #Should be (20+20+20+20) = 80  
76.0        <<<<<<<<<< it returns this value

Did I misunderstand what this function should return . I know that perimeter is a path that surrounds an area .
Note:-
(1) The difference between the calculated perimeter and the returned perimeter not always by 4.as sometimes it can be 6 no matter it’s a square a rectangle or any other polygon.
Update:=
(1) The function page

  • 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-06-12T22:39:27+00:00Added an answer on June 12, 2026 at 10:39 pm

    Which version of skimage are you using ?
    Version 0.6 and github sources do not have a skimage.measure.perimeter function.

    Additionaly, I think you meant line 3 : image[10:30, 10:30] = 1

    Edit

    Ok, I think I got it. The function is defined in _regionprops.py since version 0.7.1.
    The result 76 is actually right. It computes the perimeter of a white square of shape (20, 20).

    You think each side accounts for 20 pixels which total to 80 pixels. But by doing so you count twice the corner pixels. Removing corner pixels you end-up with a perimeter of 76 pixels.

    For other shapes the difference may not be of 4 pixels.

    Edit 2

    Looking at the source code and the documentation:

    • Documentation of regionprops says that perimeter is an approximation of the perimeter :

    Perimeter of object which approximates the contour as a line
    through the centers of border pixels using a 4-connectivity.

    • The code computes a border_image which consist of the image minus its erosion. This array corresponds to the idea of the perimeter I had in the first edit.

    • It then computes the perimeter by applying a convolution and a weighted sum to the border image. I think this is done to compute the length of the line going through the centers of border pixels as stated in the doc.

    If you want more details, you should ask one of the dev. This is a very new function in the package.

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

Sidebar

Related Questions

{test_url=>http://test.com/123.jpg} is my output from <% @results.each do |t| %> <%= t.image.extract!(test_url) %> <%
Test Page URL: http://www.guygar.com/inception/ultra/indexCopy.html I am new to this and searching SO I found
cat test.txt #this is comment line 1 line 2 #this is comment at line
I test password recovery, but there are errors. Rspec study recently. code (User Controller)
test.txt is a \n split text file: f = open('test.txt','r') f.read(256) But while read
Test string: the%20matrix%20 How can I delete the last three chars? Using this code
test.php?t=xxx,y=sss This is how the user inputs data to my script. How can I
Test.h class Test { public: Test(); //some methods private: int var; //some vars }
Test cases for manual testing. Step by step procedure to test this functionality(sticky note)
test.php includes this: echo json_encode( array( array(name=>John,time=>2pm), array(name=>2,time=>1242pm), array(name=>J231ohn,time=>2p213m), )); jQuery : $.get(test.php, function(data)

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.