MulaiMulai sekarang secara gratis

When the background isn't that obvious

Sometimes, it isn't that obvious to identify the background. If the image background is relatively uniform, then you can use a global threshold value as we practiced before, using threshold_otsu(). However, if there's uneven background illumination, adaptive thresholding threshold_local() (a.k.a. local thresholding) may produce better results.

In this exercise, you will compare both types of thresholding methods (global and local), to find the optimal way to obtain the binary image we need.

Page with text
Image loaded as page_image.

Latihan ini adalah bagian dari kursus

Image Processing in Python

Lihat Kursus

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Import the otsu threshold function
from skimage.____ import ____

# Obtain the optimal otsu global thresh value
global_thresh = ____(page_image)

# Obtain the binary image by applying global thresholding
binary_global = page_image ____ ____

# Show the binary image obtained
show_image(binary_global, 'Global thresholding')
Edit dan Jalankan Kode