Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Alex-Lewandowski
Copy link
Contributor

@Alex-Lewandowski Alex-Lewandowski commented Mar 28, 2025

Make correct_unwrap_error_phase_closure use user-defined connCompMinArea when labeling connected components. It currently always uses the default.

Description of proposed changes

Fixes #1335

  • adds a cc_min_area arg to correct_unwrap_error_phase_closure so it can be passed to cc_obj.label(min_area=cc_min_area).
    • If min_area is not passed label, it uses the default of 2.5e3

Reminders

Summary by Sourcery

Modify the phase closure error correction function to allow user-defined minimum area for connected component labeling

New Features:

  • Introduce a new optional parameter cc_min_area to control the minimum area threshold for connected component labeling

Bug Fixes:

  • Fix the default connected component labeling by adding a configurable minimum area parameter

Enhancements:

  • Add flexibility to the phase closure error correction by allowing custom minimum area for connected component labeling

Summary by Sourcery

Modify the phase closure error correction function to allow user-defined minimum area for connected component labeling

New Features:

  • Add an optional cc_min_area parameter to correct_unwrap_error_phase_closure function to control the minimum area threshold for connected component labeling

Bug Fixes:

  • Enable flexible configuration of minimum area for connected component labeling, addressing the default hard-coded value

Enhancements:

  • Improve function flexibility by allowing custom minimum area parameter for connected component labeling

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Mar 28, 2025

Reviewer's Guide by Sourcery

This pull request modifies the correct_unwrap_error_phase_closure function to allow users to specify the minimum area for connected component labeling via the cc_min_area argument. This change provides more flexibility in the phase closure error correction process.

Sequence diagram for correct_unwrap_error_phase_closure with user-defined connCompMinArea

sequenceDiagram
  participant user as User
  participant correct_unwrap_error_phase_closure as correct_unwrap_error_phase_closure
  participant conncomp_obj as conncomp.connectComponent

  user->>correct_unwrap_error_phase_closure: Call correct_unwrap_error_phase_closure(ifgram_file, common_regions, water_mask_file, ccName, dsNameIn, dsNameOut, cc_min_area)
  correct_unwrap_error_phase_closure->>conncomp_obj: cc_obj = conncomp.connectComponent(conncomp=cc, metadata=stack_obj.metadata)
  correct_unwrap_error_phase_closure->>conncomp_obj: cc_obj.label(min_area=cc_min_area)
  conncomp_obj-->>correct_unwrap_error_phase_closure: labelImg
  correct_unwrap_error_phase_closure->>correct_unwrap_error_phase_closure: measure.regionprops(cc_obj.labelImg)
  correct_unwrap_error_phase_closure-->>user: Returns corrected unwrap phase
Loading

File-Level Changes

Change Details Files
Modified the correct_unwrap_error_phase_closure function to accept a cc_min_area argument, allowing users to specify the minimum area for connected component labeling.
  • Added cc_min_area as an argument to the correct_unwrap_error_phase_closure function.
  • Passed the cc_min_area argument to the cc_obj.label() function.
  • Added cc_min_area to the run_unwrap_error_phase_closure function.
src/mintpy/unwrap_error_phase_closure.py

Assessment against linked issues

Issue Objective Addressed Explanation
#1335 Ensure the correct_unwrap_error_phase_closure function uses the user-defined connCompMinArea value when labeling connected components, instead of the default value.
#1335 The code should use the user-defined connCompMinArea value when labeling connected components during phase closure unwrapping error correction.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@Alex-Lewandowski Alex-Lewandowski marked this pull request as ready for review March 28, 2025 21:00
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @Alex-Lewandowski - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider adding a check to ensure cc_min_area is a positive value.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Alex-Lewandowski
Copy link
Contributor Author

Overall Comments:

  • Consider adding a check to ensure cc_min_area is a positive value.

Good thought, but maybe it would be best to check in the unwrap_error_phase_closure and unwrap_error_bridging CLIs?

@yunjunz yunjunz self-requested a review April 1, 2025 08:40
+ objects.conncomp.label_conn_comp: skip removing small objects if there is only one label

+ cli.unwrap_error_phase_closure: add checking for --num-sample and --min-area
Copy link
Member

@yunjunz yunjunz left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you @Alex-Lewandowski!

@yunjunz yunjunz changed the title Unwrap error correction with phase_closure should use user-defined connCompMinArea unwrap_error_phase_closure: use user-defined connCompMinArea Apr 1, 2025
@yunjunz yunjunz merged commit 4bbca8c into main Apr 1, 2025
8 checks passed
@yunjunz yunjunz deleted the bug/unw_err_phase_closure_use_min_cc_size branch April 1, 2025 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

User-defined connCompMinArea not used during unwrapping error correction with phase_closure method

3 participants