Skip to content

Replace deprecated remove_small_objects(min_size=...) in cloud-mask preprocessing without changing threshold behavior - #23

Open
2320sharon with Copilot wants to merge 2 commits into
masterfrom
copilot/fix-deprecation-warning-sds-preprocess
Open

Replace deprecated remove_small_objects(min_size=...) in cloud-mask preprocessing without changing threshold behavior#23
2320sharon with Copilot wants to merge 2 commits into
masterfrom
copilot/fix-deprecation-warning-sds-preprocess

Conversation

Copilot AI commented Mar 17, 2026

Copy link
Copy Markdown

SDS_preprocess.create_cloud_mask was emitting repeated FutureWarnings under scikit-image 0.26+ because it still used the deprecated min_size parameter. This PR migrates those calls to max_size while preserving existing object-removal thresholds exactly.

  • Deprecation migration in SDS_preprocess.create_cloud_mask

    • Updated cloud mask cleanup call from min_size=40 to max_size=39.
    • Updated cloud_mask_issue cleanup call from min_size=100 to max_size=99.
    • Uses the required off-by-one mapping to keep prior semantics (remove < Tremove <= T-1).
  • Behavior-preservation regression coverage

    • Added focused tests for connected-component thresholds in:
      • tests/test_create_cloud_mask_thresholds.py
    • Verifies boundary behavior is unchanged:
      • 39 removed / 40 kept
      • 99 removed / 100 kept
    • Also asserts the primary path no longer emits the deprecation warning from remove_small_objects.
# Before
morphology.remove_small_objects(cloud_mask, min_size=40, connectivity=1)

# After (equivalent behavior on threshold boundary)
morphology.remove_small_objects(cloud_mask, max_size=39, connectivity=1)
Original prompt

This section details on the original issue you should resolve

<issue_title>Deprecation warning in SDS_preprocess.py due to remove_small_objects(min_size=...)</issue_title>
<issue_description>## Description

Running CoastSeg triggers repeated FutureWarning messages from coastsat/SDS_preprocess.py related to a deprecated parameter in skimage.morphology.remove_small_objects.

The warning points to:

File: coastsat/SDS_preprocess.py

Line: 973

Warning

C:\development\doodleverse\coastseg\CoastSeg\.pixi\envs\default\Lib\site-packages\coastsat\SDS_preprocess.py:973: FutureWarning: Parameter `min_size` is deprecated since version 0.26.0 and will be removed in 2.0.0 (or later). To avoid this warning, please use the parameter `max_size` instead. For more details, see the documentation of `remove_small_objects`. Note that the new threshold removes objects smaller than **or equal to** its value, while the previous parameter only removed smaller ones.
  cloud_mask = morphology.remove_small_objects(

This warning is emitted multiple times during execution.

Cause

skimage.morphology.remove_small_objects() has deprecated the min_size parameter as of scikit-image 0.26.0. The code in SDS_preprocess.py still appears to use min_size, which will eventually break once support is removed in scikit-image 2.0.0 or later.

Suggested fix

Update the call at SDS_preprocess.py:973 to use max_size instead of min_size, while preserving current behavior as closely as possible.

One thing to note from the warning:

max_size removes objects smaller than or equal to the threshold

min_size previously removed objects only smaller than the threshold

So the replacement may need an off-by-one adjustment depending on intended behavior.</issue_description>

<agent_instructions>Create a fix for this issue. Ensure the same behavior is maintained while fixing the deprecation warning.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

@2320sharon
2320sharon marked this pull request as ready for review March 17, 2026 20:43
Co-authored-by: 2320sharon <61564689+2320sharon@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix deprecation warning in SDS_preprocess.py Replace deprecated remove_small_objects(min_size=...) in cloud-mask preprocessing without changing threshold behavior Mar 17, 2026
Copilot AI requested a review from 2320sharon March 17, 2026 20:49
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.

Deprecation warning in SDS_preprocess.py due to remove_small_objects(min_size=...)

2 participants