Skip to content

Commit

Permalink
Fixed dip::EdgeObjectsRemove(img, img).
Browse files Browse the repository at this point in the history
  • Loading branch information
crisluengo committed Dec 18, 2024
1 parent b01cb23 commit 583499e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions changelogs/diplib_next.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ date: 2020-00-00
the data over when the input was binary. In that case it now creates a new uint8 image that points to the
same data segment of the binary image, as intended.

- `dip::EdgeObjectsRemove()` produced an empty output image when the input and output images were the same object.

### Updated dependencies

### Build changes
Expand Down
8 changes: 6 additions & 2 deletions src/regions/label_manipulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,15 @@ void EdgeObjectsRemove( Image const& in, Image& out, dip::uint connectivity ) {
DIP_THROW_IF( !in.IsScalar(), E::IMAGE_NOT_SCALAR );
if( in.DataType().IsBinary() ) {
DIP_START_STACK_TRACE
Image tmp_in = in.QuickCopy();
if( out.Aliases( tmp_in )) { // make sure we don't overwrite in
DIP_STACK_TRACE_THIS( out.Strip() );
}
// Propagate with empty seed mask, iteration until done and treating outside the image as object
BinaryPropagation( Image(), in, out, static_cast< dip::sint >( connectivity ), 0, S::OBJECT );
BinaryPropagation( Image(), tmp_in, out, static_cast< dip::sint >( connectivity ), 0, S::OBJECT );
// The out-image now contains the edge objects
// Remove them by toggling these bits in the in-image and writing the result in out
out ^= in;
out ^= tmp_in;
DIP_END_STACK_TRACE
} else if( in.DataType().IsUInt() ) {
DIP_START_STACK_TRACE
Expand Down

0 comments on commit 583499e

Please sign in to comment.