opencv hsv
时间: 2023-09-27 15:06:01 浏览: 100
HSV (Hue, Saturation, Value) is a color space commonly used in computer vision and image processing tasks, including those performed with the OpenCV library.
In OpenCV, you can convert an image from the default BGR (Blue, Green, Red) color space to HSV using the cv2.cvtColor() function. Here's an example:
```python
import cv2
import numpy as np
# Load an image
image = cv2.imread('image.jpg')
# Convert BGR to HSV
hsv_image = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
# Display the original and HSV images
cv2.imshow('Original', image)
cv2.imshow('HSV', hsv_image)
cv2.waitKey(0)
cv2.destroyAllWindows()
```
In this example, we load an image using `cv2.imread()` and then convert it to the HSV color space using `cv2.cvtColor()` with the `cv2.COLOR_BGR2HSV` flag. Finally, we display both the original and HSV images using `cv2.imshow()`,
阅读全文
相关推荐
















