Thresholding adalah proses mengubah citra berderajat keabuan menjadi citra biner atau hitam putih sehingga dapat diketahui daerah mana yang termasuk obyek dan background dari citra secara jelas. Citra hasil thresholding biasanya digunakan lebih lanjut untuk proses pengenalan obyek serta ekstraksi fitur. Fungsi yang digunakan adalah cv2.threshold . Yang pertama kita lakukan adalah sumber gambar yang akan diubah menjadi gambar grayscale. Kedua adalah nilai ambang (threshold) yang digunakan untuk mengklasifikasikan nilai-nilai pixel. Ketiga adalah maxVal yang mewakili nilai yang akan diberikan jika nilai piksel lebih dari atau kurang dari nilai ambang. Python | Thresholding techniques using OpenCV | Set-1 (Simple Thresholding) Improve Article Save Article Like Article
Improve Article Save Article Thresholding is a technique in OpenCV, which is the assignment of pixel values in relation to the threshold value provided. In thresholding, each pixel value is compared with the threshold value. If the pixel value is smaller than the threshold, it is set to 0, otherwise, it is set to a maximum value (generally 255). Thresholding is a very popular segmentation technique, used for separating an object considered as a foreground from its background. A threshold is a value which has two regions on its either side i.e. below the threshold or above the threshold. If f (x, y) < T then f (x, y) = 0 else f (x, y) = 255 where f (x, y) = Coordinate Pixel Value T = Threshold Value. In OpenCV with Python, the function cv2.threshold is used for thresholding.
Simple ThresholdingThe basic Thresholding technique is Binary Thresholding. For every pixel, the same threshold value is applied. If the pixel value is smaller than the threshold, it is set to 0, otherwise, it is set to a maximum value.
Below is the Python code explaining different Simple Thresholding Techniques – Python3
Input: Output:
My Personal Notes arrow_drop_up Save Please Login to comment... |