Skip to content

Simple python code to extract segments passing through the mean, given a set of points composing the border of a figure.

Notifications You must be signed in to change notification settings

simonebonato/segment_through_mean

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Longest Segment Through Mean

This is a simple method that, given a list of 2d points that constitutes the border of a shape, finds all the segments that start from the points on the border, pass through the mean of the points, and end on the border again. Then it finds the longest segment among them.

🐍 How to use

First you need to have (or create) an environment using the requirements.txt file (this will allow you to use the extractor_class.py, however to run the example.ipynb you are going to need the plotly library). To use the code, simply clone the repo and use the code contained in the extractor_class.py file, as shown in example.ipynb.

The code is really simple, don't get discouraged by the length of the code on the notebook, most of it belongs to the plotting part!

🐋 Example figures

An example of the figure used in the example notebook is: image

Then it is possible to extract all the edges that make the figure: image

And finally compute all the segments that start from the points that define the border and arrive on the other side, finding the longest one: image

About

Simple python code to extract segments passing through the mean, given a set of points composing the border of a figure.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published