2
votes
  • I have a function in python which takes in RGB values and converts them HSV values.
  • Now I would want to write the Hue component, Value component and Saturation component of this image into separate images.
  • How to write these images using opencv.

  • I know that cv2.imwrite takes in a 3D array and considers this to be an image in the RGB colour space.
  • How to tell opencv that it should consider the HSV colour space and not RGB
1
simply write the resultant Mat which is in HSV color space to file using imwrite.Balaji R

1 Answers

5
votes

I would want to write the Hue component, Value component and Saturation component of this image into separate images.

cv2.imwrite() actually can write 2D arrays as well.

So, since you already have a 3D HSV array, you can just use something like:

cv2.imwrite('hue.png', img[:,:,0])
cv2.imwrite('sat.png', img[:,:,1])
cv2.imwrite('val.png', img[:,:,2])

To split them and write the three components as three images.