OpenCV Tutorial
Image Processing
Feature Detection and Description
Drawing Functions
Video Processing
Applications and Projects
In computer vision, especially when working with color images, there are situations where you'd want to open multiple windows to visualize different color channels or processed images. Here, I'll guide you on how to open multiple color windows using OpenCV.
pip install opencv-python
import cv2 import numpy as np
image = cv2.imread('path_to_image.jpg')
blue, green, red = cv2.split(image)
cv2.imshow('Blue Channel', blue) cv2.imshow('Green Channel', green) cv2.imshow('Red Channel', red)
# For blue blue_in_color = cv2.merge([blue, np.zeros_like(blue), np.zeros_like(blue)]) cv2.imshow('Blue in Color', blue_in_color) # Similarly, you can create for green and red channels
cv2.waitKey(0) cv2.destroyAllWindows()
By opening multiple color windows in OpenCV, you can effectively analyze the contribution of each color channel in an image. This is particularly useful when performing color-based segmentation or when you want to understand the color distribution in an image.
Displaying multiple images in separate windows with OpenCV:
import cv2 # Read images image1 = cv2.imread('image1.jpg') image2 = cv2.imread('image2.jpg') # Display images in separate windows cv2.imshow('Image 1', image1) cv2.imshow('Image 2', image2) cv2.waitKey(0) cv2.destroyAllWindows()
OpenCV namedWindow function for multiple windows:
namedWindow
function for creating named windows and associating images with specific windows.cv2.namedWindow('Image 1', cv2.WINDOW_NORMAL) cv2.imshow('Image 1', image1) cv2.namedWindow('Image 2', cv2.WINDOW_NORMAL) cv2.imshow('Image 2', image2)