Now function returns both result image and subtracted background
Project description
A numpy implementation of the Rolling ball and sliding paraboloid background subtraction algorithms based on https://github.com/mbalatsko/opencv-rolling-ball transcription
Fully Ported to Python from ImageJ's Background Subtractor. Only works for 8-bit greyscale images currently. Based on the concept of the rolling ball algorithm described in Stanley Sternberg's article, "Biomedical Image Processing", IEEE Computer, January 1983. Imagine that the 2D grayscale image has a third (height) dimension by the image value at every point in the image, creating a surface. A ball of given radius is rolled over the bottom side of this surface; the hull of the volume reachable by the ball is the background. https://imagej.net/ij/developer/source/ij/plugin/filter/BackgroundSubtracter.java.html
This algorithms are perfect for microscope images, to distinguish particles from background.
Installation
pip install numpy-rolling-ball
Usage
# Ejemplo A: usando PIL (Pillow)
from PIL import Image
import numpy as np
from numpy_rolling_ball import subtract_background_rolling_ball
img = np.array(Image.open('path/to/img.tif').convert('L')) # uint8 2D
img, background = subtract_background_rolling_ball(
img, 30, light_background=True, use_paraboloid=False, do_presmooth=True
)
# Ejemplo B: usando un array NumPy ya existente
# (cualquier método que te entregue un array uint8 2D es válido:
# imageio, tifffile, OpenSlide, capturas de cámara, etc.)
import numpy as np
from numpy_rolling_ball import subtract_background_rolling_ball
img = np.asarray(your_uint8_grayscale_array) # shape (H, W), dtype uint8
img, background = subtract_background_rolling_ball(
img, 30, light_background=True, use_paraboloid=False, do_presmooth=True
)
Example outputs
Input
Subtracted background
Without background
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file numpy_rolling_ball-1.0.1.tar.gz.
File metadata
- Download URL: numpy_rolling_ball-1.0.1.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e61adb628defb856634483e602d2166bb8a3b96909e37965a9dae8895825d684
|
|
| MD5 |
ffe0669ef33dced9ea44d21a593ead87
|
|
| BLAKE2b-256 |
d9251de8cc61025d5a08859aff98cbd73db7cb4bd7efb4b0262431422e31e5b2
|
Provenance
The following attestation bundles were made for numpy_rolling_ball-1.0.1.tar.gz:
Publisher:
python-publish.yml on alencina-faa/numpy-rolling-ball
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
numpy_rolling_ball-1.0.1.tar.gz -
Subject digest:
e61adb628defb856634483e602d2166bb8a3b96909e37965a9dae8895825d684 - Sigstore transparency entry: 1052545524
- Sigstore integration time:
-
Permalink:
alencina-faa/numpy-rolling-ball@2048294510c3f78d0bbee1f701edd15fc61cd3e7 -
Branch / Tag:
refs/tags/V1.0.1b - Owner: https://github.com/alencina-faa
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@2048294510c3f78d0bbee1f701edd15fc61cd3e7 -
Trigger Event:
release
-
Statement type:
File details
Details for the file numpy_rolling_ball-1.0.1-py3-none-any.whl.
File metadata
- Download URL: numpy_rolling_ball-1.0.1-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bde4affc3bced545081177f05f90bf8c338c0508a46a45d33317de110c92a81a
|
|
| MD5 |
35a63609f3a7e7ebf2c9c278fd937898
|
|
| BLAKE2b-256 |
262b95ca785b67f36bd82f5b7da66ddc3f04e0362c70b221ad1c8efcd1a8e38a
|
Provenance
The following attestation bundles were made for numpy_rolling_ball-1.0.1-py3-none-any.whl:
Publisher:
python-publish.yml on alencina-faa/numpy-rolling-ball
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
numpy_rolling_ball-1.0.1-py3-none-any.whl -
Subject digest:
bde4affc3bced545081177f05f90bf8c338c0508a46a45d33317de110c92a81a - Sigstore transparency entry: 1052545552
- Sigstore integration time:
-
Permalink:
alencina-faa/numpy-rolling-ball@2048294510c3f78d0bbee1f701edd15fc61cd3e7 -
Branch / Tag:
refs/tags/V1.0.1b - Owner: https://github.com/alencina-faa
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@2048294510c3f78d0bbee1f701edd15fc61cd3e7 -
Trigger Event:
release
-
Statement type: