Skip to content

Added the histogram equalization operator#72

Open
AbhaBarge wants to merge 2 commits intoc2siorg:mainfrom
AbhaBarge:feature/histogram_equalization
Open

Added the histogram equalization operator#72
AbhaBarge wants to merge 2 commits intoc2siorg:mainfrom
AbhaBarge:feature/histogram_equalization

Conversation

@AbhaBarge
Copy link
Copy Markdown

Description

Implemented the Histogram Equalization operator for both backend and frontend.

On the backend, a new HistogramEqualization operator was added under the conversions module, following the existing BaseOperator pattern. The operator applies cv2.equalizeHist() for grayscale images and, for color images, performs equalization on the luminance (Y) channel in YCrCb space to preserve color fidelity. It requires no parameters and has been registered in registry.py to integrate with the processing pipeline.

On the frontend, a corresponding Blockly block was added under the Conversions category with no parameter fields, fully integrated into the existing pipeline flow.

The implementation has been validated using standard and low-contrast grayscale and color images, confirming improved contrast and compatibility with downstream operators.

Fixes #41

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

How Has This Been Tested?

Describe the tests you ran to verify your changes.

  • Existing tests pass
  • New tests added
  • Manual testing

Screenshots (if applicable)

Screenshot 2026-02-26 at 11 05 39 AM Screenshot 2026-02-26 at 11 07 38 AM Screenshot 2026-02-26 at 11 15 14 AM Screenshot 2026-02-26 at 11 23 35 AM

Checklist

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

@AbhaBarge
Copy link
Copy Markdown
Author

@ivantha I’ve implemented the Histogram Equalization operator as discussed in issue #41. The backend and frontend changes have been completed and validated locally.

Please let me know if any improvements or additions are required.

It appears that merging is currently blocked due to required Code Scanning checks not running for this PR. Kindly let me know if any action is needed from my side.

Copy link
Copy Markdown
Member

@ivantha ivantha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm 👍🏼 Please rebase the PR to merge.

@AbhaBarge
Copy link
Copy Markdown
Author

Rebased onto the latest main. The branch is up to date and ready for merge. Please let me know if anything else is required. Thanks !

@ivantha
Copy link
Copy Markdown
Member

ivantha commented Feb 27, 2026

@AbhaBarge, looks like we have conflicts due to the earlier PRs that were merged. Could you please rebase once again? Thanks

@AbhaBarge
Copy link
Copy Markdown
Author

Hi @ivantha I've rebased again onto the latest main. The branch is now ready for merge. Please let me know if anything else is required. Thanks !

@ivantha
Copy link
Copy Markdown
Member

ivantha commented Mar 3, 2026

I am still seeing conflicts.

Copy link
Copy Markdown
Member

@ivantha ivantha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

◎ Argus Review

This PR adds a Histogram Equalization operator to the backend (Python/OpenCV) and a corresponding Blockly block on the frontend. The backend implementation is mostly sound and follows existing patterns, but contains a potential runtime crash for non-uint8 images and silent failure for unsupported channel counts. More critically, the frontend changes contain multiple syntax errors — a missing comma in categories.ts and duplicate tooltip properties (plus a missing comma) in conversions.blocks.ts — that will prevent the frontend from compiling. These bugs appear to stem from a bad cut/paste operation when inserting the new block definition. No automated tests were added for the new operator.

Comment thread imagelab-frontend/src/blocks/categories.ts Outdated
Comment thread imagelab-frontend/src/blocks/definitions/conversions.blocks.ts
Comment thread imagelab-backend/app/operators/conversions/histogram_equalization.py Outdated
Comment thread imagelab-backend/app/operators/conversions/histogram_equalization.py Outdated
Comment thread imagelab-backend/app/operators/conversions/__init__.py Outdated
Comment thread imagelab-backend/app/operators/conversions/histogram_equalization.py Outdated
Comment thread imagelab-backend/app/operators/registry.py Outdated
@AbhaBarge
Copy link
Copy Markdown
Author

Screenshot_20260304-095158 Rebased

@AbhaBarge
Copy link
Copy Markdown
Author

@ivantha I’ve rebased the branch on the latest main, resolved merge conflicts, and addressed the backend and frontend lint issues. The workflows appear to be awaiting maintainer approval. Please approve.
Thank you !

@ivantha
Copy link
Copy Markdown
Member

ivantha commented Mar 11, 2026

Please fix lint errors.

@ivantha
Copy link
Copy Markdown
Member

ivantha commented Mar 11, 2026

@AbhaBarge and sqush all the commits into one.
Lint is still failing btw.

@AbhaBarge AbhaBarge force-pushed the feature/histogram_equalization branch from 9e4600c to 5c7efd1 Compare March 11, 2026 17:57
@AbhaBarge
Copy link
Copy Markdown
Author

@AbhaBarge and sqush all the commits into one. Lint is still failing btw.

@ivantha I got the issue. Locally I was only running the Ruff lint checks and hadn’t verified the formatting step (ruff format --check), which is enforced in CI. I’ve now reformatted the two affected files and pushed the changes.
I've also squashed all commits into 1.

Apologies for the oversight. The linting and formatting issues should now be resolved. Please let me know if anything else needs attention.

@ivantha ivantha closed this Mar 17, 2026
@ivantha ivantha reopened this Mar 17, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 17, 2026

PR Review

Rebase

Merge commits detected — please use rebase instead of merge:

5246ce8 Merge branch 'main' into feature/histogram_equalization

Squash

Your PR has 2 commits. Please squash into a single commit.

How to fix

git fetch origin
git rebase -i origin/main   # mark all but first commit as "squash"
git push --force-with-lease

This comment updates automatically on each push.

@AbhaBarge AbhaBarge force-pushed the feature/histogram_equalization branch from e83553a to 2bafa4b Compare March 18, 2026 04:04
@AbhaBarge
Copy link
Copy Markdown
Author

@ivantha Please check. All the issues have been resolved now. I apologise for the immense delay. Thank you for your patience, I learnt a lot while working on this single PR !
image

@ivantha
Copy link
Copy Markdown
Member

ivantha commented Apr 13, 2026

Reviewed. Adds a HistogramEqualization operator (grayscale via equalizeHist, color via Y-channel in YCrCb) wired through the backend registry and a Blockly block in the Conversions category. PR also includes some incidental changes (kernelSize validation on morphological, formatting tweaks in color.py, shortened colortobinary tooltip) which overlap slightly with other in-flight PRs but are benign. Merging via rebase.

@ivantha
Copy link
Copy Markdown
Member

ivantha commented Apr 13, 2026

Attempted rebase-merge but GitHub reports the branch can't be rebased cleanly (likely because of non-linear history or a merge commit on the PR branch). Could you rebase this branch onto the latest main locally and force-push? I'll re-attempt the merge afterward.

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.

Add Histogram Equalization Operator

2 participants