Metadata-Version: 2.4
Name: numpy-rolling-ball
Version: 1.0.1
Summary: Now function returns both result image and subtracted background
Home-page: https://github.com/alencina-faa/numpy-rolling-ball
Download-URL: 
Author: Maksym Balatsko adapted by Dr. Alberto Lencina
Author-email: alencina@azul.faa.unicen.edu.ar
License: MIT License
Keywords: numpy,background subtraction,rolling ball algorithm
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.0
Classifier: Programming Language :: Python :: 3.1
Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Operating System :: OS Independent
Classifier: Topic :: Scientific/Engineering :: Image Recognition
Description-Content-Type: text/markdown
License-File: LICENSE.txt
Requires-Dist: numpy
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: license
Dynamic: license-file
Dynamic: requires-dist
Dynamic: summary

# 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](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/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

```bash
pip install numpy-rolling-ball
```

## Usage

```python
# 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](https://raw.githubusercontent.com/mbalatsko/opencv-rolling-ball/master/outputs/example.png)

#### Subtracted background

![Background](https://raw.githubusercontent.com/mbalatsko/opencv-rolling-ball/master/outputs/example_bg.png)

#### Without background

![Without background](https://raw.githubusercontent.com/mbalatsko/opencv-rolling-ball/master/outputs/example_roll.png)


