Enhancing RGB Tile Contrast#202
Merged
PatBall1 merged 19 commits intoOct 15, 2025
Merged
Conversation
Collaborator
Author
|
Will be marked as ready for review after more testing. |
03b68a3 to
1aad275
Compare
Collaborator
Author
|
Many problems are arising with dependency issues and module version mismatch in the GitHub actions. MyPy was raising errors that I was not able to replicate on my system with the same version numbers. I was able to fix them via commit fix -> overvation -> commit fix -> etc. But for this pull request: All tested, everything works as it should. |
Sphinx fixes and tutorial updates Jb/sept25
CiSong10
pushed a commit
to CiSong10/detectree2
that referenced
this pull request
Oct 15, 2025
This pull request enhances the image preprocessing capabilities in detectree2/preprocessing/tiling.py by introducing an optional RGB contrast enhancement feature and fixing some inconsistencies with return values across the tiling functions.
CiSong10
pushed a commit
to CiSong10/detectree2
that referenced
this pull request
Nov 20, 2025
This pull request enhances the image preprocessing capabilities in detectree2/preprocessing/tiling.py by introducing an optional RGB contrast enhancement feature and fixing some inconsistencies with return values across the tiling functions.
CiSong10
pushed a commit
to CiSong10/detectree2
that referenced
this pull request
Nov 20, 2025
This pull request enhances the image preprocessing capabilities in detectree2/preprocessing/tiling.py by introducing an optional RGB contrast enhancement feature and fixing some inconsistencies with return values across the tiling functions.
TeddyLiang01
pushed a commit
to TeddyLiang01/detectree2
that referenced
this pull request
Nov 26, 2025
This pull request enhances the image preprocessing capabilities in detectree2/preprocessing/tiling.py by introducing an optional RGB contrast enhancement feature and fixing some inconsistencies with return values across the tiling functions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This pull request enhances the image preprocessing capabilities in
detectree2/preprocessing/tiling.pyby introducing an optional RGB contrast enhancement feature and fixing some inconsistencies with return values across the tiling functions.Changes
RGB Contrast Enhancement
I've added an
enhance_rgb_contrastparameter to theprocess_tile,process_tile_train, andtile_datafunctions. When this feature is enabled, the system rescales RGB pixel values from their original distribution to a 1-255 range, reserving 0 for nodata values. The contrast enhancement uses percentile-based rescaling (0.2% to 99.8%) to increase RGB diversity, which significantly improves the accuracy of jungle crown delineations.Context Manager Fix
There was also a resource handling issue I discovered where functions were returning a
dataobject from within a context manager (with rasterio.open(img_path) as data:), which could lead to problems down the line. I've fixed this by having the functions return only theout_transformfrom the data object, since that's all the calling methods actually need anyway. This change affectsprocess_tile,process_tile_ms, andprocess_tile_trainfunctions.Minor Adjustments
Additionally, I made a small adjustment to the convex mask precision by reducing the buffer size from 5 to 3 for the convex delineation mask. This value is still large enough to be effective while avoiding too much inclusion of nearby tree crowns.
Future Considerations
I'll admit the function signatures are getting pretty parameter-heavy with these additions. I'm planning a follow-up pull request in the near future to refactor and clean up these function interfaces, but the current implementation is still manageable for now.
Compatibility
Existing workflows will work exactly as before. The parameter
enhance_rgb_contrastdefaults totrue, allowing for immediate performance gains if the data is re-tiled.