- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
Performing white BlackHat operation on images using OpenCV
In this program, we will perform the Blackhat operation on an image using OpenCV. BlackHat transform is used to enhance dark objects of interest in a bright background. We will use the morphologyEx(image, cv2.MORPH_BLACKHAT, kernel) function.
Original Image
Algorithm
Step 1: Import cv2. Step 2: Read the image. Step 3: Define the kernel size. Step 4: Pass the image and kernel to the cv2.morphologyex() function. Step 5: Display the output.
Example Code
import cv2 image = cv2.imread('image_test.jpg') filter_size = (5,5) kernel = cv2.getStructuringElement(cv2.MORPH_RECT, filter_size) image = cv2.morphologyEx(image, cv2.MORPH_BLACKHAT, kernel) cv2.imshow('BlackHat', image)
Output
Advertisements