You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The GrayToBinary operator assumes its input is already a single-channel grayscale image, but performs no validation or conversion. When a user connects any BGR or BGRA-output block directly to GrayToBinary, OpenCV's cv2.threshold runs independently on each channel, producing a 3-channel output instead of a true binary grayscale image.
Steps to Reproduce
importcv2, numpyasnpfromapp.operators.conversions.gray_to_binaryimportGrayToBinary# Simulates a BGR image coming from any color operatorimg_bgr=np.array([[[50, 150, 200]]], dtype=np.uint8)
result=GrayToBinary({"thresholdValue": 100, "maxValue": 255}).compute(img_bgr)
print(result.shape) # (1, 1, 3) — NOT a binary grayscale imageprint(result) # [[[ 0 255 255]]] — each channel thresholded independently
Expected Behaviour
GrayToBinary should either:
Raise a ValueError with a clear message if the input is not single-channel (guiding the user to insert GrayImage first), or
Convert BGR/BGRA to grayscale before thresholding (like ColorToBinary does)
Actual Behaviour
Silently thresholds each colour channel independently, returning a 3-channel array. The block name implies a binary (single-channel) output but the output is a 3-channel image with per-channel thresholding applied — incorrect and misleading.
Context
ColorToBinary correctly converts to grayscale before thresholding.
GrayToBinary is intended for images already in grayscale, but the pipeline UI does not prevent connecting a colour-output block to it.
Description
The
GrayToBinaryoperator assumes its input is already a single-channel grayscale image, but performs no validation or conversion. When a user connects any BGR or BGRA-output block directly toGrayToBinary, OpenCV'scv2.thresholdruns independently on each channel, producing a 3-channel output instead of a true binary grayscale image.Steps to Reproduce
Expected Behaviour
GrayToBinaryshould either:ValueErrorwith a clear message if the input is not single-channel (guiding the user to insertGrayImagefirst), orColorToBinarydoes)Actual Behaviour
Silently thresholds each colour channel independently, returning a 3-channel array. The block name implies a binary (single-channel) output but the output is a 3-channel image with per-channel thresholding applied — incorrect and misleading.
Context
ColorToBinarycorrectly converts to grayscale before thresholding.GrayToBinaryis intended for images already in grayscale, but the pipeline UI does not prevent connecting a colour-output block to it.