Medical Imaging Interaction Toolkit  2018.4.99-12ad79a3
Medical Imaging Interaction Toolkit
mitkApplyDiffImageOperation.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 
15 #include <itkCommand.h>
16 
18  Image *image,
19  Image *diffImage,
20  unsigned int timeStep,
21  unsigned int sliceDimension,
22  unsigned int sliceIndex)
23  : Operation(operationType),
24  m_Image(image),
25  m_SliceIndex(sliceIndex),
26  m_SliceDimension(sliceDimension),
27  m_TimeStep(timeStep),
28  m_Factor(1.0),
29  m_ImageStillValid(false),
30  m_DeleteTag(0)
31 {
32  if (image && diffImage)
33  {
34  // observe 3D image for DeleteEvent
35  m_ImageStillValid = true;
36 
37  itk::SimpleMemberCommand<ApplyDiffImageOperation>::Pointer command =
38  itk::SimpleMemberCommand<ApplyDiffImageOperation>::New();
39  command->SetCallbackFunction(this, &ApplyDiffImageOperation::OnImageDeleted);
40  m_DeleteTag = image->AddObserver(itk::DeleteEvent(), command);
41 
42  // keep a compressed version of the image
44  zlibContainer->SetImage(diffImage);
45  }
46 }
47 
49 {
51  {
52  m_Image->RemoveObserver(m_DeleteTag);
53  }
54 }
55 
57 {
58  m_ImageStillValid = false;
59 }
60 
62 {
63  // uncompress image to create a valid mitk::Image
64  Image::Pointer image = zlibContainer->GetImage().GetPointer();
65 
66  return image;
67 }
Base class of all Operation-classes.
Definition: mitkOperation.h:29
ApplyDiffImageOperation(OperationType operationType, Image *image, Image *diffImage, unsigned int timeStep=0, unsigned int sliceDimension=2, unsigned int sliceIndex=0)
CompressedImageContainer::Pointer zlibContainer
Image class for storing images.
Definition: mitkImage.h:72
mitk::Image::Pointer image
int OperationType
Definition: mitkOperation.h:23