Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v2][Feature] Improve CropPage pre-processor using colored images #212

Open
Udayraj123 opened this issue Sep 15, 2024 · 4 comments
Open
Assignees

Comments

@Udayraj123
Copy link
Owner

Udayraj123 commented Sep 15, 2024

Is your feature request related to a problem? Please describe.
Previously, OMRChecker used to read all images in grayscale. But since we're supporting colored inputs and outputs in the v2 release, it is time to improve the CropPage pre-processor to work on lighter colored backgrounds (see photos below). Currently, for images with light colored backgrounds e.g. light yellow backgrounds - after normalisation(cv2.normalize), the page boundary doesn't seem to get detected at all.

Describe the solution you'd like
We can introduce a flag in CropPage.tuningOptions{} to conditionally use cv2.Canny on the colored image instead of the grayscale image. This should help us find edges in the cases where background is not white but light colored (near-white in grayscale).

Describe alternatives you've considered
N/A

Additional context
Sample image where the grayscale calculation fails:
image

Debug outputs:
image
image

Note: please share your queries and approaches on discord for quicker discussions:

@Prasadayus
Copy link

My approach to solution:
Adjust Color Thresholding: We will implement adaptive or dynamic thresholding techniques tailored for lighter backgrounds. Instead of global thresholds, we will use adaptive thresholding (e.g., cv2.adaptiveThreshold), which calculates thresholds based on local neighborhoods. This would help distinguish light colors from the background effectively.

Background Subtraction: We will consider adding a preprocessing step to subtract or neutralize the background color. By estimating the average background color (e.g., light yellow), we could remove or normalize the background color before further processing.

Edge Detection Tuning: Lastly we can use canny edge detection with parameters that are adjusted dynamically based on the brightness or saturation levels of the image. This could help detect boundaries more effectively on lighter backgrounds.

@Udayraj123 If you like this approach then plz assign me this issue

@Udayraj123
Copy link
Owner Author

Cool @Prasadayus, assigning this to you. Do ask your queries if any.

@Prasadayus
Copy link

Sir how to check if my solution is running right or wrong means on which sample I have to test ?

@Udayraj123
Copy link
Owner Author

Hey @Prasadayus, for this task you will need to create a new sample image similar to the one shown in the issue description. Any OMR paper image on a light background like the yellow one would become overly bright and loose its edges, you can share a few samples like that and maybe we can pre-process it such that it fails for the current CropPage.

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

No branches or pull requests

2 participants