How to calculate disparity, using imgL and imgR in the CMYK system?

Reading image as RGB and converting them to CMYK resulted in a better color definition to identify markers attached to an actuator. As you can see them in magenta, in the CMYK image attached.

Now, they must be sterilized to calculate disparity, as in:

stereo = cv.StereoBM_create(numDisparities=16, blockSize=15)
disparity = stereo.compute(CMYK_L, CMYK_R)

However, the following error occurs:

error: OpenCV(4.7.0) /io/opencv/modules/calib3d/src/stereobm.cpp:1173: error: (-210:Unsupported format or combination of formats) Both input images must have CV_8UC1 in function ‘compute’

I assumed the error’s because CMYK has a fourth dimension (i.e. K), causing calculations to break.

How can images be converted from CMYK to grayscale directly? (so that I could reuse stereo.compute()

Should I use another color system? or even better, does stereo.compute() support CMYK system?

Converting them back to RGB is not am option/solution. Because markers get lost when the image is converted from RGB to grayscale.

Markers get similar gray as the scenario, making it hard, to any openCV lib or segmentation algorithm such as Cany, to track marker’s coordinates (x,y) accurately.

Do I need to convert them to another system? which one?

Screen Shot 2023-03-25 at 11.08.44 PM

error: OpenCV(4.7.0) /io/opencv/modules/calib3d/src/stereobm.cpp:1173: error: (-210:Unsupported format or combination of formats) Both input images must have CV_8UC1 in function ‘compute’

Hi
Have you try to use stereo compute on gray image and get disparity map inside your marker?
May be you can convert you best image in gray scale to get visible marker using cvtColor with a wrong colorspace

If it does not work may be you can use triangulatePoints?