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

Skip to content

Conversation

tkoyama010
Copy link
Member

Resolves #7660

- Add dedicated dilate() and erode() methods
- Support continuous data dilation and erosion
- Add open() and close() morphological operations
- Deprecate image_dilate_erode() in favor of new methods
- Add comprehensive tests for all new methods

Resolves #7660
@pyvista-bot pyvista-bot added the enhancement Changes that enhance the library label Aug 17, 2025
@tkoyama010 tkoyama010 marked this pull request as draft August 18, 2025 05:17
tkoyama010 and others added 12 commits August 19, 2025 07:31
- Fix type annotations in morphological filters (dilate/erode methods)
- Add proper type ignores for VTK class compatibility issues
- Fix DataSet import to use correct module path in TYPE_CHECKING block
- Resolve unreachable code warnings in cells.py
- Fix abstract class instantiation in dataset.py
- Remove unused type ignore comments
- Add proper type annotation for mesh_letters in logo.py
…error

Fixed type incompatibility in data_set.py:7872 where scalars array with
dynamic dtype (uint8, int_, or float64) was assigned to binary_mask['mask']
which expects float type.
- Remove type: ignore[abstract] from pyvista.Cell() instantiation
- Remove type: ignore[unreachable] from numpy dtype checks
These were no longer needed after previous type fixes.
- Fix voxelize_binary_mask dtype issue by preserving original dtype instead of casting to float
- Update image_dilate_erode doctest to use the non-deprecated close() method
- Both fixes maintain the same functionality while resolving doctest failures
Cast scalars array to float before assignment to binary_mask['mask']
to resolve mypy type incompatibility. The __setitem__ method expects
float arrays, but scalars could be uint8, int, or float64 depending
on the input values.

πŸ€– Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
tkoyama010 and others added 2 commits August 23, 2025 17:02
Wrap deprecated image_dilate_erode method calls with pytest.warns
to properly handle expected PyVistaDeprecationWarning in tests.

πŸ€– Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@tkoyama010 tkoyama010 marked this pull request as ready for review August 23, 2025 09:27
Copy link

codecov bot commented Aug 23, 2025

Codecov Report

βœ… All modified and coverable lines are covered by tests.
βœ… Project coverage is 96.41%. Comparing base (6ae8972) to head (665d1c8).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7833   +/-   ##
=======================================
  Coverage   96.40%   96.41%           
=======================================
  Files         150      150           
  Lines       32675    32726   +51     
  Branches     4114     4122    +8     
=======================================
+ Hits        31501    31552   +51     
  Misses        570      570           
  Partials      604      604           

- Add tests for progress_bar parameter
- Add tests for error conditions when active scalars are cell data
- Add tests for custom kernel sizes
- Improve overall test coverage for new morphological filter methods
@user27182 user27182 self-requested a review August 24, 2025 03:30
tkoyama010 and others added 2 commits August 24, 2025 14:43
These cached test images are no longer needed after recent improvements
to the morphological filter implementation.

πŸ€– Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@pyvista-bot
Copy link
Contributor

pyvista-bot commented Aug 24, 2025

@pyvista-bot pyvista-bot temporarily deployed to pull request August 24, 2025 15:04 Inactive
@tkoyama010 tkoyama010 changed the title feat: Improve morphological filters for ImageData Improve morphological filters for ImageData Aug 24, 2025
@pyvista-bot pyvista-bot temporarily deployed to pull request September 9, 2025 23:48 Inactive
Copy link
Contributor

@user27182 user27182 left a comment

Choose a reason for hiding this comment

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

Haven't reviewed closely yet but it's not clear to me if continous should even be needed as a keyword, as I'm not exactly sure what the difference in output would be for some common use cases, it may be be that the continuous filters do everything the binary ones do, plus more, i.e. perhaps they are more general.

The use of additional examples would help clear this up.
In addition, the current examples have a binary image input and binary output, but the plots use interpolation to color the cells. Instead, visualizing the point data as cell data using something points_to_cells before plotting would help make the plot actually appear binary.

@pyvista-bot pyvista-bot temporarily deployed to pull request September 10, 2025 23:59 Inactive
@akaszynski
Copy link
Member

The use of additional examples would help clear this up.

Agreed, would be nice to have some additional examples for this.

@pyvista-bot pyvista-bot temporarily deployed to pull request September 11, 2025 15:59 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Changes that enhance the library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve morphological filters for ImageData
4 participants