Skip to content

Fix incorrect visualization of thresholded grayscale images#16

Open
mrajaeim wants to merge 1 commit intoAlireza-Akhavan:masterfrom
mrajaeim:master
Open

Fix incorrect visualization of thresholded grayscale images#16
mrajaeim wants to merge 1 commit intoAlireza-Akhavan:masterfrom
mrajaeim:master

Conversation

@mrajaeim
Copy link

@mrajaeim mrajaeim commented Feb 5, 2026

Thresholding outputs from OpenCV were being displayed using Matplotlib’s default normalization. This caused misleading visuals because intensity ranges (e.g., 0–127 after THRESH_TRUNC) were stretched to 0–255 during display.

Root Cause:

plt.imshow() automatically rescales image intensity when vmin and vmax are not specified.

Solution:

All grayscale visualizations now explicitly use:

vmin=0, vmax=255

This ensures the displayed images accurately reflect true pixel intensities from OpenCV.

Prev:

image

After

image

Matplotlib was auto-normalizing grayscale images, causing incorrect
visual interpretation of thresholding results (especially THRESH_TRUNC).

Added explicit vmin=0 and vmax=255 to all imshow calls to ensure
pixel intensities are displayed using the true 8-bit grayscale range.
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.

1 participant