Medical Imaging Interaction Toolkit  2018.4.99-eed36131
Medical Imaging Interaction Toolkit
mitkPhotoacousticBModeFilter.cpp
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 
14 #include "usServiceReference.h"
15 #include <mitkImageReadAccessor.h>
16 
18 {
19  this->SetNumberOfIndexedInputs(1);
20  this->SetNumberOfRequiredInputs(1);
21 }
22 
24 {
25 }
26 
28 {
29  Superclass::GenerateInputRequestedRegion();
30 
31  mitk::Image::Pointer output = this->GetOutput();
32  mitk::Image::Pointer input = this->GetInput();
33 
34  if (!output->IsInitialized())
35  return;
36 
37  input->SetRequestedRegionToLargestPossibleRegion();
38 }
39 
41 {
42  mitk::Image::ConstPointer input = this->GetInput();
43  mitk::Image::Pointer output = this->GetOutput();
44 
45  if ((output->IsInitialized()) && (this->GetMTime() <= m_TimeOfHeaderInitialization.GetMTime()))
46  return;
47 
48  output->Initialize(input->GetPixelType(), input->GetDimension(), input->GetDimensions());
49  output->GetGeometry()->SetSpacing(input->GetGeometry()->GetSpacing());
50  output->GetGeometry()->Modified();
51  output->SetPropertyList(input->GetPropertyList()->Clone());
52 
54 }
55 
57 {
59  mitk::Image::Pointer input = this->GetInput();
60  mitk::Image::Pointer output = this->GetOutput();
61 
62  if (!output->IsInitialized())
63  return;
64 
65  mitk::ImageReadAccessor reader(input);
66 
67  unsigned int size = output->GetDimension(0) * output->GetDimension(1) * output->GetDimension(2);
68 
69  const float* InputData = (const float*)(reader.GetData());
70  float* OutputData = new float[size];
71  if (!m_UseLogFilter)
72  for (unsigned int i = 0; i < size; ++i)
73  {
74  OutputData[i] = std::abs(InputData[i]);
75  }
76  else
77  {
78  for (unsigned int i = 0; i < size; ++i)
79  {
80  OutputData[i] = log(std::abs(InputData[i]));
81  }
82  }
83 
84  output->SetImportVolume(OutputData, 0, 0, mitk::Image::ImportMemoryManagementType::CopyMemory);
85  delete[] OutputData;
87 }
InputImageType * GetInput(void)
OutputType * GetOutput()
Get the output data of this image source object.
ImageReadAccessor class to get locked read access for a particular image part.
const void * GetData() const
Gives const access to the data.