Skip to content

Commit

Permalink
Merge pull request #349 from clEsperanto/patch-0.13.2
Browse files Browse the repository at this point in the history
Patch-0.13.2
  • Loading branch information
StRigaud authored Sep 29, 2024
2 parents 776ae03 + 15e3e05 commit ab31139
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 54 deletions.
71 changes: 44 additions & 27 deletions clic/include/tier4.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,22 @@ auto
threshold_otsu_func(const Device::Pointer & device, const Array::Pointer & src, Array::Pointer dst) -> Array::Pointer;


/**
* @name pixel_count_map
* @brief Takes a label map, determines the number of pixels per label and replaces every label with the that number.
* This results in a parametric image expressing area or volume.
*
* @param device Device to perform the operation on. [const Device::Pointer &]
* @param src Label image to measure [const Array::Pointer &]
* @param dst Parametric image computed[Array::Pointer ( = None )]
* @return Array::Pointer
*
* @note 'label measurement', 'map', 'in assistant'
* @see https://clij.github.io/clij2-docs/reference_pixelCountMap
*/
auto
pixel_count_map_func(const Device::Pointer & device, const Array::Pointer & src, Array::Pointer dst) -> Array::Pointer;

/**
* @name label_pixel_count_map
* @brief Takes a label map, determines the number of pixels per label and replaces every label with the that number.
Expand All @@ -116,6 +132,7 @@ threshold_otsu_func(const Device::Pointer & device, const Array::Pointer & src,
*
* @note 'label measurement', 'map', 'in assistant'
* @see https://clij.github.io/clij2-docs/reference_pixelCountMap
* @deprecated This function is deprecated. Use pixel_count_map_func instead.
*/
auto
label_pixel_count_map_func(const Device::Pointer & device,
Expand Down Expand Up @@ -143,7 +160,7 @@ centroids_of_labels_func(const Device::Pointer & device, const Array::Pointer &


/**
* @name remove_labels_with_values_out_of_range
* @name remove_labels_with_map_values_out_of_range
* @brief Remove labels with values outside a given value range based on a vector of values
* associated with the labels.
*
Expand All @@ -159,15 +176,15 @@ centroids_of_labels_func(const Device::Pointer & device, const Array::Pointer &
* @see https://clij.github.io/clij2-docs/reference_excludeLabelsWithValuesOutOfRange
*/
auto
remove_labels_with_values_out_of_range_func(const Device::Pointer & device,
const Array::Pointer & src,
const Array::Pointer & values,
Array::Pointer dst,
float min_value,
float max_value) -> Array::Pointer;
remove_labels_with_map_values_out_of_range_func(const Device::Pointer & device,
const Array::Pointer & src,
const Array::Pointer & values,
Array::Pointer dst,
float min_value,
float max_value) -> Array::Pointer;

/**
* @name remove_labels_with_values_within_range
* @name remove_labels_with_map_values_within_range
* @brief Remove labels with values inside a given value range based on a vector of values
* associated with the labels.
*
Expand All @@ -183,12 +200,12 @@ remove_labels_with_values_out_of_range_func(const Device::Pointer & device,
* @see https://clij.github.io/clij2-docs/reference_excludeLabelsWithValuesWithinRange
*/
auto
remove_labels_with_values_within_range_func(const Device::Pointer & device,
const Array::Pointer & src,
const Array::Pointer & values,
Array::Pointer dst,
float min_value,
float max_value) -> Array::Pointer;
remove_labels_with_map_values_within_range_func(const Device::Pointer & device,
const Array::Pointer & src,
const Array::Pointer & values,
Array::Pointer dst,
float min_value,
float max_value) -> Array::Pointer;

/**
* @name exclude_labels_with_values_out_of_range
Expand All @@ -205,15 +222,15 @@ remove_labels_with_values_within_range_func(const Device::Pointer & device,
*
* @note 'label processing', 'combine'
* @see https://clij.github.io/clij2-docs/reference_excludeLabelsWithValuesOutOfRange
* @deprecated This function is deprecated. Use remove_labels_with_values_out_of_range_func instead.
* @deprecated This function is deprecated. Use remove_labels_with_map_values_out_of_range_func instead.
*/
auto
exclude_labels_with_values_out_of_range_func(const Device::Pointer & device,
const Array::Pointer & src,
const Array::Pointer & values,
Array::Pointer dst,
float min_value_range,
float max_value_range) -> Array::Pointer;
exclude_labels_with_map_values_out_of_range_func(const Device::Pointer & device,
const Array::Pointer & src,
const Array::Pointer & values,
Array::Pointer dst,
float min_value_range,
float max_value_range) -> Array::Pointer;

/**
* @name exclude_labels_with_values_within_range
Expand All @@ -233,12 +250,12 @@ exclude_labels_with_values_out_of_range_func(const Device::Pointer & device,
* @deprecated This function is deprecated. Use remove_labels_with_values_within_range_func instead.
*/
auto
exclude_labels_with_values_within_range_func(const Device::Pointer & device,
const Array::Pointer & src,
const Array::Pointer & values,
Array::Pointer dst,
float min_value_range,
float max_value_range) -> Array::Pointer;
exclude_labels_with_map_values_within_range_func(const Device::Pointer & device,
const Array::Pointer & src,
const Array::Pointer & values,
Array::Pointer dst,
float min_value_range,
float max_value_range) -> Array::Pointer;

/**
* @name extension_ratio_map
Expand Down
2 changes: 1 addition & 1 deletion clic/include/tier7.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ closing_labels_func(const Device::Pointer & device, const Array::Pointer & src,

/**
* @name erode_connected_labels
* @note 'label processing', 'in assistant'
* @brief Erodes labels to a smaller size. Note: Depending on the label image and the radius,
* labels may disappear and labels may split into multiple islands. Thus, overlapping labels of input and output may
* not have the same identifier.
Expand All @@ -221,6 +220,7 @@ closing_labels_func(const Device::Pointer & device, const Array::Pointer & src,
* @param radius [int ( = 1 )]
* @return Array::Pointer
*
* @note 'label processing', 'in assistant'
*/
auto
erode_connected_labels_func(const Device::Pointer & device, const Array::Pointer & src, Array::Pointer dst, int radius)
Expand Down
2 changes: 1 addition & 1 deletion clic/include/tier8.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ smooth_labels_func(const Device::Pointer & device, const Array::Pointer & src, A

/**
* @name smooth_connected_labels
* @category 'label processing', 'in assistant', 'bia-bob-suggestion'
* @brief Apply a morphological erosion and dilation of the label image with respect to
* the connectivity of the labels.
*
Expand All @@ -46,6 +45,7 @@ smooth_labels_func(const Device::Pointer & device, const Array::Pointer & src, A
* @param radius Smoothing radius. [int ( = 0 )]
* @return Array::Pointer
*
* @note 'label processing', 'in assistant', 'bia-bob-suggestion'
*/
auto
smooth_connected_labels_func(const Device::Pointer & device, const Array::Pointer & src, Array::Pointer dst, int radius)
Expand Down
40 changes: 20 additions & 20 deletions clic/src/tier4/filter_label_by_values.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ namespace cle::tier4
{

auto
remove_labels_with_values_out_of_range_func(const Device::Pointer & device,
const Array::Pointer & src,
const Array::Pointer & values,
Array::Pointer dst,
float min_value,
float max_value) -> Array::Pointer
remove_labels_with_map_values_out_of_range_func(const Device::Pointer & device,
const Array::Pointer & src,
const Array::Pointer & values,
Array::Pointer dst,
float min_value,
float max_value) -> Array::Pointer
{
auto above = tier1::greater_constant_func(device, values, nullptr, max_value);
auto below = tier1::smaller_constant_func(device, values, nullptr, min_value);
Expand All @@ -30,12 +30,12 @@ remove_labels_with_values_out_of_range_func(const Device::Pointer & device,


auto
remove_labels_with_values_within_range_func(const Device::Pointer & device,
const Array::Pointer & src,
const Array::Pointer & values,
Array::Pointer dst,
float min_value,
float max_value) -> Array::Pointer
remove_labels_with_map_values_within_range_func(const Device::Pointer & device,
const Array::Pointer & src,
const Array::Pointer & values,
Array::Pointer dst,
float min_value,
float max_value) -> Array::Pointer
{
auto above = tier1::greater_or_equal_constant_func(device, values, nullptr, max_value);
auto below = tier1::smaller_or_equal_constant_func(device, values, nullptr, max_value);
Expand All @@ -46,14 +46,14 @@ remove_labels_with_values_within_range_func(const Device::Pointer & device,


auto
exclude_labels_with_values_out_of_range_func(const Device::Pointer & device,
const Array::Pointer & src,
const Array::Pointer & values,
Array::Pointer dst,
float min_value_range,
float max_value_range) -> Array::Pointer
exclude_labels_with_map_values_out_of_range_func(const Device::Pointer & device,
const Array::Pointer & src,
const Array::Pointer & values,
Array::Pointer dst,
float min_value_range,
float max_value_range) -> Array::Pointer
{
return remove_labels_with_values_out_of_range_func(device, src, values, dst, min_value_range, max_value_range);
return remove_labels_with_map_values_out_of_range_func(device, src, values, dst, min_value_range, max_value_range);
}


Expand All @@ -65,7 +65,7 @@ exclude_labels_with_values_within_range_func(const Device::Pointer & device,
float min_value_range,
float max_value_range) -> Array::Pointer
{
return remove_labels_with_values_within_range_func(device, src, values, dst, min_value_range, max_value_range);
return remove_labels_with_map_values_within_range_func(device, src, values, dst, min_value_range, max_value_range);
}

} // namespace cle::tier4
12 changes: 9 additions & 3 deletions clic/src/tier4/parametrics_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ namespace cle::tier4
{

auto
label_pixel_count_map_func(const Device::Pointer & device,
const Array::Pointer & src,
Array::Pointer dst) -> Array::Pointer
pixel_count_map_func(const Device::Pointer & device, const Array::Pointer & src, Array::Pointer dst) -> Array::Pointer
{
tier0::create_like(src, dst, dType::FLOAT);
auto props = tier3::statistics_of_background_and_labelled_pixels_func(device, src, nullptr);
Expand All @@ -26,6 +24,14 @@ label_pixel_count_map_func(const Device::Pointer & device,
return tier1::replace_values_func(device, src, values, dst);
}

auto
label_pixel_count_map_func(const Device::Pointer & device,
const Array::Pointer & src,
Array::Pointer dst) -> Array::Pointer
{
return pixel_count_map_func(device, src, dst);
}

auto
extension_ratio_map_func(const Device::Pointer & device,
const Array::Pointer & src,
Expand Down
2 changes: 1 addition & 1 deletion clic/src/tier5/filter_label_by_size.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ filter_label_by_size_func(const Device::Pointer & device,
auto list_of_area = Array::create(nb_labels, 1, 1, 1, dType::FLOAT, mType::BUFFER, device);
list_of_area->writeFrom(stats["area"].data());

return tier4::remove_labels_with_values_out_of_range_func(device, src, list_of_area, dst, min_size, max_size);
return tier4::remove_labels_with_map_values_out_of_range_func(device, src, list_of_area, dst, min_size, max_size);
}

auto
Expand Down
2 changes: 1 addition & 1 deletion tests/tier4/test_label_pixelcount_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ TEST_P(TestLabelPixelCountMap, execute2d)
auto gpu_input = cle::Array::create(6, 5, 1, 2, cle::dType::LABEL, cle::mType::BUFFER, device);
gpu_input->writeFrom(input.data());

auto gpu_output = cle::tier4::label_pixel_count_map_func(device, gpu_input, nullptr);
auto gpu_output = cle::tier4::pixel_count_map_func(device, gpu_input, nullptr);

std::vector<float> output(gpu_output->size());
gpu_output->readTo(output.data());
Expand Down

0 comments on commit ab31139

Please sign in to comment.