25 #include "itksys/SystemTools.hxx"
39 std::string name = fileName;
40 m_FileExtension = itksys::SystemTools::GetFilenameLastExtension( fileName );
41 if(m_FileExtension ==
".nrrd")
45 else if(m_FileExtension ==
".csv")
51 throw std::logic_error(
"The specified file type is not supported, standard file type is .nrrd!");
53 int pos = name.find_last_of(
".");
54 name.insert(pos,
"_DistanceImage");
55 m_ToFImageWriter->SetDistanceImageFileName(name);
57 name.insert(pos,
"_AmplitudeImage");
58 m_ToFImageWriter->SetAmplitudeImageFileName(name);
60 name.insert(pos,
"_IntensityImage");
61 m_ToFImageWriter->SetIntensityImageFileName(name);
66 m_ToFImageWriter->SetToFImageType(tofImageType);
72 assert(distanceImageInput);
74 assert(amplitudeImageInput);
76 assert(intensityImageInput);
78 ImageReadAccessor distAcc(distanceImageInput, distanceImageInput->GetSliceData(0,0,0));
79 ImageReadAccessor amplAcc(amplitudeImageInput, amplitudeImageInput->GetSliceData(0,0,0));
80 ImageReadAccessor intenAcc(intensityImageInput, intensityImageInput->GetSliceData(0,0,0));
82 float* distanceFloatData = (
float*) distAcc.
GetData();
83 float* amplitudeFloatData = (
float*) amplAcc.GetData();
84 float* intensityFloatData = (
float*) intenAcc.GetData();
85 if (m_RecordingStarted)
87 m_ToFImageWriter->Add(distanceFloatData,amplitudeFloatData,intensityFloatData);
91 this->SetNthOutput(0,distanceImageInput);
92 this->SetNthOutput(1,amplitudeImageInput);
93 this->SetNthOutput(2,intensityImageInput);
98 if(m_ToFImageWriter.IsNull())
100 throw std::logic_error(
"ToFImageWriter is unitialized, set filename first!");
103 m_ToFImageWriter->Open();
104 m_RecordingStarted =
true;
109 m_ToFImageWriter->Close();
110 m_RecordingStarted =
false;
115 return m_ToFImageWriter;
120 m_ToFImageWriter = tofImageWriter;
125 this->SetInput(0,input);
130 if ((input == NULL) && (idx == this->GetNumberOfInputs() - 1))
132 this->SetNumberOfInputs(this->GetNumberOfInputs() - 1);
134 else if(idx == 0 || idx == 1 || idx == 2)
136 this->ProcessObject::SetNthInput(idx, input);
139 m_ToFImageWriter->SetToFCaptureWidth(xDim);
140 m_ToFImageWriter->SetToFCaptureWidth(yDim);
143 this->CreateOutputsForAllInputs();
148 return this->GetInput(0);
153 if (this->GetNumberOfInputs() < 1)
155 return static_cast< mitk::Image*
>(this->ProcessObject::GetInput(idx));
160 this->SetNumberOfOutputs(this->GetNumberOfInputs());
161 for (
unsigned int idx = 0; idx < this->GetNumberOfOutputs(); ++idx)
162 if (this->GetOutput(idx) == NULL)
164 DataObjectPointer newOutput = this->MakeOutput(idx);
165 this->SetNthOutput(idx, newOutput);
void SetImageType(ToFImageWriter::ToFImageType tofImageType)
Set image type for recording.
ToFImageRecorderFilter()
standard constructor
itk::SmartPointer< Self > Pointer
void StartRecording()
start recording of data
~ToFImageRecorderFilter()
standard destructor
std::string m_FileExtension
const void * GetData() const
Gives const access to the data.
void CreateOutputsForAllInputs()
Create an output for each input.
void StopRecording()
stop recording of data
virtual void GenerateData() override
method generating the output of this filter. Called in the updated process of the pipeline...
void SetFileName(std::string fileName)
Set file name for writing image files This filename will be appended by "_DistanceImage", "_AmplitudeImage", or "_IntensityImage" for the single images.
Image class for storing images.
void SetToFImageWriter(ToFImageWriter::Pointer tofImageWriter)
Sets a pointer to the ToFImageWriter internally used.
ToFImageWriter::Pointer GetToFImageWriter()
Returns a pointer to the ToFImageWriter internally used.
unsigned int GetDimension() const
Get dimension of the image.
ImageReadAccessor class to get locked read access for a particular image part.
Image * GetInput()
returns the input of this filter
virtual void SetInput(Image *input)
sets the input of this filter