Ask Your Question
0

got error while converting HSV2BGR

asked 2019-09-20 13:32:50 -0600

Samjith888 gravatar image

updated 2019-09-20 13:36:32 -0600

Below is the code i wrote.

> import cv2 
> import numpy as np
> image = cv2.imread('67.png')
> cv2.imshow('original', image) hsv =
> cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
> hsv=  hsv[:, :, 1] n1=
> np.where(np.logical_and(80<=hsv,
> hsv<=180), 255, hsv) res =
> cv2.cvtColor(n1, cv2.COLOR_HSV2BGR)
> cv2.imshow('result', res)
> cv2.waitKey(0)

Got following error

cv2.error: OpenCV(4.1.0) c:\projects\opencv-python\opencv\modules\imgproc\src\color.simd_helpers.hpp:92: error: (-2:Unspecified error) in function '__cdecl cv::impl::anonymous-namespace'::CvtHelper<struct cv::impl::anonymous namespace'::Set<3,-1,-1>,struct cv::impl::A0x3b52564f::Set<3,4,-1>,struct cv::impl::A0x3b52564f::Set<0,5,-1>,2>::CvtHelper(const class cv::_InputArray &,const class cv::_OutputArray &,int)'

Invalid number of channels in input image: 'VScn::contains(scn)' where 'scn' is 1

I have found the issue can be solve by using img = np.array(img, dtype=np.uint8) . But its not working. Any help will be appreciated

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
0

answered 2019-09-20 14:02:50 -0600

LBerger gravatar image

updated 2019-09-20 14:27:07 -0600

Check image depth. 67.png or n1 one is a grayscale image ->

Invalid number of channels in input image: 'VScn::contains(scn)' where 'scn' is 1

edit flag offensive delete link more

Comments

No.. Its a RGB image.. and then iI converted it into hsv. After some processing , again I’m trying to convert the hsv into rgb.. hence i got the error

Samjith888 gravatar imageSamjith888 ( 2019-09-20 14:13:41 -0600 )edit

Yes.. n1 image is grayscale.

Samjith888 gravatar imageSamjith888 ( 2019-09-21 01:09:43 -0600 )edit

you have to execute because of its size img = np.full((512,512,3), 12, np.uint8)

Dhurub gravatar imageDhurub ( 2020-01-22 03:21:24 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2019-09-20 13:32:50 -0600

Seen: 12,525 times

Last updated: Sep 20 '19