mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-04 03:53:26 +08:00
Add threshold minimum algorithm
This commit is contained in:
committed by
François Boulogne
parent
71456ed672
commit
31db1c607e
@@ -0,0 +1,37 @@
|
||||
"""
|
||||
==================================
|
||||
Minimum Algorithm For Thresholding
|
||||
==================================
|
||||
|
||||
The minimum algorithm takes a histogram of the image and smooths it
|
||||
repeatedly unitl there are only two peaks in the histogram. Then it
|
||||
finds the minimum value between the two peaks. With the smoothing
|
||||
there can be multiple pixel values with the minimum histogram count,
|
||||
so you can pick 'min', 'mid', or 'max' of these values.
|
||||
|
||||
"""
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
from skimage import data
|
||||
from skimage.filters.thresholding import threshold_minimum
|
||||
|
||||
image = data.camera()
|
||||
|
||||
threshold = threshold_minimum(image, bias='min')
|
||||
|
||||
binarized = image > threshold
|
||||
|
||||
fig, axes = plt.subplots(nrows=2, figsize=(7, 8))
|
||||
ax0, ax1 = axes
|
||||
plt.gray()
|
||||
|
||||
ax0.imshow(image)
|
||||
ax0.set_title('Image')
|
||||
|
||||
ax1.imshow(binarized)
|
||||
ax1.set_title('Thresholded')
|
||||
|
||||
for ax in axes:
|
||||
ax.axis('off')
|
||||
|
||||
plt.show()
|
||||
Reference in New Issue
Block a user