- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is hysteresis thresholding? How can it be achieved using scikit-learn in Python?
Hysteresis refers to the lagging effect of a result. With respect to threshold, hysteresis refers to the areas that are above a specific low threshold value or above high threshold values. It refers to areas that are highly-confident in nature.
With the help of hysteresis, the noise outside the edges of the object in the image can be ignored.
Let us see how hysteresis threshold can be achieved using scikit-learn library:
Example
import matplotlib.pyplot as plt from skimage import data, filters fig, ax = plt.subplots(nrows=2, ncols=2) orig_img = data.coins() edges = filters.sobel(orig_img) low = 0.1 high = 0.4 lowt = (edges > low).astype(int) hight = (edges > high).astype(int) hyst = filters.apply_hysteresis_threshold(edges, low, high) ax[0, 0].imshow(orig_img, cmap='gray') ax[0, 0].set_title('Original image') ax[0, 1].imshow(edges, cmap='magma') ax[0, 1].set_title('Sobel edges') ax[1, 0].imshow(lowt, cmap='magma') ax[1, 0].set_title('Low threshold') ax[1, 1].imshow(hight + hyst, cmap='magma') ax[1, 1].set_title('Hysteresis threshold') for a in ax.ravel(): a.axis('off') plt.tight_layout() plt.show()
Output
Explanation
The required libraries are imported.
The subplot function is used to set the plot area before plotting the images on the console.
The ‘coin’ data already present in scikit-learn package is used as input.
The ‘sobel’ filter is used to get the ‘sobel’ image of the input, wherein the edges are emphasized in the resultant image
The function ‘apply_hysteresis_threshold’ is used to get values above and below a certain threshold.
This data is displayed on the console using the function ‘imshow’.
- Related Articles
- How can data be scaled using scikit-learn library in Python?
- Explain how L1 Normalization can be implemented using scikit-learn library in Python?
- Explain how L2 Normalization can be implemented using scikit-learn library in Python?
- How can scikit-learn library be used to load data in Python?
- How can scikit learn library be used to preprocess data in Python?
- How can a specific tint be added to grayscale images in scikit-learn in Python?
- How can scikit learn library be used to upload and view an image in Python?
- How to binarize the data using Python Scikit-learn?
- How to implement Random Projection using Python Scikit-learn?
- How to perform dimensionality reduction using Python Scikit-learn?
- Finding Euclidean distance using Scikit-Learn in Python
- How can scikit-learn be used to convert an image from RGB to grayscale in Python?
- How can scikit-learn library be used to get the resolution of an image in Python?
- How to create a sample dataset using Python Scikit-learn?
- How to generate random regression problems using Python Scikit-learn?
