Qu

imbothat

Builtin index · Images

result = imbothat(img, radius) <br> imbothat(img, se=)

Input: img, radius · Output: result

What it is

img is a binary Image; radius is a positive integer. Bottom-hat: imclose(img, radius) - img, extracts small dark features / corrects a slowly-varying dark background.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = imbothat(img, radius) <br> imbothat(img, se=)
img Imageimg is a binary Image.
radius —radius is a positive integer.
result Image
Returns a new Image, same dimensions. (imtophat, the bright-feature dual, is its sibling arm, documented below.) Same additive se= kwarg as imdilate above, added in v0.4.0.

Examples

From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.

m = [0, 0, 0, 0, 0, 0; 0, 255, 255, 0, 255, 0; 0, 255, 255, 0, 0, 0; 0, 0, 0, 0, 0, 0; 0, 255, 0, 0, 255, 255; 0, 0, 0, 0, 255, 255]
img = image_from_matrix(m)
imshow(img)

eroded = imerode(img, 1)
dilated = imdilate(img, 1)
opened = imopen(img, 1)                # drops the lone speck

closed = imclose(img, 1)               # fills small gaps

bright = imtophat(img, 1)              # small bright features

dark = imbothat(img, 1)                # small dark features

imshow(opened)
print(eroded.width, dilated.width, opened.width, closed.width, bright.width, dark.width)
output
6 6 6 6 6 6
a synthetic field with one bright patch

from images

How it works

imtophat(img, radius) (original minus opening — extracts small bright features / corrects a slowly-varying bright background; the primary foreground/background separation mechanism beyond a plain threshold) / imbothat(img, radius) (closing minus original — the dark-feature dual). Same additive se= kwarg as imerode/imdilate above.

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.