ImageBinarization.jl Documentation

A Julia package containing a number of algorithms for analyzing images and automatically binarizing them into background and foreground.

Getting started

This package is part of a wider Julia-based image processing ecosystem. If you are starting out, then you may benefit from reading about some fundamental conventions that the ecosystem utilizes that are markedly different from how images are typically represented in OpenCV, MATLAB, ImageJ or Python.

The usage examples in the ImageBinarization.jl package assume that you have already installed some key packages. Notably, the examples assume that you are able to load and display an image. Loading an image is facilitated through the FileIO.jl package, which uses QuartzImageIO.jl if you are on MacOS, and ImageMagick.jl otherwise. Depending on your particular system configuration, you might encounter problems installing the image loading packages, in which case you can refer to the troubleshooting guide.

Image display is typically handled by the ImageView.jl package. Alternatives include the various plotting packages, including Makie.jl. There is also the ImageShow.jl package which facilitates displaying images in Jupyter notebooks via IJulia.jl. Finally, one can also obtain a useful preview of an image in the REPL using the ImageInTerminal.jl package. However, this package assumes that the terminal uses a monospace font, and tends not to produce adequate results in a Windows environment.

Another package that is used to illustrate the functionality in ImageBinarization.jl is the TestImages.jl which serves as a repository of many standard image processing test images.

Basic usage

Each binarization algorithm in ImageBinarization.jl is an AbstractImageBinarizationAlgorithm.

Suppose one wants to binarize an image. This can be achieved by simply choosing an appropriate algorithm and calling binarize or binarize! in the image. The background and foreground will be automatically binarized.

Let's see a simple demo:

using TestImages, ImageBinarization
img = testimage("cameraman")
alg = Otsu()
img₀₁ = binarize(img, alg)
93825
demo image

This usage reads as "binarize the image img with algorithm alg"

For more advanced usage, please check function reference page.

Examples of ImageBinarization in action

Image of cells:
Original image
Original image
Intermodes
Intermodes
Minimum Error
Minimum Error
Minimum
Minimum
Moments
Moments
Otsu
Otsu
Polysegment
Polysegment
Rosin
Rosin
Sauvola
Sauvola
Niblack
Niblack
Adaptive
Adaptive
Yen
Yen
Balanced
Balanced
Image of moon surface: (Unimodal)
Original image
Original image
Intermodes
Intermodes
Minimum Error
Minimum Error
Minimum
Minimum
Moments
Moments
Otsu
Otsu
Polysegment
Polysegment
Rosin
Rosin
Sauvola
Sauvola
Niblack
Niblack
Adaptive
Adaptive
Yen
Yen
Balanced
Balanced
Image of text:
Original image
Original image
Intermodes
Intermodes
Minimum Error
Minimum Error
Minimum
Minimum
Moments
Moments
Otsu
Otsu
Polysegment
Polysegment
Rosin
Rosin
Sauvola
Sauvola
Niblack
Niblack
Adaptive
Adaptive
yen
Yen
Balanced
Balanced