जब बैकग्राउंड इतना स्पष्ट न हो
कभी-कभी बैकग्राउंड पहचानना इतना आसान नहीं होता. अगर इमेज का बैकग्राउंड काफ़ी एक-सा है, तो आप पहले की तरह threshold_otsu() का उपयोग करके एक global threshold वैल्यू ले सकते हैं. लेकिन अगर बैकग्राउंड की रोशनी असमान है, तो adaptive thresholding threshold_local() (यानी local thresholding) बेहतर नतीजे दे सकता है.
इस अभ्यास में, आप दोनों तरह की thresholding विधियों (global और local) की तुलना करेंगे, ताकि हमें ज़रूरी binary इमेज पाने का सबसे अच्छा तरीका मिल सके.
Image
page_image के रूप में लोड की गई है.
यह अभ्यास पाठ्यक्रम का हिस्सा है
Python में इमेज प्रोसेसिंग
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# 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')