brainrat-private 6.0.4
slices.h
Go to the documentation of this file.
1/* Copyright (C) 2000-2013 CEA
2 *
3 * This software and supporting documentation were developed by
4 * bioPICSEL
5 * CEA/DSV/I²BM/MIRCen/LMN, Batiment 61,
6 * 18, route du Panorama
7 * 92265 Fontenay-aux-Roses
8 * France
9 */
10
11#ifndef BRAINRAT_DATA_SLICES_H
12#define BRAINRAT_DATA_SLICES_H
13
14#include <iomanip>
15#include <cartobase/type/string_conversion.h>
16#include <aims/io/process.h>
17#include <aims/io/io_g.h>
18#include <aims/data/data_g.h>
19#include <aims/math/mathelem.h>
20#include <aims/morphology/morphology_g.h>
21#include <aims/utility/converter_g.h>
22
23#define INCH 25.49 // inch->mm
24#define NB_MODES 2 // Mode de number back + tissue approximation
25#define MIN_HISTO 0
26#define MAX_HISTO 64 // TODO test bug value 255...
27#define MAX_INT16_T 32767
28#define MAX_ITER 500
29#define MID_WINDOW 4 // Median processed on window = 4-C-4
30//#define MID_WINDOW 0 // Global median on all components
31#define FRACTION 3.0 // Variation 1/N fraction
32 // tolerance / surf or dim [default = 3]
33#define BORDER_LOCAL 10 // Around component
34#define BORDER_GLOBAL 50 // Around component
35#define PERCENT_SURFACE .2 // Test over mode surface detected / reject
36#define EROSION 1 // Size of erosion / separation
37
38//------------------------------------------------------------------------------
39// Process to detect histological slices in a scanned image
40//------------------------------------------------------------------------------
41class SlicesDetector : public aims::Process {
42 public:
43 std::string fileIn;
44 std::string fileOut;
45 //std::vector<int32_t> dimensionsizes, dimensionorders;
47 int32_t n, res;
48 int32_t lt, ht;
49 uint8_t c;
51
53};
54
55//------------------------------------------------------------------------------
56// Processes to detect, extract and stack histological slices in a scanned image
57//------------------------------------------------------------------------------
58class SlicesStacker : public aims::Process {
59 public:
60 std::string fileIn;
61 std::string fileInP;
62 std::string fileOut;
63 std::string outName;
64 std::vector<int32_t> dimensionsizes, dimensionorders;
65 std::string format;
66 std::string background;
67 bool nostack;
69 uint8_t sn;
70 int32_t n, res;
71 int32_t dx, dy, lt, ht;
72 uint8_t c;
73 float z;
74
75 protected:
77};
78
79
81 public:
83};
84
89
90//------------------------------------------------------------------------------
91// Enumerate type parameter to be tested = continuity
92//------------------------------------------------------------------------------
99
105
111
112//------------------------------------------------------------------------------
113// Component structure
114//------------------------------------------------------------------------------
115typedef struct {
116
117 int32_t label_i; // i=init; m=inter; f=final
118 int32_t label_m; // value = -1
119 int32_t label_f;
120
121 int32_t abscissa_x;
122 int32_t abscissa_X;
123
124 int32_t ordinate_y;
125 int32_t ordinate_Y;
126
127 int32_t coordinate_z ;
128 int32_t coordinate_Z ;
129
130
134
135 int32_t bounding_hz; // Extraction bounding box GC + max X
138
139 int32_t bounding_vt;
142
143 int32_t surface;
144 int32_t surfaceMM;
147
151
153
154//------------------------------------------------------------------------------
155// Validation_Test structure
156//------------------------------------------------------------------------------
157typedef struct {
158 // Mandatory
160
161 // Optional
165
167
168//------------------------------------------------------------------------------
169// Maxima histogram structure
170//------------------------------------------------------------------------------
171typedef struct {
172
173 int32_t iteration;
174 int32_t numero;
175 int32_t value;
176 int32_t position;
177 int32_t surface;
179 int32_t extrema;
180
182
183//------------------------------------------------------------------------------
184// HistologyScanSlicesDetector
185//------------------------------------------------------------------------------
187public:
188
189 // Constructor fo class HistologyScanSlicesDetector
191 float slice_min_surface = 1.,
192 float slice_median_variation = 1. / FRACTION,
193 int32_t histogram_modes = NB_MODES,
194 int32_t histogram_bins = MAX_HISTO,
195 bool check_slices = true);
196
197 // Analyzes histology scan and return a generic object containing
198 // bounding boxes about detected slices
199 carto::Object boundingBoxes(const carto::VolumeRef<int16_t> & vol,
200 const std::vector<Component> & components);
201
202 std::vector<Component> analyze(carto::VolumeRef<int16_t> & vol,
203 const int32_t slices_number = 6,
204 const int32_t scan_resolution = 0,
205 const int32_t threshold_lowerbound = 0,
206 const int32_t threshold_upperbound = 0);
207
208protected:
209
210 bool detectHistogramModes(const carto::VolumeRef<int32_t> & histogram,
211 const int32_t slices_number,
212 const int32_t slices_min_voxels,
213 const HistoAnalysisFunction analysis_function,
214 int32_t & background,
215 int32_t & slices_mode_lowerbound,
216 int32_t & slices_mode_upperbound);
217
218 std::vector<Component> detectComponents(
219 carto::VolumeRef<int16_t> & vol,
220 const int32_t slices_number,
221 const int32_t threshold_lowerbound,
222 const int32_t threshold_upperbound);
223
224 std::vector<Component> checkComponents(
225 carto::VolumeRef<int16_t> & vol,
226 std::vector<Component> &components,
227 const int32_t slices_number);
228
229 std::vector<Component> processOutlierComponents(
230 std::vector<Component> &components,
231 carto::VolumeRef<int16_t> &vol,
232 const int32_t slices_number);
233
234 std::vector<Component> openComponent(
235 const std::vector<Component> & components,
236 const int32_t component,
237 carto::VolumeRef<int16_t> &vol);
238
239 std::vector<Component> separateComponent(
240 const std::vector<Component> & components,
241 const int32_t component,
242 carto::VolumeRef<int16_t> &vol,
243 const Direction dir);
244
245 void writeTestsWarnings(const Tests &t);
246
247 //int64_t getSurfaceVariationInMm();
248
249private:
250
251// carto::VolumeRef<T> _vol;
252// int32_t _slices_number;
253 float _slice_min_surface;
254 float _slice_median_variation;
255 int32_t _histogram_modes;
256 int32_t _histogram_bins;
257 bool _checks_slices;
258// std::vector<int32_t> _dimension_sizes,
259// _dimension_orders;
260};
261
262//------------------------------------------------------------------------------
263// Iterator type definitions MAXIMA / COMPONENT
264//------------------------------------------------------------------------------
265typedef std::vector<Component>::iterator CompIterator;
266typedef std::vector<Maxima>::iterator MaxIterator;
267
268Maxima affectMaxima(int32_t iter, int32_t num, int32_t val,
269 int32_t pos, int32_t extr);
270
271//------------------------------------------------------------------------------
272// Write Component + vector<Point3d)
273//------------------------------------------------------------------------------
274void writeComponents(std::vector<Component> &comp);
275void writeVector3int32_t(std::vector<AimsVector<int32_t, 3> > &vect);
276void writeVectorInt32_t(std::vector<int32_t> &vect);
277void writeAimsInt32_t(carto::VolumeRef<int32_t> &vol);
278void writeAimsFloat(carto::VolumeRef<float> &vol);
279void writeMaxima(std::vector<Maxima> &mxm);
280void writeMaximaIter(std::vector<Maxima> &mxm,
281 int32_t iter);
282
283//------------------------------------------------------------------------------
284// Functions to integrate to StackSlices
285//------------------------------------------------------------------------------
286
287//------------------------------------------------------------------------------
288// 0) Analyse histogram to extract component mode
289//------------------------------------------------------------------------------
290template <class T>
291float computeHistogramRatio(const carto::VolumeRef<T> &vol,
292 const int32_t bins);
293
294carto::VolumeRef<int32_t> generateHistogram(
295 const carto::VolumeRef<int16_t> &vol,
296 const int32_t bins = MAX_HISTO);
297
298std::vector<AimsVector<int32_t, 3> > updateVDM(
299 std::vector<AimsVector<int32_t, 3> > &vdm);
300
301carto::VolumeRef<int16_t> applyThreshold(
302 const carto::VolumeRef<int16_t> &vol,
303 const int16_t threshold_lower_bound,
304 const int16_t threshold_upper_bound,
305 const int16_t new_value = MAX_INT16_T);
306
307//------------------------------------------------------------------------------
308// 1) Connex component extraction
309//------------------------------------------------------------------------------
310carto::VolumeRef<int16_t> computeConnexComponent(
311 carto::VolumeRef<int16_t> &vol);
312
313//------------------------------------------------------------------------------
314// 2) Extract information from component
315//------------------------------------------------------------------------------
316std::vector<Component> removeComponent(std::vector<Component> cpnt, int32_t l);
317
318std::vector<Component> removeComponents(
319 const std::vector<Component> & cpnt,
320 const std::vector<Component> & to_remove);
321
322std::vector<Component> insertComponent(std::vector<Component> cpnt,
323 int32_t comp,
324 std::vector<Component> cpnt2slices,
325 int32_t l);
326
327std::vector<int32_t> getComponentLabels(const std::vector<Component> & cpnt);
328
329
330std::vector<Component> extractInformationFromComponent(
331 const carto::VolumeRef<int16_t> &vol);
332
333//------------------------------------------------------------------------------
334// 3) Test function: 1) init and 2) update
335//------------------------------------------------------------------------------
336
337Tests testComponents(const std::vector<Component> &cpnt, int32_t number_cpnt);
338
339void displayComponentsStrategy(const std::vector<Component> &cpnt);
340
341void displayStatus(const Tests &t);
342
343bool isValid(const Tests &t);
344
345//------------------------------------------------------------------------------
346// 4) Test size && dimension X/Y continuity
347//------------------------------------------------------------------------------
348// Point3d return=value, mean, std
349std::vector<int32_t> extractVectorFromComponent(
350 std::vector<Component> cpnt,
352
354 std::vector<Component> &cpnt, float variation, int32_t mid_window = 0);
355
356//------------------------------------------------------------------------------
357// 4 bis) Process data with morphomath
358//------------------------------------------------------------------------------
359carto::VolumeRef<int32_t> projectData(carto::VolumeRef<int16_t> &X);
360
361carto::VolumeRef<int16_t> transposeVolume(
362 carto::VolumeRef<int16_t> &vol);
363
364bool removeComponentsInVolume(carto::VolumeRef<int16_t> & vol,
365 const std::vector<Component> & to_remove);
366
367carto::VolumeRef<int16_t> extractFromVolume(
368 const carto::VolumeRef<int16_t> &vol,
369 const int32_t x,
370 const int32_t X,
371 const int32_t y,
372 const int32_t Y,
373 const int32_t old_label,
374 const int32_t new_label);
375
376bool copyToVolume(const carto::VolumeRef<int16_t> &vol,
377 carto::VolumeRef<int16_t> &destvol,
378 const int32_t x,
379 const int32_t X,
380 const int32_t y,
381 const int32_t Y,
382 const int32_t old_label,
383 const int32_t new_label);
384
385std::vector<Component> openingComponent(std::vector<Component> &cpnt,
386 int32_t comp,
387 carto::VolumeRef<int16_t> vol,
388 float fraction);
389
390std::vector<Component> separateComponent(std::vector<Component> &cpnt,
391 int32_t comp,
392 carto::VolumeRef<int16_t> vol,
393 int32_t min_surface,
394 Direction dir,
395 float fraction);
396
397std::vector<Component> getOutliersBySurface(const std::vector<Component> & cpnt,
398 const float min_surface);
399
400std::vector<Component> getOutliersByWeight(const std::vector<Component> & cpnt,
401 const int32_t slices_number);
402
403std::vector<Component> filterComponentsBySurface(
404 const std::vector<Component> & cpnt,
405 const float min_surface);
406
407std::vector<Component> weightedRemoveComponents(
408 std::vector<Component> &cpnt,
409 int32_t slices_number);
410
411std::vector<Component> processOutlierComponent(std::vector<Component> &cpnt,
412 carto::VolumeRef<int16_t> &vol,
413 int32_t min_surface,
414 int32_t slices_number,
415 float fraction);
416
417//------------------------------------------------------------------------------
418// 5) Sort component according to Right->Left / Top->Down
419//------------------------------------------------------------------------------
420int32_t getDimensionCount(std::vector<int32_t> dimensionsizes);
421
422std::vector<Component> changeComponentsIndex(
423 std::vector<Component>& components,
424 std::vector<int32_t> dimensionsizes,
425 std::vector<int32_t> dimensionorders,
426 int32_t offset = 1, int32_t step = 1);
427
428bool compareComponentsByLabelM(const Component & c1, const Component & c2);
429
430std::vector<Component> sortComponent(std::vector<Component> & cpnt,
431 std::vector<int32_t> dimensionsizes);
432
433//------------------------------------------------------------------------------
434// 6) Apply new labelling
435//------------------------------------------------------------------------------
436carto::VolumeRef<int16_t> applyNewLabelling(std::vector<Component> cpnt,
437 carto::VolumeRef<int16_t> vol);
438
439//------------------------------------------------------------------------------
440// 7) Dectect slices
441//------------------------------------------------------------------------------
442template<class T> bool
443detectSlices(aims::Process & p, const std::string &, aims::Finder &);
444
445//------------------------------------------------------------------------------
446// 8) Reconstruct volume
447//------------------------------------------------------------------------------
448int32_t extractMaxima(std::vector<int32_t> vctr);
449
450template<class T>
451void rescale(carto::VolumeRef<T> &in, carto::RescalerInfo & info);
452
453template<class T>
454bool writeStackedSlices(int32_t dx, int32_t dy, int32_t res,
455 float z,
456 T background,
457 std::vector<Component> &cpnt,
458 carto::VolumeRef<T> &vol,
459 std::string outputfile,
460 std::string format);
461
462template<class T>
463bool writeNumberedSlices(int32_t dx, int32_t dy, int32_t res,
464 float z,
465 T background,
466 std::vector<Component> &cpnt,
467 carto::VolumeRef<T> &vol,
468 std::string outputdir,
469 std::string outputname,
470 std::string format,
471 uint8_t slicemin);
472
473template<class T>
474static bool individStackSlices(aims::Process & p,
475 const std::string &,
476 aims::Finder &);
477
478
479//------------------------------------------------------------------------------
480// Utilities
481//------------------------------------------------------------------------------
482template <class T>
483float getVoxelLebesgue(const carto::VolumeRef<T> & vol);
484
485template <class T>
486int32_t getVoxelCount(const carto::VolumeRef<T> & vol, float value);
487
488template<class T>
489inline T background(std::vector<Component> & cpnt, carto::VolumeRef<T> &vol)
490{
491 double bg = 0;
492 int32_t count = 0;
493
494 for (int32_t i = 0; i <(int32_t)cpnt.size(); i++)
495 {
496 // Uses pixels around the component bounding box to process background
497 // mean value
498 Component & c = cpnt[ i ];
499
500 if (((c.abscissa_x - BORDER_LOCAL)> 0)
501 && ((c.abscissa_X + BORDER_LOCAL) <= vol.getSizeX()))
502 {
503 for (int32_t y = c.ordinate_y; y <c.ordinate_Y; y++)
504 {
505 bg += vol(c.abscissa_x - 1, y);
506 bg += vol(c.abscissa_X, y);
507 }
508
509 count += (c.bounding_vt * 2);
510 }
511
512 if (((c.ordinate_y - BORDER_LOCAL)> 0)
513 && ((c.ordinate_Y + BORDER_LOCAL) <= vol.getSizeY()))
514 {
515 for (int32_t x = c.abscissa_x; x <c.abscissa_X; x++)
516 {
517 bg += vol(x, c.ordinate_y - 1);
518 bg += vol(x, c.ordinate_Y);
519 }
520 count += (c.bounding_hz * 2);
521 }
522 }
523
524 return (T)(bg / count);
525}
526
527template<>
528inline AimsRGB background<AimsRGB>(std::vector<Component> & cpnt,
529 carto::VolumeRef<AimsRGB> &vol)
530{
531 AimsRGB bg(0,0,0);
532 AimsVector<double, 3> s(0,0,0);
533 int32_t count = 0;
534
535 for (int32_t i = 0; i <(int32_t)cpnt.size(); i++)
536 {
537 // Uses pixels around the component bounding box to process background
538 // mean value
539 Component & c = cpnt[ i ];
540
541 if (((c.abscissa_x - BORDER_LOCAL)> 0)
542 && ((c.abscissa_X + BORDER_LOCAL) <= vol.getSizeX()))
543 {
544 for (int32_t y = c.ordinate_y; y <c.ordinate_Y; y++)
545 {
546 for (int32_t v = 0; v <3; v++)
547 {
548 s[v] += vol(c.abscissa_x - 1, y)[v];
549 s[v] += vol(c.abscissa_X, y)[v];
550 }
551 }
552
553 count += (c.bounding_vt * 2);
554 }
555
556 if (((c.ordinate_y - BORDER_LOCAL)> 0)
557 && ((c.ordinate_Y + BORDER_LOCAL) <= vol.getSizeY()))
558 {
559 for (int32_t x = c.abscissa_x; x <c.abscissa_X; x++)
560 {
561 for (int32_t v = 0; v <3; v++)
562 {
563 s[v] += vol(x, c.ordinate_y - 1)[v];
564 s[v] += vol(x, c.ordinate_Y)[v];
565 }
566 }
567 count += (c.bounding_hz * 2);
568 }
569 }
570
571 bg[0] = (uint8_t)(s[0] / count);
572 bg[1] = (uint8_t)(s[1] / count);
573 bg[2] = (uint8_t)(s[2] / count);
574
575 return (AimsRGB)(bg);
576}
577
578template<>
579inline AimsRGBA background<AimsRGBA>(std::vector<Component> & cpnt,
580 carto::VolumeRef<AimsRGBA> &vol)
581{
582 AimsRGBA bg(0,0,0,0);
583 AimsVector<double, 4> s(0,0,0,0);
584 int32_t count = 0;
585
586 for (int32_t i = 0; i <(int32_t)cpnt.size(); i++)
587 {
588 // Uses pixels around the component bounding box to process background
589 // mean value
590 Component & c = cpnt[ i ];
591
592 if (((c.abscissa_x - BORDER_LOCAL)> 0)
593 && ((c.abscissa_X + BORDER_LOCAL) <= vol.getSizeX()))
594 {
595 for (int32_t y = c.ordinate_y; y <c.ordinate_Y; y++)
596 {
597 for (int32_t v = 0; v <4; v++)
598 {
599 s[v] += vol(c.abscissa_x - 1, y)[v];
600 s[v] += vol(c.abscissa_X, y)[v];
601 }
602 }
603 count += (c.bounding_vt * 2);
604 }
605
606 if (((c.ordinate_y - BORDER_LOCAL)> 0)
607 && ((c.ordinate_Y + BORDER_LOCAL) <= vol.getSizeY()))
608 {
609 for (int32_t x = c.abscissa_x; x <c.abscissa_X; x++)
610 {
611 for (int32_t v = 0; v <4; v++)
612 {
613 s[v] += vol(x, c.ordinate_y - 1)[v];
614 s[v] += vol(x, c.ordinate_Y)[v];
615 }
616 }
617 count += (c.bounding_hz * 2);
618 }
619 }
620
621 bg[0] = (uint8_t)(bg[0] / count);
622 bg[1] = (uint8_t)(bg[1] / count);
623 bg[2] = (uint8_t)(bg[2] / count);
624 bg[3] = (uint8_t)(bg[3] / count);
625
626 return (AimsRGBA)(bg);
627}
628
629#endif
std::vector< Component > processOutlierComponents(std::vector< Component > &components, carto::VolumeRef< int16_t > &vol, const int32_t slices_number)
std::vector< Component > analyze(carto::VolumeRef< int16_t > &vol, const int32_t slices_number=6, const int32_t scan_resolution=0, const int32_t threshold_lowerbound=0, const int32_t threshold_upperbound=0)
carto::Object boundingBoxes(const carto::VolumeRef< int16_t > &vol, const std::vector< Component > &components)
HistologyScanSlicesDetector(float slice_min_surface=1., float slice_median_variation=1./FRACTION, int32_t histogram_modes=NB_MODES, int32_t histogram_bins=MAX_HISTO, bool check_slices=true)
bool detectHistogramModes(const carto::VolumeRef< int32_t > &histogram, const int32_t slices_number, const int32_t slices_min_voxels, const HistoAnalysisFunction analysis_function, int32_t &background, int32_t &slices_mode_lowerbound, int32_t &slices_mode_upperbound)
std::vector< Component > separateComponent(const std::vector< Component > &components, const int32_t component, carto::VolumeRef< int16_t > &vol, const Direction dir)
std::vector< Component > openComponent(const std::vector< Component > &components, const int32_t component, carto::VolumeRef< int16_t > &vol)
std::vector< Component > detectComponents(carto::VolumeRef< int16_t > &vol, const int32_t slices_number, const int32_t threshold_lowerbound, const int32_t threshold_upperbound)
void writeTestsWarnings(const Tests &t)
std::vector< Component > checkComponents(carto::VolumeRef< int16_t > &vol, std::vector< Component > &components, const int32_t slices_number)
float min_size
Definition slices.h:46
bool disable_checks
Definition slices.h:50
int32_t lt
Definition slices.h:48
int32_t res
Definition slices.h:47
std::string fileOut
Definition slices.h:44
float fraction
Definition slices.h:46
int32_t ht
Definition slices.h:48
uint8_t c
Definition slices.h:49
int32_t n
Definition slices.h:47
std::string fileIn
Definition slices.h:43
int32_t lt
Definition slices.h:71
int32_t res
Definition slices.h:70
std::string format
Definition slices.h:65
float fraction
Definition slices.h:68
std::string fileIn
Definition slices.h:60
std::string background
Definition slices.h:66
float z
Definition slices.h:73
bool nostack
Definition slices.h:67
uint8_t c
Definition slices.h:72
float min_size
Definition slices.h:68
int32_t ht
Definition slices.h:71
std::vector< int32_t > dimensionsizes
Definition slices.h:64
std::string fileOut
Definition slices.h:62
int32_t dy
Definition slices.h:71
std::vector< int32_t > dimensionorders
Definition slices.h:64
uint8_t sn
Definition slices.h:69
int32_t dx
Definition slices.h:71
int32_t n
Definition slices.h:70
std::string fileInP
Definition slices.h:61
std::string outName
Definition slices.h:63
std::vector< Component > filterComponentsBySurface(const std::vector< Component > &cpnt, const float min_surface)
float getVoxelLebesgue(const carto::VolumeRef< T > &vol)
std::vector< Component > separateComponent(std::vector< Component > &cpnt, int32_t comp, carto::VolumeRef< int16_t > vol, int32_t min_surface, Direction dir, float fraction)
std::vector< Component > removeComponent(std::vector< Component > cpnt, int32_t l)
#define MAX_INT16_T
Definition slices.h:27
std::vector< Component > weightedRemoveComponents(std::vector< Component > &cpnt, int32_t slices_number)
Maxima affectMaxima(int32_t iter, int32_t num, int32_t val, int32_t pos, int32_t extr)
Direction
Definition slices.h:101
@ Vertical
Definition slices.h:103
@ Horizontal
Definition slices.h:102
std::vector< Component > changeComponentsIndex(std::vector< Component > &components, std::vector< int32_t > dimensionsizes, std::vector< int32_t > dimensionorders, int32_t offset=1, int32_t step=1)
std::vector< int32_t > extractVectorFromComponent(std::vector< Component > cpnt, ContinuityParameterTested param)
#define NB_MODES
Definition slices.h:24
bool detectSlices(aims::Process &p, const std::string &, aims::Finder &)
Definition slices_d.h:23
std::vector< Component > processMedianConsistencyParameters(std::vector< Component > &cpnt, float variation, int32_t mid_window=0)
std::vector< Component > processOutlierComponent(std::vector< Component > &cpnt, carto::VolumeRef< int16_t > &vol, int32_t min_surface, int32_t slices_number, float fraction)
void writeMaxima(std::vector< Maxima > &mxm)
std::vector< AimsVector< int32_t, 3 > > updateVDM(std::vector< AimsVector< int32_t, 3 > > &vdm)
HistoAnalysisFunction
Definition slices.h:107
@ HistogramMode
Definition slices.h:108
@ ProjectionMode
Definition slices.h:109
void displayStatus(const Tests &t)
carto::VolumeRef< int16_t > applyNewLabelling(std::vector< Component > cpnt, carto::VolumeRef< int16_t > vol)
bool writeNumberedSlices(int32_t dx, int32_t dy, int32_t res, float z, T background, std::vector< Component > &cpnt, carto::VolumeRef< T > &vol, std::string outputdir, std::string outputname, std::string format, uint8_t slicemin)
Definition slices_d.h:361
AimsRGBA background< AimsRGBA >(std::vector< Component > &cpnt, carto::VolumeRef< AimsRGBA > &vol)
Definition slices.h:579
bool removeComponentsInVolume(carto::VolumeRef< int16_t > &vol, const std::vector< Component > &to_remove)
std::vector< Component > getOutliersBySurface(const std::vector< Component > &cpnt, const float min_surface)
bool compareComponentsByLabelM(const Component &c1, const Component &c2)
std::vector< Component > removeComponents(const std::vector< Component > &cpnt, const std::vector< Component > &to_remove)
std::vector< int32_t > getComponentLabels(const std::vector< Component > &cpnt)
#define FRACTION
Definition slices.h:31
float computeHistogramRatio(const carto::VolumeRef< T > &vol, const int32_t bins)
std::vector< Component > extractInformationFromComponent(const carto::VolumeRef< int16_t > &vol)
carto::VolumeRef< int16_t > transposeVolume(carto::VolumeRef< int16_t > &vol)
std::vector< Component > insertComponent(std::vector< Component > cpnt, int32_t comp, std::vector< Component > cpnt2slices, int32_t l)
std::vector< Component > sortComponent(std::vector< Component > &cpnt, std::vector< int32_t > dimensionsizes)
ContinuityParameterTested
Definition slices.h:94
@ ComponentSize_vt
Definition slices.h:97
@ ComponentSurface
Definition slices.h:95
@ ComponentSize_hz
Definition slices.h:96
struct Component * ComponentPtr
void writeVectorInt32_t(std::vector< int32_t > &vect)
carto::VolumeRef< int32_t > generateHistogram(const carto::VolumeRef< int16_t > &vol, const int32_t bins=MAX_HISTO)
bool isValid(const Tests &t)
#define MAX_HISTO
Definition slices.h:26
AimsRGB background< AimsRGB >(std::vector< Component > &cpnt, carto::VolumeRef< AimsRGB > &vol)
Definition slices.h:528
#define BORDER_LOCAL
Definition slices.h:33
void rescale(carto::VolumeRef< T > &in, carto::RescalerInfo &info)
carto::VolumeRef< int32_t > projectData(carto::VolumeRef< int16_t > &X)
void displayComponentsStrategy(const std::vector< Component > &cpnt)
void writeComponents(std::vector< Component > &comp)
int32_t extractMaxima(std::vector< int32_t > vctr)
carto::VolumeRef< int16_t > computeConnexComponent(carto::VolumeRef< int16_t > &vol)
T background(std::vector< Component > &cpnt, carto::VolumeRef< T > &vol)
Definition slices.h:489
std::vector< Component > getOutliersByWeight(const std::vector< Component > &cpnt, const int32_t slices_number)
void writeAimsInt32_t(carto::VolumeRef< int32_t > &vol)
std::vector< Component > openingComponent(std::vector< Component > &cpnt, int32_t comp, carto::VolumeRef< int16_t > vol, float fraction)
struct Tests * TestsPtr
std::vector< Component >::iterator CompIterator
Definition slices.h:265
void writeAimsFloat(carto::VolumeRef< float > &vol)
void writeVector3int32_t(std::vector< AimsVector< int32_t, 3 > > &vect)
int32_t getDimensionCount(std::vector< int32_t > dimensionsizes)
Tests testComponents(const std::vector< Component > &cpnt, int32_t number_cpnt)
carto::VolumeRef< int16_t > extractFromVolume(const carto::VolumeRef< int16_t > &vol, const int32_t x, const int32_t X, const int32_t y, const int32_t Y, const int32_t old_label, const int32_t new_label)
carto::VolumeRef< int16_t > applyThreshold(const carto::VolumeRef< int16_t > &vol, const int16_t threshold_lower_bound, const int16_t threshold_upper_bound, const int16_t new_value=MAX_INT16_T)
void writeMaximaIter(std::vector< Maxima > &mxm, int32_t iter)
struct Maxima * MaximaPtr
int32_t getVoxelCount(const carto::VolumeRef< T > &vol, float value)
bool copyToVolume(const carto::VolumeRef< int16_t > &vol, carto::VolumeRef< int16_t > &destvol, const int32_t x, const int32_t X, const int32_t y, const int32_t Y, const int32_t old_label, const int32_t new_label)
bool writeStackedSlices(int32_t dx, int32_t dy, int32_t res, float z, T background, std::vector< Component > &cpnt, carto::VolumeRef< T > &vol, std::string outputfile, std::string format)
Definition slices_d.h:273
std::vector< Maxima >::iterator MaxIterator
Definition slices.h:266
int32_t abscissa_x
Definition slices.h:121
int32_t label_m
Definition slices.h:118
int32_t coordinate_z
Definition slices.h:127
float diff_median_bounding_vt
Definition slices.h:149
int32_t test_median_surface
Definition slices.h:146
int32_t gravity_center_x
Definition slices.h:131
int32_t gravity_center_z
Definition slices.h:133
int32_t ref_median_bounding_hz
Definition slices.h:136
int32_t ordinate_y
Definition slices.h:124
int32_t ref_median_surface
Definition slices.h:145
int32_t label_i
Definition slices.h:117
float diff_median_bounding_hz
Definition slices.h:148
int32_t bounding_vt
Definition slices.h:139
int32_t surfaceMM
Definition slices.h:144
int32_t test_median_bounding_vt
Definition slices.h:141
int32_t ordinate_Y
Definition slices.h:125
float diff_median_surface
Definition slices.h:150
int32_t label_f
Definition slices.h:119
int32_t surface
Definition slices.h:143
int32_t ref_median_bounding_vt
Definition slices.h:140
int32_t bounding_hz
Definition slices.h:135
int32_t coordinate_Z
Definition slices.h:128
int32_t gravity_center_y
Definition slices.h:132
int32_t test_median_bounding_hz
Definition slices.h:137
int32_t abscissa_X
Definition slices.h:122
int32_t iteration
Definition slices.h:173
int32_t numero
Definition slices.h:174
int32_t extrema
Definition slices.h:179
int32_t position
Definition slices.h:176
int32_t test_surface
Definition slices.h:178
int32_t value
Definition slices.h:175
int32_t surface
Definition slices.h:177
bool test_vertical_continuity
Definition slices.h:164
bool test_nb_component
Definition slices.h:159
bool test_size_continuity
Definition slices.h:162
bool test_horizontal_continuity
Definition slices.h:163