Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 102 additions & 48 deletions docs/Coding_Knowledge_Base.md

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/Plugins/NXImageProcessing/docs/BinaryDilateImageFilter.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ The `BinaryMorphScanline` out-of-core path bulk-reads bounded slabs with a share

![Binary dilation example.](Images/BinaryDilation.png)

**Kernel Radius** accepts 0–2147483646 cells per axis when kernel counts and image layouts are representable.

% Auto generated parameter table will be inserted here

## Example Pipelines
Expand Down
2 changes: 2 additions & 0 deletions src/Plugins/NXImageProcessing/docs/BinaryErodeImageFilter.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ The `BinaryMorphScanline` out-of-core path bulk-reads bounded slabs with a share

![Binary erosion example.](Images/BinaryErosion.png)

**Kernel Radius** accepts 0–2147483646 cells per axis when kernel counts and image layouts are representable.

% Auto generated parameter table will be inserted here

## Example Pipelines
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ Other cases retain the raw-ring fallback. If the ring reservation is unavailable

![Binary closing example.](Images/BinaryClosing.png)

**Kernel Radius** accepts 0–2147483646 cells per axis when kernel counts and image layouts are representable.

% Auto generated parameter table will be inserted here

## Example Pipelines
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ Other cases retain the raw-ring fallback. If the ring reservation is unavailable

![Binary opening example.](Images/BinaryOpening.png)

**Kernel Radius** accepts 0–2147483646 cells per axis when kernel counts and image layouts are representable.

% Auto generated parameter table will be inserted here

## Example Pipelines
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ The filter erodes the binary foreground and reconstructs the surviving marker wi

![Binary opening by reconstruction.](Images/OpeningByReconstruction.png)

**Kernel Radius** accepts 0–2147483646 cells per axis when kernel counts and image layouts are representable.

% Auto generated parameter table will be inserted here

## Example Pipelines
Expand Down
2 changes: 2 additions & 0 deletions src/Plugins/NXImageProcessing/docs/BlackTopHatImageFilter.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ The out-of-core composite path uses Z-rings bounded by the kernel radius and ser
![Black top-hat example.](Images/BlackTopHat_1.png)
![Black top-hat example.](Images/BlackTopHat_2.png)

**Kernel Radius** accepts 0–2147483646 cells per axis when kernel counts and image layouts are representable.

% Auto generated parameter table will be inserted here

## Example Pipelines
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ Geodesic morphology and opening/closing by reconstruction are described in Chapt

The filter dilates the input and reconstructs the dilated marker under the input by erosion, optionally performing a second reconstruction to restore preserved intensities. Resident arrays use the Vincent hybrid reconstruction, whose raster, anti-raster, and fold-to-convergence sweeps run as dependency-exact, block-wavefront parallel plane sweeps when the reconstruction uses face connectivity (**Fully Connected** off); with full connectivity it falls back to the exact serial sweeps, since a same-row diagonal read can land in the horizontally adjacent block, which no rectangular block schedule can order. Disk-backed reconstruction iterates a forward raster sweep followed by a reverse anti-raster sweep over consecutive Z-plane slabs until stable, skipping any slab whose planes are already proven unchanged since that direction's last visit. Within a plane, the raster/anti-raster sweep is tiled into independent blocks that run in parallel; under face connectivity every voxel still sees exactly the values the un-blocked sweep would produce, and under full connectivity the iterated forward/reverse passes still converge to the identical final result. Each work and mask slab targets 16 MiB, plus one boundary plane. At least one plane is processed, so a single plane wider than the target can make the buffers exceed 16 MiB. Update order and output are unchanged, preserving exact storage-path parity.

**Kernel Radius** accepts 0–2147483646 cells per axis when kernel counts and image layouts are representable.

% Auto generated parameter table will be inserted here

## Example Pipelines
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ For a true 3D image with an out-of-core input or output, the filter first asks t

For a true 2D image, a checked planner keeps the combined input halo, boundary mask, and output below a 64 MiB target. Normal-width images use full-width row blocks; exceptionally wide images use X tiles with halos. Both routes preserve the same boundary classification, kernel-offset order, exact-value comparisons, and non-cascading output as the in-core path.

**Kernel Radius** accepts 0–2147483646 cells per axis when kernel counts and image layouts are representable.

% Auto generated parameter table will be inserted here

## Example Pipelines
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ For a true 3D image with an out-of-core input or output, the filter first asks t

For a true 2D image, a checked planner keeps the combined input halo, boundary mask, and output below a 64 MiB target. Normal-width images use full-width row blocks; exceptionally wide images use X tiles with halos. Both routes preserve the same boundary classification, kernel-offset order, exact-value comparisons, and non-cascading output as the in-core path.

**Kernel Radius** accepts 0–2147483646 cells per axis when kernel counts and image layouts are representable.

% Auto generated parameter table will be inserted here

## Example Pipelines
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ The `MorphScanline` out-of-core path bulk-reads bounded slabs with a shared Z ha

![Grayscale dilation example.](Images/GrayscaleDilation.png)

**Kernel Radius** accepts 0–2147483646 cells per axis when kernel counts and image layouts are representable.

% Auto generated parameter table will be inserted here

## Example Pipelines
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ The `MorphScanline` out-of-core path bulk-reads bounded slabs with a shared Z ha

![Grayscale erosion example.](Images/GrayscaleErosion.png)

**Kernel Radius** accepts 0–2147483646 cells per axis when kernel counts and image layouts are representable.

% Auto generated parameter table will be inserted here

## Example Pipelines
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ The out-of-core composite path uses Z-rings bounded by the kernel radius and ser

![Grayscale closing example.](Images/GrayscaleClosing.png)

**Kernel Radius** accepts 0–2147483646 cells per axis when kernel counts and image layouts are representable.

% Auto generated parameter table will be inserted here

## Example Pipelines
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ The out-of-core composite path uses Z-rings bounded by the kernel radius and ser

![Grayscale opening example.](Images/GrayscaleOpening.png)

**Kernel Radius** accepts 0–2147483646 cells per axis when kernel counts and image layouts are representable.

% Auto generated parameter table will be inserted here

## Example Pipelines
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ The `MorphGradientScanline` out-of-core path keeps store reads and writes serial

For a single-slice image, the path uses a checked 64 MiB aggregate target. A fitting out-of-core input may use a fixed 48 MiB input buffer and at most 16 MiB of output staging; otherwise the image is processed as full-width row blocks or, for exceptionally wide rows, X tiles with their clipped X/Y halos. Empty structuring elements emit zero through the same bounded-write policy. No datastore access occurs inside the parallel voxel loop.

**Kernel Radius** accepts 0–2147483646 cells per axis when kernel counts and image layouts are representable.

% Auto generated parameter table will be inserted here

## Example Pipelines
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ Geodesic morphology and opening/closing by reconstruction are described in Chapt

The filter erodes the input and reconstructs the eroded marker under the input by dilation, optionally performing a second reconstruction to restore preserved intensities. Resident arrays use the Vincent hybrid reconstruction, whose raster, anti-raster, and fold-to-convergence sweeps run as dependency-exact, block-wavefront parallel plane sweeps when the reconstruction uses face connectivity (**Fully Connected** off); with full connectivity it falls back to the exact serial sweeps, since a same-row diagonal read can land in the horizontally adjacent block, which no rectangular block schedule can order. Disk-backed reconstruction iterates a forward raster sweep followed by a reverse anti-raster sweep over consecutive Z-plane slabs until stable, skipping any slab whose planes are already proven unchanged since that direction's last visit. Within a plane, the raster/anti-raster sweep is tiled into independent blocks that run in parallel; under face connectivity every voxel still sees exactly the values the un-blocked sweep would produce, and under full connectivity the iterated forward/reverse passes still converge to the identical final result. Each work and mask slab targets 16 MiB, plus one boundary plane. At least one plane is processed, so a single plane wider than the target can make the buffers exceed 16 MiB. Update order and output are unchanged, preserving exact storage-path parity.

**Kernel Radius** accepts 0–2147483646 cells per axis when kernel counts and image layouts are representable.

% Auto generated parameter table will be inserted here

## Example Pipelines
Expand Down
2 changes: 2 additions & 0 deletions src/Plugins/NXImageProcessing/docs/WhiteTopHatImageFilter.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ The out-of-core composite path uses Z-rings bounded by the kernel radius and ser

![White top-hat example.](Images/WhiteTopHat.png)

**Kernel Radius** accepts 0–2147483646 cells per axis when kernel counts and image layouts are representable.

% Auto generated parameter table will be inserted here

## Example Pipelines
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,18 @@ IFilter::PreflightResult BinaryDilateImageFilter::preflightImpl(const DataStruct
auto backgroundValue = filterArgs.value<float64>(k_BackgroundValue_Key);
const DataPath outputArrayPath = selectedInputArray.replaceName(outputArrayName);

const auto kernelRadius = filterArgs.value<VectorUInt32Parameter::ValueType>(k_KernelRadius_Key);
if(auto radiusResult = ImageProcessing::ValidateKernelRadius(kernelRadius); radiusResult.invalid())
{
return {ConvertResultTo<OutputActions>(std::move(radiusResult), OutputActions{})};
}
const auto& imageGeom = dataStructure.getDataRefAs<ImageGeom>(imageGeomPath);
const auto& layoutInputArray = dataStructure.getDataRefAs<IDataArray>(selectedInputArray);
if(auto layoutResult = ImageProcessing::ValidateMorphologyLayout(imageGeom.getDimensions(), kernelRadius, false, GetDataTypeSize(layoutInputArray.getDataType())); layoutResult.invalid())
{
return {ConvertResultTo<OutputActions>(ImageProcessing::AddMorphologyLayoutGeometryContext(std::move(layoutResult), imageGeomPath), OutputActions{})};
}

const auto& inputArray = dataStructure.getDataRefAs<IDataArray>(selectedInputArray);
if(inputArray.getNumberOfComponents() != 1)
{
Expand Down Expand Up @@ -144,8 +156,18 @@ Result<> BinaryDilateImageFilter::executeImpl(DataStructure& dataStructure, cons
auto foregroundValue = filterArgs.value<float64>(k_ForegroundValue_Key);
auto boundaryToForeground = filterArgs.value<bool>(k_BoundaryToForeground_Key);

const ImageProcessing::StructuringElement se = ImageProcessing::MakeStructuringElement(
static_cast<ImageProcessing::KernelType>(kernelType), {static_cast<int32>(kernelRadius[0]), static_cast<int32>(kernelRadius[1]), static_cast<int32>(kernelRadius[2])});
const auto& imageGeom = dataStructure.getDataRefAs<ImageGeom>(imageGeomPath);
const auto& inputArray = dataStructure.getDataRefAs<IDataArray>(selectedInputArray);
if(auto layoutResult = ImageProcessing::ValidateMorphologyLayout(imageGeom.getDimensions(), kernelRadius, false, GetDataTypeSize(inputArray.getDataType())); layoutResult.invalid())
{
return ImageProcessing::AddMorphologyLayoutGeometryContext(std::move(layoutResult), imageGeomPath);
}
auto kernelResult = ImageProcessing::MakeCheckedStructuringElement(static_cast<ImageProcessing::KernelType>(kernelType), kernelRadius);
if(kernelResult.invalid())
{
return ConvertInvalidResult<void>(std::move(kernelResult));
}
const ImageProcessing::StructuringElement& se = kernelResult.value();

return ImageProcessing::ExecuteBinaryMorphologyImageFilter(dataStructure, imageGeomPath, selectedInputArray, outputArrayPath, se, ImageProcessing::MorphOp::Dilate, foregroundValue, backgroundValue,
boundaryToForeground, shouldCancel, messageHandler);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,18 @@ IFilter::PreflightResult BinaryErodeImageFilter::preflightImpl(const DataStructu
auto backgroundValue = filterArgs.value<float64>(k_BackgroundValue_Key);
const DataPath outputArrayPath = selectedInputArray.replaceName(outputArrayName);

const auto kernelRadius = filterArgs.value<VectorUInt32Parameter::ValueType>(k_KernelRadius_Key);
if(auto radiusResult = ImageProcessing::ValidateKernelRadius(kernelRadius); radiusResult.invalid())
{
return {ConvertResultTo<OutputActions>(std::move(radiusResult), OutputActions{})};
}
const auto& imageGeom = dataStructure.getDataRefAs<ImageGeom>(imageGeomPath);
const auto& layoutInputArray = dataStructure.getDataRefAs<IDataArray>(selectedInputArray);
if(auto layoutResult = ImageProcessing::ValidateMorphologyLayout(imageGeom.getDimensions(), kernelRadius, false, GetDataTypeSize(layoutInputArray.getDataType())); layoutResult.invalid())
{
return {ConvertResultTo<OutputActions>(ImageProcessing::AddMorphologyLayoutGeometryContext(std::move(layoutResult), imageGeomPath), OutputActions{})};
}

const auto& inputArray = dataStructure.getDataRefAs<IDataArray>(selectedInputArray);
if(inputArray.getNumberOfComponents() != 1)
{
Expand Down Expand Up @@ -143,8 +155,18 @@ Result<> BinaryErodeImageFilter::executeImpl(DataStructure& dataStructure, const
auto foregroundValue = filterArgs.value<float64>(k_ForegroundValue_Key);
auto boundaryToForeground = filterArgs.value<bool>(k_BoundaryToForeground_Key);

const ImageProcessing::StructuringElement se = ImageProcessing::MakeStructuringElement(
static_cast<ImageProcessing::KernelType>(kernelType), {static_cast<int32>(kernelRadius[0]), static_cast<int32>(kernelRadius[1]), static_cast<int32>(kernelRadius[2])});
const auto& imageGeom = dataStructure.getDataRefAs<ImageGeom>(imageGeomPath);
const auto& inputArray = dataStructure.getDataRefAs<IDataArray>(selectedInputArray);
if(auto layoutResult = ImageProcessing::ValidateMorphologyLayout(imageGeom.getDimensions(), kernelRadius, false, GetDataTypeSize(inputArray.getDataType())); layoutResult.invalid())
{
return ImageProcessing::AddMorphologyLayoutGeometryContext(std::move(layoutResult), imageGeomPath);
}
auto kernelResult = ImageProcessing::MakeCheckedStructuringElement(static_cast<ImageProcessing::KernelType>(kernelType), kernelRadius);
if(kernelResult.invalid())
{
return ConvertInvalidResult<void>(std::move(kernelResult));
}
const ImageProcessing::StructuringElement& se = kernelResult.value();

return ImageProcessing::ExecuteBinaryMorphologyImageFilter(dataStructure, imageGeomPath, selectedInputArray, outputArrayPath, se, ImageProcessing::MorphOp::Erode, foregroundValue, backgroundValue,
boundaryToForeground, shouldCancel, messageHandler);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,19 @@ IFilter::PreflightResult BinaryMorphologicalClosingImageFilter::preflightImpl(co
auto foregroundValue = filterArgs.value<float64>(k_ForegroundValue_Key);
const DataPath outputArrayPath = selectedInputArray.replaceName(outputArrayName);

const auto kernelRadius = filterArgs.value<VectorUInt32Parameter::ValueType>(k_KernelRadius_Key);
if(auto radiusResult = ImageProcessing::ValidateKernelRadius(kernelRadius); radiusResult.invalid())
{
return {ConvertResultTo<OutputActions>(std::move(radiusResult), OutputActions{})};
}
const auto& imageGeom = dataStructure.getDataRefAs<ImageGeom>(imageGeomPath);
const auto& layoutInputArray = dataStructure.getDataRefAs<IDataArray>(selectedInputArray);
if(auto layoutResult = ImageProcessing::ValidateMorphologyLayout(imageGeom.getDimensions(), kernelRadius, filterArgs.value<bool>(k_SafeBorder_Key), GetDataTypeSize(layoutInputArray.getDataType()));
layoutResult.invalid())
{
return {ConvertResultTo<OutputActions>(ImageProcessing::AddMorphologyLayoutGeometryContext(std::move(layoutResult), imageGeomPath), OutputActions{})};
}

const auto& inputArray = dataStructure.getDataRefAs<IDataArray>(selectedInputArray);
if(inputArray.getNumberOfComponents() != 1)
{
Expand Down Expand Up @@ -139,8 +152,19 @@ Result<> BinaryMorphologicalClosingImageFilter::executeImpl(DataStructure& dataS
auto foregroundValue = filterArgs.value<float64>(k_ForegroundValue_Key);
auto safeBorder = filterArgs.value<bool>(k_SafeBorder_Key);

const ImageProcessing::StructuringElement se = ImageProcessing::MakeStructuringElement(
static_cast<ImageProcessing::KernelType>(kernelType), {static_cast<int32>(kernelRadius[0]), static_cast<int32>(kernelRadius[1]), static_cast<int32>(kernelRadius[2])});
const auto& imageGeom = dataStructure.getDataRefAs<ImageGeom>(imageGeomPath);
const auto& inputArray = dataStructure.getDataRefAs<IDataArray>(selectedInputArray);
if(auto layoutResult = ImageProcessing::ValidateMorphologyLayout(imageGeom.getDimensions(), kernelRadius, filterArgs.value<bool>(k_SafeBorder_Key), GetDataTypeSize(inputArray.getDataType()));
layoutResult.invalid())
{
return ImageProcessing::AddMorphologyLayoutGeometryContext(std::move(layoutResult), imageGeomPath);
}
auto kernelResult = ImageProcessing::MakeCheckedStructuringElement(static_cast<ImageProcessing::KernelType>(kernelType), kernelRadius);
if(kernelResult.invalid())
{
return ConvertInvalidResult<void>(std::move(kernelResult));
}
const ImageProcessing::StructuringElement& se = kernelResult.value();

// Closing derives its own internal background, so the façade's background argument is unused for Closing; pass 0.0.
return ImageProcessing::ExecuteBinaryMorphologyCompositeImageFilter(dataStructure, imageGeomPath, selectedInputArray, outputArrayPath, se, ImageProcessing::BinaryCompositeOp::Closing,
Expand Down
Loading