Getting error: OpenCV(3.4.3) /io/opencv/modules/imgproc/src/color.hpp:257 error

asked 2019-10-21 01:42:26 -0500

Sandeep Kumar gravatar image

updated 2019-10-21 02:30:20 -0500

berak gravatar image

Hi, I tried to find the LBP on Hyperspectral Image after computing first 3 Principal Component Analysis. I am getting the following error.

error Traceback (most recent call last)
in ()
1 img_bgr=pcdata
----> 2 img_gray = cv2.cvtColor(img_bgr, cv2.COLOR_BGR2GRAY)

error: OpenCV(3.4.3) /io/opencv/modules/imgproc/src/color.hpp:257: error: (-2:Unspecified error) in function 'cv::CvtHelper<VScn, VDcn, VDepth, sizePolicy>::CvtHelper(cv::InputArray, cv::OutputArray, int) [with VScn = cv::Set<3, 4>; VDcn = cv::Set<1>; VDepth = cv::Set<0, 2, 5>; cv::SizePolicy sizePolicy = (cv::SizePolicy)2u; cv::InputArray = const cv::_InputArray&; cv::OutputArray = const cv::_OutputArray&]'

Unsupported depth of input image:
'VDepth::contains(depth)'

where

'depth' is 6 (CV_64F)
edit retag flag offensive close merge delete

Comments

1

1 img_bgr=pcdata ----> 2 img_gray = cv2.cvtColor(img_bgr, cv2.COLOR_BGR2GRAY)

this does not make any sense to me. why is it there ?

berak gravatar imageberak ( 2019-10-21 02:24:35 -0500 )edit
1

after computing first 3 Principal Component Analysis

we probably need to see, what your pcadata is, and how it got derived.

at least, there's no PCA here

berak gravatar imageberak ( 2019-10-21 02:25:36 -0500 )edit
1

I tried the LBP code in Google colab. I applied it to Hyperspectral image which is of dimension 145x145x200. I reduced it to 3 principal component bands by applying PCA resulting in dimension 145x145x3 and stored it in pcdata numpy array. This is given below.

hsi_data=sio.loadmat("Indian_pines_corrected.mat")['indian_pines_corrected']
pc = principal_components(hsi_data)
pcdata = pc.reduce(num=3).transform(hsi_data)

Copy lbp.py from https://github.com/arsho/local_binary... In img_gray = cv2.cvtColor(img_bgr, cv2.COLOR_BGR2GRAY) line of main function I am getting the error.

Sandeep Kumar gravatar imageSandeep Kumar ( 2019-10-21 05:54:56 -0500 )edit
Sandeep Kumar gravatar imageSandeep Kumar ( 2019-10-21 06:01:51 -0500 )edit
1

could you try to update your question with the code, so it is in context, and maybe we can try to reproduce it ?

also, please try to print out shapes / types after relevant operations

berak gravatar imageberak ( 2019-10-21 06:11:30 -0500 )edit

Comment box is not sufficient for pasting the code. How can I share the code in .ipynb format to you. I am new to this forum.

Sandeep Kumar gravatar imageSandeep Kumar ( 2019-10-21 20:38:44 -0500 )edit
1

no, unfortunately you cannot share an .ipynb here, theres nothing to run it.

berak gravatar imageberak ( 2019-10-22 00:50:57 -0500 )edit

cvtColor(img_bgr,COLOR_BGR2GRAY);

with latest master you get the correct information:

> Unsupported depth of input image:
>     'VDepth::contains(depth)'
> where
>     'depth' is 6 (CV_64F)

i also doubt, that this is the correct way to apply LBP to your 3 component pca output.

berak gravatar imageberak ( 2019-10-22 01:26:55 -0500 )edit
1

Please find the code in this link. https://colab.research.google.com/dri...

Sandeep Kumar gravatar imageSandeep Kumar ( 2019-10-22 12:08:14 -0500 )edit

Hi berak, I am not getting any error and able to execute by modifying the code as below

img_bgr=pcdata.astype(dtype=np.uint8)
height, width, channel = img_bgr.shape
img_gray = cv2.cvtColor(img_bgr,cv2.COLOR_BGR2GRAY)

But how far the use of unsigned int is correct in PCA result I don't know. Can you check this.

Sandeep Kumar gravatar imageSandeep Kumar ( 2019-10-22 20:40:05 -0500 )edit