Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkRandomImageSampler.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 #ifndef mitkRandomImageSampler_h
13 #define mitkRandomImageSampler_h
14 
15 #include <MitkCLUtilitiesExports.h>
16 
17 //MITK
18 #include <mitkImage.h>
19 #include <mitkImageToImageFilter.h>
20 #include <itkImage.h>
21 
22 namespace mitk
23 {
26  {
31  };
32 
41  {
42  public:
43 
45  itkFactorylessNewMacro(Self);
46  itkCloneMacro(Self);
47  itkSetMacro(SamplingMode, RandomImageSamplerMode);
48  itkGetConstMacro(SamplingMode, RandomImageSamplerMode);
49 
50  itkSetMacro(AcceptanceRate, double);
51  itkGetConstMacro(AcceptanceRate, double);
52 
57  void SetAcceptanceRateVector(std::vector<double> arg)
58  {
59  m_AcceptanceRateVector = arg;
60  }
61 
62  itkGetConstMacro(AcceptanceRateVector, std::vector<double>);
63 
64  itkSetMacro(NumberOfSamples, unsigned int);
65  itkGetConstMacro(NumberOfSamples, unsigned int);
66 
71  void SetNumberOfSamplesVector(std::vector<unsigned int> arg)
72  {
73  m_NumberOfSamplesVector = arg;
74  }
75 
76  itkGetConstMacro(NumberOfSamplesVector, std::vector<unsigned int>);
77 
78  private:
86  ~RandomImageSampler() override;
91  void GenerateOutputInformation() override;
96  void GenerateData() override;
97 
101  template<typename TPixel, unsigned int VImageDimension>
102  void ItkImageProcessing(const itk::Image<TPixel, VImageDimension>* itkImage);
103 
107  template<typename TPixel, unsigned int VImageDimension>
108  void ItkImageProcessingClassDependendSampling(const itk::Image<TPixel, VImageDimension>* itkImage);
109 
113  template<typename TPixel, unsigned int VImageDimension>
114  void ItkImageProcessingFixedNumberSampling(const itk::Image<TPixel, VImageDimension>* itkImage);
115 
119  template<typename TPixel, unsigned int VImageDimension>
120  void ItkImageProcessingClassDependendNumberSampling(const itk::Image<TPixel, VImageDimension>* itkImage);
121 
122  double m_AcceptanceRate;
123  std::vector<double> m_AcceptanceRateVector;
124  unsigned int m_NumberOfSamples;
125  std::vector<unsigned int> m_NumberOfSamplesVector;
126  RandomImageSamplerMode m_SamplingMode;
127  };
128 } //END mitk namespace
129 #endif
#define MITKCLUTILITIES_EXPORT
Superclass of all classes having one or more Images as input and generating Images as output.
Randomly samples voxels from a label image using configurable strategies.
mitkClassMacro(RandomImageSampler, ImageToImageFilter)
void SetNumberOfSamplesVector(std::vector< unsigned int > arg)
Set per-class sample counts for CLASS_DEPENDEND_NUMBER_OF_ACCEPTANCE mode.
void SetAcceptanceRateVector(std::vector< double > arg)
Set per-class acceptance rates for CLASS_DEPENDEND_ACCEPTANCE_RATE mode.
Find image slices visible on a given plane.
RandomImageSamplerMode
Enumeration of sampling modes for RandomImageSampler.
@ CLASS_DEPENDEND_ACCEPTANCE_RATE
Sample each class with an individual acceptance rate.
@ SINGLE_ACCEPTANCE_RATE
Sample all labels with a single acceptance rate.
@ CLASS_DEPENDEND_NUMBER_OF_ACCEPTANCE
Draw a fixed number of samples per class.
@ SINGLE_NUMBER_OF_ACCEPTANCE
Draw a fixed total number of samples.