Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
This python module can calculate the following parameters for binary images:
See this Wikipedia page to get the definition of those parameters.
This module gives the exact results as ImageJ (use edge=True
as shown below), all the parameters are exactly calculated and not approximated.
This project is available via pip:
pip install feret
The definition of the maxferet and minferet uses the image of a caliper. Therefore, only the points which correspond to the convex hull of the object play a role. That is why before any calculations the convex hull is determined to reduce the runtime.
The maxferet is calculated as the maximum Euclidean distance of all pixels.
The minferet is exactly calculated and not approximated. My algorithm uses the fact, that the calipers that define the minferet run on one side through two points and on the other through one point. The script iterates over all edge points and defines a line through the point and the one next to it. Then all the distances to the other points are calculated and the maximum is taken. The minimum of all those maximums is the minferet. The maximum of all those maximums is not the maxferet, that is the reason it is calculated separately. The runtime of this is already pretty good but hopefully I can improve it in the future.
The module can be used as followed:
First you need a binary image for which the feret diameter should be calculated. The background has to have the value zero, the object can have any nonzero value. The object doesn't have to be convex. At the moment the module only supports one object per image.This means, that if there are multiple not connected regions, the script will calculate a convexhull which include all regions and for this hull the feret diameter is calculated.
Thr calls are:
import feret
# tifffile is not required nor included in this module.
import tifffile as tif
img = tif.imread('example.tif') # Image has to be a numpy 2d-array.
# get the values
maxf, minf, minf90, maxf90 = feret.all(img)
# get only maxferet
maxf = feret.max(img)
# get only minferet
minf = feret.min(img)
# get only minferet90
minf90 = feret.min90(img)
# get only maxferet90
maxf90 = feret.max90(img)
# get all the informations
res = feret.calc(img)
maxf = res.maxf
minf = res.minf
minf90 = res.minf90
minf_angle = res.minf_angle
minf90_angle = res.minf90_angle
maxf_angle = res.maxf_angle
maxf90_angle = res.maxf90_angle
There is an option to calculate the Feret diameters for the pixel edges instead of the centers. Just add an edge=True
in the call as shown below. This works for all calls analogous.
import feret
# tifffile is not required nor included in this module.
import tifffile as tif
img = tif.imread('example.tif') # Image has to be a numpy 2d-array.
# get only maxferet
maxf = feret.max(img, edge=True)
This module can also plot the result. Just use
import feret
# tifffile is not required nor included in this module.
import tifffile as tif
img = tif.imread('example.tif') # Image has to be a numpy 2d-array.
# plot the result
feret.plot(img) #edge=True can be passed here too
The reason for the two MinFeret points on the left is described above. The MinFeret line does not have to run in between its two base points or through one of them. MaxFeret and MinFeret do not have to be 90° to each other. To calculate the 90° to MaxFeret and MinFeret use feret.max90(img)
and feret.min90(img)
methods.
FAQs
Calculate the maximum and minimum Feret diameter.
We found that feret demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.