Update ndwi_labels.py , add comments and blurring function(Optional) - #26
Merged
Conversation
Enhance the code. Write Comments. Apply Gaussian filtering if we want.
# Apply majority number of Windows:
**Buffer Matrix :**
- Same shape as original image.
- The buffer matrix is a matrix where each element represents the number of times a sliding window moves over a specific pixel.
* For example:
- When a sliding window covers a particular region of the matrix, all pixels within this region are incremented by 1.
- As the sliding window moves, the common pixels between the current and previous sliding windows are incremented by 1, reflecting the overlap.
---
**Water count matrix :**
- Same shape as original image.
- A matrix where each pixel value represents the number of times pixels labelled as water.
* For example:
1. For each sliding window ⇒ It is segmented 0 (Land) or 1 (Water).
2. We apply add operation between current segmented image and previous semented images.
3.1 If pixel semented as 1 as last loop ⇒ water count increased by 1.
3.1 If pixel semented as 0 but last loop segmented as 1 ⇒ water count still as it is.
- This happen because each point may have more than one buffering window that passes through it.
- **Before :** If at least one sliding window labels the pixel as water => It will be water.
- **After :** If more than half of sliding winodws labels the pixel as water then water, else land.
# Concatenate the rest of sliding windows images (Unlabeled parts) from NDWI classifed.
fwitmer
approved these changes
Jul 1, 2024
fwitmer
left a comment
Owner
There was a problem hiding this comment.
Improves documentation for get_ndwi_label function and adds majority pixel rule for labeling water pixels.
Ritika-K7
pushed a commit
to Ritika-K7/CoastlineExtraction
that referenced
this pull request
Aug 23, 2025
Update ndwi_labels.py by adding majority pixel rule for labeling water pixels. Also improves documentation for get_ndwi_label function.
Ritika-K7
pushed a commit
to Ritika-K7/CoastlineExtraction
that referenced
this pull request
Aug 23, 2025
Update ndwi_labels.py by adding majority pixel rule for labeling water pixels. Also improves documentation for get_ndwi_label function.
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.
This pull request is part of Google Summer of Code 2024.