Skip to main content

Now function returns both result image and subtracted background

Project description

Rolling ball and sliding paraboloid background subtraction algorithms

PyPI version Downloads 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. http://rsbweb.nih.gov/ij/developer/source/ij/plugin/filter/BackgroundSubtracter.java.html

This algorithms are perfect for microscope images, to distinguish particles from background.

Installation

pip install opencv-rolling-ball

Usage

import cv2
from cv2_rolling_ball import subtract_background_rolling_ball

img = cv2.imread(f'path/to/img.tif', 0)
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

opencv-rolling-ball-1.0.1.tar.gz (6.2 kB view details)

Uploaded Source

File details

Details for the file opencv-rolling-ball-1.0.1.tar.gz.

File metadata

  • Download URL: opencv-rolling-ball-1.0.1.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.6

File hashes

Hashes for opencv-rolling-ball-1.0.1.tar.gz
Algorithm Hash digest
SHA256 095111fae47056692b44fee9e8f635dcc095276f07ba496738d9f06a27d1fe46
MD5 ecd9f2f35bdcdfd362c7e776bd74d1e1
BLAKE2b-256 86a7b210b66daf1d6beb12f5d5c8bc2f91a3b37f5fb520d6728d7c05ef4e6c14

See more details on using hashes here.

Supported by

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