Skip to content

Commit

Permalink
Merge branch 'master' into rename_parameters
Browse files Browse the repository at this point in the history
Signed-off-by: Stephane Rigaud <[email protected]>
  • Loading branch information
StRigaud authored Oct 17, 2024
2 parents f0fc262 + d61a5a0 commit 1750e2d
Show file tree
Hide file tree
Showing 22 changed files with 120 additions and 93 deletions.
36 changes: 18 additions & 18 deletions clic/include/tier1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,7 @@ maximum_images_func(const Device::Pointer & device,
*
* @note 'filter', 'in assistant'
* @see https://clij.github.io/clij2-docs/reference_maximum3DBox
* @deprecated This function is deprecated. Consider using maximum() instead.
* @deprecated This function is deprecated. Consider using maximum_filter() instead.
*/
auto
maximum_box_func(const Device::Pointer & device,
Expand All @@ -1041,7 +1041,7 @@ maximum_box_func(const Device::Pointer & device,
int radius_z) -> Array::Pointer;

/**
* @name maximum
* @name maximum_filter
* @brief Computes the local maximum of a pixels neighborhood (box or sphere). The neighborhood size is specified by its
* halfwidth, halfheight and halfdepth (radius).
*
Expand All @@ -1059,13 +1059,13 @@ maximum_box_func(const Device::Pointer & device,
* @see https://clij.github.io/clij2-docs/reference_maximum3DSphere
*/
auto
maximum_func(const Device::Pointer & device,
const Array::Pointer & src,
Array::Pointer dst,
float radius_x,
float radius_y,
float radius_z,
std::string connectivity) -> Array::Pointer;
maximum_filter_func(const Device::Pointer & device,
const Array::Pointer & src,
Array::Pointer dst,
float radius_x,
float radius_y,
float radius_z,
std::string connectivity) -> Array::Pointer;


/**
Expand Down Expand Up @@ -1342,7 +1342,7 @@ median_func(const Device::Pointer & device,
*
* @note 'filter', 'in assistant'
* @see https://clij.github.io/clij2-docs/reference_minimum3DBox
* @deprecated This function is deprecated. Consider using minimum() instead.
* @deprecated This function is deprecated. Consider using minimum_filter() instead.
*/
auto
minimum_box_func(const Device::Pointer & device,
Expand All @@ -1354,7 +1354,7 @@ minimum_box_func(const Device::Pointer & device,


/**
* @name minimum
* @name minimum_filter
* @brief Computes the local minimum of a pixels cube neighborhood. The cubes size is specified by its halfwidth,
* halfheight and halfdepth (radius).
*
Expand All @@ -1372,13 +1372,13 @@ minimum_box_func(const Device::Pointer & device,
* @see https://clij.github.io/clij2-docs/reference_minimum3DSphere
*/
auto
minimum_func(const Device::Pointer & device,
const Array::Pointer & src,
Array::Pointer dst,
float radius_x,
float radius_y,
float radius_z,
std::string connectivity) -> Array::Pointer;
minimum_filter_func(const Device::Pointer & device,
const Array::Pointer & src,
Array::Pointer dst,
float radius_x,
float radius_y,
float radius_z,
std::string connectivity) -> Array::Pointer;


/**
Expand Down
19 changes: 10 additions & 9 deletions clic/include/tier3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,39 +360,40 @@ morphological_chan_vese_func(const Device::Pointer & device,
* standard deviation of the intensity, and some shape descriptors of labelled objects in a label image and its
* corresponding intensity image.
*
* The intensity image is optional and set to 0 if not provided.
* The intensity image is equal to the label image if not provided.
* The label image is set to the entire image if not provided.
*
* @param device Device to perform the operation on. [const Device::Pointer &]
* @param label Label image to compute the statistics. [const Array::Pointer &]]
* @param intensity Intensity image. [Array::Pointer ( = None )]
* @param label Label image to compute the statistics. [Array::Pointer ( = None )]]
* @return StatisticsMap
*
* @see https://clij.github.io/clij2-docs/reference_statisticsOfLabelledPixels
*/
auto
statistics_of_labelled_pixels_func(const Device::Pointer & device,
const Array::Pointer & label,
Array::Pointer intensity) -> StatisticsMap;
statistics_of_labelled_pixels_func(const Device::Pointer & device, Array::Pointer intensity, Array::Pointer label)
-> StatisticsMap;

/**
* @name statistics_of_background_and_labelled_pixels
* @brief Compute, for the background and labels, the bounding box, area (in pixels/voxels), minimum intensity,
* maximum intensity, average intensity, standard deviation of the intensity, and some shape descriptors of
* labelled objects in a label image and its corresponding intensity image.
*
* The intensity image is optional and set to 0 if not provided.
* The intensity image is equal to the label image if not provided.
* The label image is set to the entire image if not provided.
*
* @param device Device to perform the operation on. [const Device::Pointer &]
* @param label Label image to compute the statistics. [const Array::Pointer &]]
* @param intensity Intensity image. [Array::Pointer ( = None )]
* @param label Label image to compute the statistics. [Array::Pointer ( = None )]]
* @return StatisticsMap
*
* @see https://clij.github.io/clij2-docs/reference_statisticsOfBackgroundAndLabelledPixels
*/
auto
statistics_of_background_and_labelled_pixels_func(const Device::Pointer & device,
const Array::Pointer & label,
const Array::Pointer & intensity) -> StatisticsMap;
Array::Pointer intensity,
Array::Pointer label) -> StatisticsMap;

} // namespace cle::tier3

Expand Down
16 changes: 8 additions & 8 deletions clic/include/tier4.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ remove_labels_with_map_values_within_range_func(const Device::Pointer & device,
* associated with the labels.
*
* @param device Device to perform the operation on. [const Device::Pointer &]
* @param src Input image where labels will be filtered. [const Array::Pointer &]
* @param values Vector of values associated with the labels. [const Array::Pointer &]
* @param values_map Vector of values associated with the labels. [const Array::Pointer &]
* @param label_map_input Input image where labels will be filtered. [const Array::Pointer &]
* @param dst Output image where labels will be written to. [Array::Pointer ( = None )]
* @param minimum_value_range Minimum value to keep. [float ( = 0 )]
* @param maximum_value_range Maximum value to keep. [float ( = 100 )]
Expand All @@ -225,8 +225,8 @@ remove_labels_with_map_values_within_range_func(const Device::Pointer & device,
*/
auto
exclude_labels_with_map_values_out_of_range_func(const Device::Pointer & device,
const Array::Pointer & src,
const Array::Pointer & values,
const Array::Pointer & values_map,
const Array::Pointer & label_map_input,
Array::Pointer dst,
float minimum_value_range,
float maximum_value_range) -> Array::Pointer;
Expand All @@ -237,8 +237,8 @@ exclude_labels_with_map_values_out_of_range_func(const Device::Pointer & device,
* associated with the labels.
*
* @param device Device to perform the operation on. [const Device::Pointer &]
* @param src Input image where labels will be filtered. [const Array::Pointer &]
* @param values Vector of values associated with the labels. [const Array::Pointer &]
* @param values_map Vector of values associated with the labels. [const Array::Pointer &]
* @param label_map_input Input image where labels will be filtered. [const Array::Pointer &]
* @param dst Output image where labels will be written to. [Array::Pointer ( = None )]
* @param minimum_value_range Minimum value to keep. [float ( = 0 )]
* @param maximum_value_range Maximum value to keep. [float ( = 100 )]
Expand All @@ -250,8 +250,8 @@ exclude_labels_with_map_values_out_of_range_func(const Device::Pointer & device,
*/
auto
exclude_labels_with_map_values_within_range_func(const Device::Pointer & device,
const Array::Pointer & src,
const Array::Pointer & values,
const Array::Pointer & values_map,
const Array::Pointer & label_map_input,
Array::Pointer dst,
float minimum_value_range,
float maximum_value_range) -> Array::Pointer;
Expand Down
14 changes: 7 additions & 7 deletions clic/src/tier1/maximum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ namespace cle::tier1
{

auto
maximum_func(const Device::Pointer & device,
const Array::Pointer & src,
Array::Pointer dst,
float radius_x,
float radius_y,
float radius_z,
std::string connectivity) -> Array::Pointer
maximum_filter_func(const Device::Pointer & device,
const Array::Pointer & src,
Array::Pointer dst,
float radius_x,
float radius_y,
float radius_z,
std::string connectivity) -> Array::Pointer
{
tier0::create_like(src, dst);
auto r_x = radius2kernelsize(radius_x);
Expand Down
14 changes: 7 additions & 7 deletions clic/src/tier1/minimum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ namespace cle::tier1
{

auto
minimum_func(const Device::Pointer & device,
const Array::Pointer & src,
Array::Pointer dst,
float radius_x,
float radius_y,
float radius_z,
std::string connectivity) -> Array::Pointer
minimum_filter_func(const Device::Pointer & device,
const Array::Pointer & src,
Array::Pointer dst,
float radius_x,
float radius_y,
float radius_z,
std::string connectivity) -> Array::Pointer
{
tier0::create_like(src, dst);
auto r_x = radius2kernelsize(radius_x);
Expand Down
4 changes: 2 additions & 2 deletions clic/src/tier2/bottom_hat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ bottom_hat_func(const Device::Pointer & device,
float radius_z,
std::string connectivity) -> Array::Pointer
{
auto temp1 = tier1::maximum_func(device, src, nullptr, radius_x, radius_y, radius_z, connectivity);
auto temp2 = tier1::minimum_func(device, temp1, nullptr, radius_x, radius_y, radius_z, connectivity);
auto temp1 = tier1::maximum_filter_func(device, src, nullptr, radius_x, radius_y, radius_z, connectivity);
auto temp2 = tier1::minimum_filter_func(device, temp1, nullptr, radius_x, radius_y, radius_z, connectivity);
return tier1::add_images_weighted_func(device, temp2, src, dst, 1, -1);
}

Expand Down
4 changes: 2 additions & 2 deletions clic/src/tier2/bottom_hat_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ bottom_hat_box_func(const Device::Pointer & device,
int radius_z) -> Array::Pointer
{
std::cerr << "Deprecated: this function is deprecated, use bottom_hat instead\n";
auto temp1 = tier1::maximum_box_func(device, src, nullptr, radius_x, radius_y, radius_z);
auto temp2 = tier1::minimum_box_func(device, temp1, nullptr, radius_x, radius_y, radius_z);
auto temp1 = tier1::maximum_filter_func(device, src, nullptr, radius_x, radius_y, radius_z, "box");
auto temp2 = tier1::minimum_filter_func(device, temp1, nullptr, radius_x, radius_y, radius_z, "box");
return tier1::add_images_weighted_func(device, temp2, src, dst, 1, -1);
}

Expand Down
4 changes: 2 additions & 2 deletions clic/src/tier2/closing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ closing_func(const Device::Pointer & device,
float radius_z,
std::string connectivity) -> Array::Pointer
{
auto temp = tier1::maximum_func(device, src, nullptr, radius_x, radius_y, radius_z, connectivity);
return tier1::minimum_func(device, temp, dst, radius_x, radius_y, radius_z, connectivity);
auto temp = tier1::maximum_filter_func(device, src, nullptr, radius_x, radius_y, radius_z, connectivity);
return tier1::minimum_filter_func(device, temp, dst, radius_x, radius_y, radius_z, connectivity);
}

} // namespace cle::tier2
4 changes: 2 additions & 2 deletions clic/src/tier2/closing_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ closing_box_func(const Device::Pointer & device,
int radius_z) -> Array::Pointer
{
std::cerr << "Deprecated: this function is deprecated, use closing instead\n";
auto temp = tier1::maximum_box_func(device, src, nullptr, radius_x, radius_y, radius_z);
return tier1::minimum_box_func(device, temp, dst, radius_x, radius_y, radius_z);
auto temp = tier1::maximum_filter_func(device, src, nullptr, radius_x, radius_y, radius_z, "box");
return tier1::minimum_filter_func(device, temp, dst, radius_x, radius_y, radius_z, "box");
}

} // namespace cle::tier2
4 changes: 2 additions & 2 deletions clic/src/tier2/opening.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ opening_func(const Device::Pointer & device,
float radius_z,
std::string connectivity) -> Array::Pointer
{
auto temp = tier1::minimum_func(device, src, nullptr, radius_x, radius_y, radius_z, connectivity);
return tier1::maximum_func(device, temp, dst, radius_x, radius_y, radius_z, connectivity);
auto temp = tier1::minimum_filter_func(device, src, nullptr, radius_x, radius_y, radius_z, connectivity);
return tier1::maximum_filter_func(device, temp, dst, radius_x, radius_y, radius_z, connectivity);
}

} // namespace cle::tier2
4 changes: 2 additions & 2 deletions clic/src/tier2/opening_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ opening_box_func(const Device::Pointer & device,
int radius_z) -> Array::Pointer
{
std::cerr << "Deprecated: this function is deprecated, use opening instead\n";
auto temp = tier1::minimum_box_func(device, src, nullptr, radius_x, radius_y, radius_z);
return tier1::maximum_box_func(device, temp, dst, radius_x, radius_y, radius_z);
auto temp = tier1::minimum_filter_func(device, src, nullptr, radius_x, radius_y, radius_z, "box");
return tier1::maximum_filter_func(device, temp, dst, radius_x, radius_y, radius_z, "box");
}

} // namespace cle::tier2
4 changes: 2 additions & 2 deletions clic/src/tier2/top_hat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ top_hat_func(const Device::Pointer & device,
float radius_z,
std::string connectivity) -> Array::Pointer
{
auto temp1 = tier1::minimum_func(device, src, nullptr, radius_x, radius_y, radius_z, connectivity);
auto temp2 = tier1::maximum_func(device, temp1, nullptr, radius_x, radius_y, radius_z, connectivity);
auto temp1 = tier1::minimum_filter_func(device, src, nullptr, radius_x, radius_y, radius_z, connectivity);
auto temp2 = tier1::maximum_filter_func(device, temp1, nullptr, radius_x, radius_y, radius_z, connectivity);
return tier1::add_images_weighted_func(device, src, temp2, dst, 1, -1);
}

Expand Down
4 changes: 2 additions & 2 deletions clic/src/tier2/top_hat_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ top_hat_box_func(const Device::Pointer & device,
int radius_z) -> Array::Pointer
{
std::cerr << "Deprecated: this function is deprecated, use top_hat instead\n";
auto temp1 = tier1::minimum_box_func(device, src, nullptr, radius_x, radius_y, radius_z);
auto temp2 = tier1::maximum_box_func(device, temp1, nullptr, radius_x, radius_y, radius_z);
auto temp1 = tier1::minimum_filter_func(device, src, nullptr, radius_x, radius_y, radius_z, "box");
auto temp2 = tier1::maximum_filter_func(device, temp1, nullptr, radius_x, radius_y, radius_z, "box");
return tier1::add_images_weighted_func(device, src, temp2, dst, 1, -1);
}

Expand Down
44 changes: 35 additions & 9 deletions clic/src/tier3/statistics_of_labelled_pixels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,25 @@ namespace cle::tier3
{

auto
statistics_of_labelled_pixels_func(const Device::Pointer & device,
const Array::Pointer & label,
Array::Pointer intensity) -> StatisticsMap
statistics_of_labelled_pixels_func(const Device::Pointer & device, Array::Pointer intensity, Array::Pointer label)
-> StatisticsMap
{
if (intensity == nullptr && label == nullptr)
{
throw std::runtime_error(
"Error: no intensity nor label was provided to the 'statistics_of_labelled_pixels' function.");
}
if (label == nullptr)
{
std::cerr << "Warning: no label was provided. Label will be the entire image." << std::endl;
tier0::create_like(intensity, label, dType::LABEL);
label->fill(1);
}
if (intensity == nullptr)
{
// std::cerr << "Warning: no intensity was provided. Pixels intensity will be set to their label value." <<
// std::endl;
std::cerr << "Warning: no intensity was provided. Pixels intensity will be set to their label value." << std::endl;
tier0::create_like(label, intensity, dType::FLOAT);
intensity->fill(0);
tier1::copy_func(device, label, intensity);
}

return compute_statistics_per_labels(device, label, intensity);
Expand All @@ -24,11 +33,28 @@ statistics_of_labelled_pixels_func(const Device::Pointer & device,

auto
statistics_of_background_and_labelled_pixels_func(const Device::Pointer & device,
const Array::Pointer & label,
const Array::Pointer & intensity) -> StatisticsMap
Array::Pointer intensity,
Array::Pointer label) -> StatisticsMap
{
if (intensity == nullptr && label == nullptr)
{
throw std::runtime_error(
"Error: no intensity nor label was provided to the 'statistics_of_labelled_pixels' function.");
}
if (label == nullptr)
{
std::cerr << "Warning: no label was provided. Label will be the entire image." << std::endl;
tier0::create_like(intensity, label, dType::LABEL);
label->fill(1);
}
if (intensity == nullptr)
{
std::cerr << "Warning: no intensity was provided. Pixels intensity will be set to their label value." << std::endl;
tier0::create_like(label, intensity, dType::FLOAT);
tier1::copy_func(device, label, intensity);
}
auto temp = tier1::add_image_and_scalar_func(device, label, nullptr, 1);
auto props = tier3::statistics_of_labelled_pixels_func(device, temp, intensity);
auto props = tier3::statistics_of_labelled_pixels_func(device, intensity, temp);
std::vector<float> labels = props["label"];
std::transform(labels.begin(), labels.end(), labels.begin(), [](float label) { return label - 1; });
props["label"] = labels;
Expand Down
4 changes: 2 additions & 2 deletions clic/src/tier4/centroids_of_labels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ centroids_of_labels_func(const Device::Pointer & device,
cle::StatisticsMap props;
if (include_background)
{
props = tier3::statistics_of_background_and_labelled_pixels_func(device, src, nullptr);
props = tier3::statistics_of_background_and_labelled_pixels_func(device, nullptr, src);
}
else
{
props = tier3::statistics_of_labelled_pixels_func(device, src, nullptr);
props = tier3::statistics_of_labelled_pixels_func(device, nullptr, src);
}
auto centroid_x = props["centroid_x"];
auto centroid_y = props["centroid_y"];
Expand Down
Loading

0 comments on commit 1750e2d

Please sign in to comment.