Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new filters and operations #343

Merged
merged 14 commits into from
Sep 24, 2024
3 changes: 1 addition & 2 deletions clic/include/statistics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ using StatisticsMap = std::unordered_map<std::string, std::vector<float>>;
auto
compute_statistics_per_labels(const Device::Pointer & device,
const Array::Pointer & label,
const Array::Pointer & intensity,
size_t offset) -> StatisticsMap;
const Array::Pointer & intensity) -> StatisticsMap;

auto
_statistics_per_label(const Device::Pointer & device,
Expand Down
41 changes: 41 additions & 0 deletions clic/include/tier1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2059,6 +2059,47 @@ replace_value_func(const Device::Pointer & device,
float scalar0,
float scalar1) -> Array::Pointer;

/**
* @name replace_intensity
* @brief Replaces a specific intensity in an image with a given new value.
*
* @param device Device to perform the operation on. [const Device::Pointer &]
* @param src Input image to process. [const Array::Pointer &]
* @param dst Output result image. [Array::Pointer ( = None )]
* @param scalar0 Old value. [float ( = 0 )]
* @param scalar1 New value. [float ( = 1 )]
* @return Array::Pointer
* @see https://clij.github.io/clij2-docs/reference_replaceIntensity
* @deprecated This function is deprecated. Consider using replace_value() instead.
*/
auto
replace_intensity_func(const Device::Pointer & device,
const Array::Pointer & src,
Array::Pointer dst,
float scalar0,
float scalar1) -> Array::Pointer;

/**
* @name replace_intensities
* @brief Replaces integer intensities specified in a vector image. The values are passed as a vector of values.
* The vector index represents the old intensity and the value at that position represents the new intensity.s
*
* @param device Device to perform the operation on. [const Device::Pointer &]
* @param src0 Input image to process. [const Array::Pointer &]
* @param src1 List of intensities to replace, as a vector of values. [const Array::Pointer &]
* @param dst Output result image. [Array::Pointer ( = None )]
* @return Array::Pointer
*
* @note 'bia-bob-suggestion'
* @see https://clij.github.io/clij2-docs/reference_replaceIntensities
* @deprecated This function is deprecated. Consider using replace_values() instead.
*/
auto
replace_intensities_func(const Device::Pointer & device,
const Array::Pointer & src0,
const Array::Pointer & src1,
Array::Pointer dst) -> Array::Pointer;

/**
* @name maximum_sphere
* @brief Computes the local maximum of a pixels spherical neighborhood. The spheres size is specified by its halfwidth,
Expand Down
40 changes: 40 additions & 0 deletions clic/include/tier2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,46 @@ subtract_images_func(const Device::Pointer & device,
const Array::Pointer & src1,
Array::Pointer dst) -> Array::Pointer;

/**
* @name sub_stack
* @brief Crop a volume into a new volume, along the z-axis.
*
* @param device Device to perform the operation on. [const Device::Pointer &]
* @param src Input image. [const Array::Pointer &]
* @param dst Output image. [Array::Pointer ( = None )]
* @param start_z Start z coordinate of the crop. [int ( = 0 )]
* @param end_z End z coordinate of the crop. [int ( = 0 )]
* @return Array::Pointer
*
* @note 'transform', 'in assistant'
* @see https://clij.github.io/clij2-docs/reference_subStack
*/
auto
sub_stack_func(const Device::Pointer & device, const Array::Pointer & src, Array::Pointer dst, int start_z, int end_z)
-> Array::Pointer;

/**
* @name reduce_stack
* @brief Reduces the number of z-slices in a stack by a given factor. With the offset you have control which slices
* stays: with a factor 3 and offset 0, slices 0,3,6, etc. are kept. with a factor 4 and offset 1, slices 1,5,9, etc.
* are kept.
*
* @param device Device to perform the operation on. [const Device::Pointer &]
* @param src Input image. [const Array::Pointer &]
* @param dst Output image. [Array::Pointer ( = None )]
* @param reduction_factor Reduction factor. [int ( = 2 )]
* @param offset Offset. [int ( = 0 )]
* @return Array::Pointer
*
* @note 'transform', 'in assistant'
* @see https://clij.github.io/clij2-docs/reference_reduceStack
*/
auto
reduce_stack_func(const Device::Pointer & device,
const Array::Pointer & src,
Array::Pointer dst,
int reduction_factor,
int offset) -> Array::Pointer;

/**
* @name sum_of_all_pixels
Expand Down
30 changes: 25 additions & 5 deletions clic/include/tier3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,16 +368,36 @@ morphological_chan_vese_func(const Device::Pointer & device,
* The intensity image is optional and set to 0 if not provided.
*
* @param device Device to perform the operation on. [const Device::Pointer &]
* @param src Label image to compute the statistics. [const Array::Pointer &]]
* @param label Label image to compute the statistics. [const Array::Pointer &]]
* @param intensity Intensity image. [Array::Pointer ( = None )]
* @param withBG Include the background label in the statistics. [bool ( = False )]
* @return StatisticsMap
*
* @see https://clij.github.io/clij2-docs/reference_statisticsOfLabelledPixels
*/
auto
statistics_of_labelled_pixels_func(const Device::Pointer & device,
const Array::Pointer & src,
Array::Pointer intensity,
bool withBG) -> StatisticsMap;
const Array::Pointer & label,
Array::Pointer intensity) -> 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.
*
* @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 )]
* @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;

} // namespace cle::tier3

Expand Down
161 changes: 149 additions & 12 deletions clic/include/tier4.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,25 +105,162 @@ threshold_otsu_func(const Device::Pointer & device, const Array::Pointer & src,


/**
* @name filter_label_by_size
* @brief Filter labelled objects outside of the min/max size range value.
* @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.
* 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
label_pixel_count_map_func(const Device::Pointer & device,
const Array::Pointer & src,
Array::Pointer dst) -> Array::Pointer;


/**
* @name centroids_of_labels
* @brief Determines the centroids of all labels in a label image or image stack.
* It writes the resulting coordinates in point list image of dimensions n * d
* where n is the number of labels and d=3 the dimensionality (x,y,z) of the original image.
*
* @param device Device to perform the operation on. [const Device::Pointer &]
* @param src Label image where the centroids will be determined from. [const Array::Pointer &]
* @param dst Output image where the centroids will be written to. [Array::Pointer ( = None )]
* @param withBG Determines if the background label should be included. [bool ( = False )]
* @return Array::Pointer
*
* @note 'bia-bob-suggestion'
* @see https://clij.github.io/clij2-docs/reference_centroidsOfLabels
*/
auto
centroids_of_labels_func(const Device::Pointer & device, const Array::Pointer & src, Array::Pointer dst, bool withBG)
-> Array::Pointer;


/**
* @name remove_labels_with_values_out_of_range
* @brief Remove labels with values outside a given value range based on a vector of values
* 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 dst Output image where labels will be written to. [Array::Pointer ( = None )]
* @param min_value Minimum value to keep. [float ( = 0 )]
* @param max_value Maximum value to keep. [float ( = 100 )]
* @return Array::Pointer
*
* @note 'label processing', 'combine'
* @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;

/**
* @name remove_labels_with_values_within_range
* @brief Remove labels with values inside a given value range based on a vector of values
* 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 dst Output image where labels will be written to. [Array::Pointer ( = None )]
* @param min_value Minimum value to keep. [float ( = 0 )]
* @param max_value Maximum value to keep. [float ( = 100 )]
* @return Array::Pointer
*
* @note 'label processing', 'combine'
* @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;

/**
* @name exclude_labels_with_values_out_of_range
* @brief Exclude labels with values outside a given value range based on a vector of values
* 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 dst Output image where labels will be written to. [Array::Pointer ( = None )]
* @param min_value_range Minimum value to keep. [float ( = 0 )]
* @param max_value_range Maximum value to keep. [float ( = 100 )]
* @return Array::Pointer
*
* @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.
*/
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;

/**
* @name exclude_labels_with_values_within_range
* @brief Exclude labels with values inside a given value range based on a vector of values
* 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 dst Output image where labels will be written to. [Array::Pointer ( = None )]
* @param min_value_range Minimum value to keep. [float ( = 0 )]
* @param max_value_range Maximum value to keep. [float ( = 100 )]
* @return Array::Pointer
*
* @note 'label processing', 'combine'
* @see https://clij.github.io/clij2-docs/reference_excludeLabelsWithValuesWithinRange
* @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;

/**
* @name extension_ratio_map
* @brief Determines the ratio of the extension for every label in a label map and returns it as
* a parametric map.
*
* The extension ration is defined as the maximum distance of any pixel in the label to the label's centroid divided by
* the average distance of all pixels in the label to the centroid.
*
* @param device Device to perform the operation on. [const Device::Pointer &]
* @param src Input label image. [const Array::Pointer &]
* @param dst Output label image. [Array::Pointer ( = None )]
* @param min_size Minimum size of labels to keep. [float ( = 0 )]
* @param max_size Maximum size of labels to keep. [float ( = 100 )]
* @param dst Output parametric image. [Array::Pointer ( = None )]
* @return Array::Pointer
*
* @note 'label processing', 'in assistant'
* @see https://clij.github.io/clij2-docs/reference_excludeLabelsOutsideSizeRange
* @note 'label processing', 'in assistant', 'map'
* @see https://clij.github.io/clij2-docs/reference_extensionRatioMap
*/
auto
filter_label_by_size_func(const Device::Pointer & device,
const Array::Pointer & src,
Array::Pointer dst,
float min_size,
float max_size) -> Array::Pointer;
extension_ratio_map_func(const Device::Pointer & device,
const Array::Pointer & src,
Array::Pointer dst) -> Array::Pointer;


} // namespace cle::tier4
Expand Down
Loading
Loading