Skip to main content

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

License: MIT

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

clone to use

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

Input

Subtracted background

Background

Without background

Without background

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

numpy_rolling_ball-1.0.0.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

numpy_rolling_ball-1.0.0-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file numpy_rolling_ball-1.0.0.tar.gz.

File metadata

  • Download URL: numpy_rolling_ball-1.0.0.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

Hashes for numpy_rolling_ball-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e3ebc8c62a902e856da45b76b0d6bbb2f633e66445825455cf9d1318dfab9325
MD5 4c6cd19e8273a2fcba6136769ffe43a8
BLAKE2b-256 6006ab903e8b62d1a0edfffcde94cfb46ec8c8b82b425c3e46879102d008ec5a

See more details on using hashes here.

Provenance

The following attestation bundles were made for numpy_rolling_ball-1.0.0.tar.gz:

Publisher: python-publish.yml on alencina-faa/numpy-rolling-ball

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file numpy_rolling_ball-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for numpy_rolling_ball-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f1d475a5cf0a8aa2a2f41ab1c0c653b25dde0c1dca3ee2734fd3308d8af1bb18
MD5 42b0780f1c9f121930bdc7dd8ab0a884
BLAKE2b-256 7e298c93f875986906d5a2933d9e5d5de74749fba4621775e48ea3fa4c27c41b

See more details on using hashes here.

Provenance

The following attestation bundles were made for numpy_rolling_ball-1.0.0-py3-none-any.whl:

Publisher: python-publish.yml on alencina-faa/numpy-rolling-ball

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page