Skip to content

fix(conversions): convert BGR/BGRA to gray before thresholding in GrayToBinary#321

Open
Jayant-kernel wants to merge 1 commit intoc2siorg:mainfrom
Jayant-kernel:fix/graytobinary-color-input
Open

fix(conversions): convert BGR/BGRA to gray before thresholding in GrayToBinary#321
Jayant-kernel wants to merge 1 commit intoc2siorg:mainfrom
Jayant-kernel:fix/graytobinary-color-input

Conversation

@Jayant-kernel
Copy link
Copy Markdown
Contributor

Description

Fixes GrayToBinary silently producing a 3-channel output when given a colour (BGR or BGRA) image instead of a grayscale one.

Previously, cv2.threshold ran on each colour channel independently, producing a 3-channel result that was incorrectly labelled as binary. Now the operator converts BGR/BGRA input to grayscale first — consistent with how ColorToBinary handles the same case.

Fixes #319

Type of Change

  • Bug fix

How Has This Been Tested?

  • New tests added — tests/operators/conversions/test_gray_to_binary.py
    • grayscale input works as before
    • BGR input is converted to gray before thresholding (single-channel output)
    • BGRA input is converted to gray before thresholding (single-channel output)
    • default params produce correct binary output
  • Existing tests pass

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review
  • My changes generate no new warnings
  • Tests pass locally

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] GrayToBinary silently produces wrong output when given a color (BGR/BGRA) image

1 participant