Skip to content

Commit 85904fc

Browse files
authored
Merge pull request #343 from clEsperanto/add-new-filters
Add new filters and operations
2 parents 115caa8 + a16d357 commit 85904fc

26 files changed

+836
-165
lines changed

clic/include/statistics.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ using StatisticsMap = std::unordered_map<std::string, std::vector<float>>;
1414
auto
1515
compute_statistics_per_labels(const Device::Pointer & device,
1616
const Array::Pointer & label,
17-
const Array::Pointer & intensity,
18-
size_t offset) -> StatisticsMap;
17+
const Array::Pointer & intensity) -> StatisticsMap;
1918

2019
auto
2120
_statistics_per_label(const Device::Pointer & device,

clic/include/tier1.hpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2059,6 +2059,47 @@ replace_value_func(const Device::Pointer & device,
20592059
float scalar0,
20602060
float scalar1) -> Array::Pointer;
20612061

2062+
/**
2063+
* @name replace_intensity
2064+
* @brief Replaces a specific intensity in an image with a given new value.
2065+
*
2066+
* @param device Device to perform the operation on. [const Device::Pointer &]
2067+
* @param src Input image to process. [const Array::Pointer &]
2068+
* @param dst Output result image. [Array::Pointer ( = None )]
2069+
* @param scalar0 Old value. [float ( = 0 )]
2070+
* @param scalar1 New value. [float ( = 1 )]
2071+
* @return Array::Pointer
2072+
* @see https://clij.github.io/clij2-docs/reference_replaceIntensity
2073+
* @deprecated This function is deprecated. Consider using replace_value() instead.
2074+
*/
2075+
auto
2076+
replace_intensity_func(const Device::Pointer & device,
2077+
const Array::Pointer & src,
2078+
Array::Pointer dst,
2079+
float scalar0,
2080+
float scalar1) -> Array::Pointer;
2081+
2082+
/**
2083+
* @name replace_intensities
2084+
* @brief Replaces integer intensities specified in a vector image. The values are passed as a vector of values.
2085+
* The vector index represents the old intensity and the value at that position represents the new intensity.s
2086+
*
2087+
* @param device Device to perform the operation on. [const Device::Pointer &]
2088+
* @param src0 Input image to process. [const Array::Pointer &]
2089+
* @param src1 List of intensities to replace, as a vector of values. [const Array::Pointer &]
2090+
* @param dst Output result image. [Array::Pointer ( = None )]
2091+
* @return Array::Pointer
2092+
*
2093+
* @note 'bia-bob-suggestion'
2094+
* @see https://clij.github.io/clij2-docs/reference_replaceIntensities
2095+
* @deprecated This function is deprecated. Consider using replace_values() instead.
2096+
*/
2097+
auto
2098+
replace_intensities_func(const Device::Pointer & device,
2099+
const Array::Pointer & src0,
2100+
const Array::Pointer & src1,
2101+
Array::Pointer dst) -> Array::Pointer;
2102+
20622103
/**
20632104
* @name maximum_sphere
20642105
* @brief Computes the local maximum of a pixels spherical neighborhood. The spheres size is specified by its halfwidth,

clic/include/tier2.hpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,46 @@ subtract_images_func(const Device::Pointer & device,
895895
const Array::Pointer & src1,
896896
Array::Pointer dst) -> Array::Pointer;
897897

898+
/**
899+
* @name sub_stack
900+
* @brief Crop a volume into a new volume, along the z-axis.
901+
*
902+
* @param device Device to perform the operation on. [const Device::Pointer &]
903+
* @param src Input image. [const Array::Pointer &]
904+
* @param dst Output image. [Array::Pointer ( = None )]
905+
* @param start_z Start z coordinate of the crop. [int ( = 0 )]
906+
* @param end_z End z coordinate of the crop. [int ( = 0 )]
907+
* @return Array::Pointer
908+
*
909+
* @note 'transform', 'in assistant'
910+
* @see https://clij.github.io/clij2-docs/reference_subStack
911+
*/
912+
auto
913+
sub_stack_func(const Device::Pointer & device, const Array::Pointer & src, Array::Pointer dst, int start_z, int end_z)
914+
-> Array::Pointer;
915+
916+
/**
917+
* @name reduce_stack
918+
* @brief Reduces the number of z-slices in a stack by a given factor. With the offset you have control which slices
919+
* 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.
920+
* are kept.
921+
*
922+
* @param device Device to perform the operation on. [const Device::Pointer &]
923+
* @param src Input image. [const Array::Pointer &]
924+
* @param dst Output image. [Array::Pointer ( = None )]
925+
* @param reduction_factor Reduction factor. [int ( = 2 )]
926+
* @param offset Offset. [int ( = 0 )]
927+
* @return Array::Pointer
928+
*
929+
* @note 'transform', 'in assistant'
930+
* @see https://clij.github.io/clij2-docs/reference_reduceStack
931+
*/
932+
auto
933+
reduce_stack_func(const Device::Pointer & device,
934+
const Array::Pointer & src,
935+
Array::Pointer dst,
936+
int reduction_factor,
937+
int offset) -> Array::Pointer;
898938

899939
/**
900940
* @name sum_of_all_pixels

clic/include/tier3.hpp

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -368,16 +368,36 @@ morphological_chan_vese_func(const Device::Pointer & device,
368368
* The intensity image is optional and set to 0 if not provided.
369369
*
370370
* @param device Device to perform the operation on. [const Device::Pointer &]
371-
* @param src Label image to compute the statistics. [const Array::Pointer &]]
371+
* @param label Label image to compute the statistics. [const Array::Pointer &]]
372372
* @param intensity Intensity image. [Array::Pointer ( = None )]
373-
* @param withBG Include the background label in the statistics. [bool ( = False )]
374373
* @return StatisticsMap
374+
*
375+
* @see https://clij.github.io/clij2-docs/reference_statisticsOfLabelledPixels
375376
*/
376377
auto
377378
statistics_of_labelled_pixels_func(const Device::Pointer & device,
378-
const Array::Pointer & src,
379-
Array::Pointer intensity,
380-
bool withBG) -> StatisticsMap;
379+
const Array::Pointer & label,
380+
Array::Pointer intensity) -> StatisticsMap;
381+
382+
/**
383+
* @name statistics_of_background_and_labelled_pixels
384+
* @brief Compute, for the background and labels, the bounding box, area (in pixels/voxels), minimum intensity,
385+
* maximum intensity, average intensity, standard deviation of the intensity, and some shape descriptors of
386+
* labelled objects in a label image and its corresponding intensity image.
387+
*
388+
* The intensity image is optional and set to 0 if not provided.
389+
*
390+
* @param device Device to perform the operation on. [const Device::Pointer &]
391+
* @param label Label image to compute the statistics. [const Array::Pointer &]]
392+
* @param intensity Intensity image. [Array::Pointer ( = None )]
393+
* @return StatisticsMap
394+
*
395+
* @see https://clij.github.io/clij2-docs/reference_statisticsOfBackgroundAndLabelledPixels
396+
*/
397+
auto
398+
statistics_of_background_and_labelled_pixels_func(const Device::Pointer & device,
399+
const Array::Pointer & label,
400+
const Array::Pointer & intensity) -> StatisticsMap;
381401

382402
} // namespace cle::tier3
383403

clic/include/tier4.hpp

Lines changed: 149 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -105,25 +105,162 @@ threshold_otsu_func(const Device::Pointer & device, const Array::Pointer & src,
105105

106106

107107
/**
108-
* @name filter_label_by_size
109-
* @brief Filter labelled objects outside of the min/max size range value.
108+
* @name label_pixel_count_map
109+
* @brief Takes a label map, determines the number of pixels per label and replaces every label with the that number.
110+
* This results in a parametric image expressing area or volume.
111+
*
112+
* @param device Device to perform the operation on. [const Device::Pointer &]
113+
* @param src Label image to measure [const Array::Pointer &]
114+
* @param dst Parametric image computed[Array::Pointer ( = None )]
115+
* @return Array::Pointer
116+
*
117+
* @note 'label measurement', 'map', 'in assistant'
118+
* @see https://clij.github.io/clij2-docs/reference_pixelCountMap
119+
*/
120+
auto
121+
label_pixel_count_map_func(const Device::Pointer & device,
122+
const Array::Pointer & src,
123+
Array::Pointer dst) -> Array::Pointer;
124+
125+
126+
/**
127+
* @name centroids_of_labels
128+
* @brief Determines the centroids of all labels in a label image or image stack.
129+
* It writes the resulting coordinates in point list image of dimensions n * d
130+
* where n is the number of labels and d=3 the dimensionality (x,y,z) of the original image.
131+
*
132+
* @param device Device to perform the operation on. [const Device::Pointer &]
133+
* @param src Label image where the centroids will be determined from. [const Array::Pointer &]
134+
* @param dst Output image where the centroids will be written to. [Array::Pointer ( = None )]
135+
* @param withBG Determines if the background label should be included. [bool ( = False )]
136+
* @return Array::Pointer
137+
*
138+
* @note 'bia-bob-suggestion'
139+
* @see https://clij.github.io/clij2-docs/reference_centroidsOfLabels
140+
*/
141+
auto
142+
centroids_of_labels_func(const Device::Pointer & device, const Array::Pointer & src, Array::Pointer dst, bool withBG)
143+
-> Array::Pointer;
144+
145+
146+
/**
147+
* @name remove_labels_with_values_out_of_range
148+
* @brief Remove labels with values outside a given value range based on a vector of values
149+
* associated with the labels.
150+
*
151+
* @param device Device to perform the operation on. [const Device::Pointer &]
152+
* @param src Input image where labels will be filtered. [const Array::Pointer &]
153+
* @param values Vector of values associated with the labels. [const Array::Pointer &]
154+
* @param dst Output image where labels will be written to. [Array::Pointer ( = None )]
155+
* @param min_value Minimum value to keep. [float ( = 0 )]
156+
* @param max_value Maximum value to keep. [float ( = 100 )]
157+
* @return Array::Pointer
158+
*
159+
* @note 'label processing', 'combine'
160+
* @see https://clij.github.io/clij2-docs/reference_excludeLabelsWithValuesOutOfRange
161+
*/
162+
auto
163+
remove_labels_with_values_out_of_range_func(const Device::Pointer & device,
164+
const Array::Pointer & src,
165+
const Array::Pointer & values,
166+
Array::Pointer dst,
167+
float min_value,
168+
float max_value) -> Array::Pointer;
169+
170+
/**
171+
* @name remove_labels_with_values_within_range
172+
* @brief Remove labels with values inside a given value range based on a vector of values
173+
* associated with the labels.
174+
*
175+
* @param device Device to perform the operation on. [const Device::Pointer &]
176+
* @param src Input image where labels will be filtered. [const Array::Pointer &]
177+
* @param values Vector of values associated with the labels. [const Array::Pointer &]
178+
* @param dst Output image where labels will be written to. [Array::Pointer ( = None )]
179+
* @param min_value Minimum value to keep. [float ( = 0 )]
180+
* @param max_value Maximum value to keep. [float ( = 100 )]
181+
* @return Array::Pointer
182+
*
183+
* @note 'label processing', 'combine'
184+
* @see https://clij.github.io/clij2-docs/reference_excludeLabelsWithValuesWithinRange
185+
*/
186+
auto
187+
remove_labels_with_values_within_range_func(const Device::Pointer & device,
188+
const Array::Pointer & src,
189+
const Array::Pointer & values,
190+
Array::Pointer dst,
191+
float min_value,
192+
float max_value) -> Array::Pointer;
193+
194+
/**
195+
* @name exclude_labels_with_values_out_of_range
196+
* @brief Exclude labels with values outside a given value range based on a vector of values
197+
* associated with the labels.
198+
*
199+
* @param device Device to perform the operation on. [const Device::Pointer &]
200+
* @param src Input image where labels will be filtered. [const Array::Pointer &]
201+
* @param values Vector of values associated with the labels. [const Array::Pointer &]
202+
* @param dst Output image where labels will be written to. [Array::Pointer ( = None )]
203+
* @param min_value_range Minimum value to keep. [float ( = 0 )]
204+
* @param max_value_range Maximum value to keep. [float ( = 100 )]
205+
* @return Array::Pointer
206+
*
207+
* @note 'label processing', 'combine'
208+
* @see https://clij.github.io/clij2-docs/reference_excludeLabelsWithValuesOutOfRange
209+
* @deprecated This function is deprecated. Use remove_labels_with_values_out_of_range_func instead.
210+
*/
211+
auto
212+
exclude_labels_with_values_out_of_range_func(const Device::Pointer & device,
213+
const Array::Pointer & src,
214+
const Array::Pointer & values,
215+
Array::Pointer dst,
216+
float min_value_range,
217+
float max_value_range) -> Array::Pointer;
218+
219+
/**
220+
* @name exclude_labels_with_values_within_range
221+
* @brief Exclude labels with values inside a given value range based on a vector of values
222+
* associated with the labels.
223+
*
224+
* @param device Device to perform the operation on. [const Device::Pointer &]
225+
* @param src Input image where labels will be filtered. [const Array::Pointer &]
226+
* @param values Vector of values associated with the labels. [const Array::Pointer &]
227+
* @param dst Output image where labels will be written to. [Array::Pointer ( = None )]
228+
* @param min_value_range Minimum value to keep. [float ( = 0 )]
229+
* @param max_value_range Maximum value to keep. [float ( = 100 )]
230+
* @return Array::Pointer
231+
*
232+
* @note 'label processing', 'combine'
233+
* @see https://clij.github.io/clij2-docs/reference_excludeLabelsWithValuesWithinRange
234+
* @deprecated This function is deprecated. Use remove_labels_with_values_within_range_func instead.
235+
*/
236+
auto
237+
exclude_labels_with_values_within_range_func(const Device::Pointer & device,
238+
const Array::Pointer & src,
239+
const Array::Pointer & values,
240+
Array::Pointer dst,
241+
float min_value_range,
242+
float max_value_range) -> Array::Pointer;
243+
244+
/**
245+
* @name extension_ratio_map
246+
* @brief Determines the ratio of the extension for every label in a label map and returns it as
247+
* a parametric map.
248+
*
249+
* The extension ration is defined as the maximum distance of any pixel in the label to the label's centroid divided by
250+
* the average distance of all pixels in the label to the centroid.
110251
*
111252
* @param device Device to perform the operation on. [const Device::Pointer &]
112253
* @param src Input label image. [const Array::Pointer &]
113-
* @param dst Output label image. [Array::Pointer ( = None )]
114-
* @param min_size Minimum size of labels to keep. [float ( = 0 )]
115-
* @param max_size Maximum size of labels to keep. [float ( = 100 )]
254+
* @param dst Output parametric image. [Array::Pointer ( = None )]
116255
* @return Array::Pointer
117256
*
118-
* @note 'label processing', 'in assistant'
119-
* @see https://clij.github.io/clij2-docs/reference_excludeLabelsOutsideSizeRange
257+
* @note 'label processing', 'in assistant', 'map'
258+
* @see https://clij.github.io/clij2-docs/reference_extensionRatioMap
120259
*/
121260
auto
122-
filter_label_by_size_func(const Device::Pointer & device,
123-
const Array::Pointer & src,
124-
Array::Pointer dst,
125-
float min_size,
126-
float max_size) -> Array::Pointer;
261+
extension_ratio_map_func(const Device::Pointer & device,
262+
const Array::Pointer & src,
263+
Array::Pointer dst) -> Array::Pointer;
127264

128265

129266
} // namespace cle::tier4

0 commit comments

Comments
 (0)