void mitk::SurfaceInterpolationController::SetCurrentInterpolationSession(mitk::Image::Pointer currentSegmentationImage)
{
  if (currentSegmentationImage.GetPointer() == m_SelectedSegmentation)
    return;

  if (currentSegmentationImage.IsNull())
  {
    m_SelectedSegmentation = nullptr;
    return;
  }

  m_SelectedSegmentation = currentSegmentationImage.GetPointer();

  auto it = m_ListOfInterpolationSessions.find(currentSegmentationImage.GetPointer());
  // If the session does not exist yet create a new ContourPositionPairList otherwise reinitialize the interpolation pipeline
  if (it == m_ListOfInterpolationSessions.end())
  {
    ContourPositionInformationVec2D newList;
    m_ListOfInterpolationSessions.insert(std::pair<mitk::Image*, ContourPositionInformationVec2D>(m_SelectedSegmentation, newList));
    m_InterpolationResult = nullptr;
    m_CurrentNumberOfReducedContours = 0;

    itk::MemberCommand<SurfaceInterpolationController>::Pointer command = itk::MemberCommand<SurfaceInterpolationController>::New();
    command->SetCallbackFunction(this, &SurfaceInterpolationController::OnSegmentationDeleted);
    m_SegmentationObserverTags.insert( std::pair<mitk::Image*, unsigned long>( m_SelectedSegmentation, m_SelectedSegmentation->AddObserver( itk::DeleteEvent(), command ) ) );
  }

  this->ReinitializeInterpolation();
}
コード例 #2
0
void mitk::USTelemedImageSource::GetNextRawImage( mitk::Image::Pointer& image)
{
  if ( image.IsNull() ) { image = mitk::Image::New(); }

  //get the actual resolution to check if it changed. We have to do this every time because the geometry takes a few frames to adapt
  Usgfw2Lib::tagImageResolution resolutionInMetersActual;
  m_ImageProperties->GetResolution(&resolutionInMetersActual, 0);
  if (m_OldnXPelsPerUnit != resolutionInMetersActual.nXPelsPerUnit || m_OldnYPelsPerUnit != resolutionInMetersActual.nYPelsPerUnit)
    {
      //we can only update if the image exists and has a geometry
      if (m_Image.IsNotNull() && m_Image->GetGeometry() != nullptr)
     {
        m_OldnXPelsPerUnit = resolutionInMetersActual.nXPelsPerUnit;
        m_OldnYPelsPerUnit = resolutionInMetersActual.nYPelsPerUnit;
        UpdateImageGeometry();
      }

    }
  //now update image
  if ( m_Image->IsInitialized() )
  {
    m_ImageMutex->Lock();

    // copy contents of the given image into the member variable
    image->Initialize(m_Image->GetPixelType(), m_Image->GetDimension(), m_Image->GetDimensions());
    mitk::ImageReadAccessor inputReadAccessor(m_Image, m_Image->GetSliceData(0,0,0));
    image->SetSlice(inputReadAccessor.GetData());
    image->SetGeometry(m_Image->GetGeometry());

    m_ImageMutex->Unlock();
  }

}
コード例 #3
0
void mitk::SurfaceInterpolationController::SetCurrentInterpolationSession(mitk::Image::Pointer currentSegmentationImage)
{
  if (currentSegmentationImage.GetPointer() == m_SelectedSegmentation)
    return;

  m_ReduceFilter->Reset();
  m_NormalsFilter->Reset();
  m_InterpolateSurfaceFilter->Reset();

  if (currentSegmentationImage.IsNull())
  {
    m_SelectedSegmentation = 0;
    return;
  }
  ContourListMap::iterator it = m_ListOfInterpolationSessions.find(currentSegmentationImage.GetPointer());

  m_SelectedSegmentation = currentSegmentationImage.GetPointer();

  itk::ImageBase<3>::Pointer itkImage = itk::ImageBase<3>::New();
  AccessFixedDimensionByItk_1( m_SelectedSegmentation, GetImageBase, 3, itkImage );
  m_InterpolateSurfaceFilter->SetReferenceImage( itkImage.GetPointer() );

  if (it == m_ListOfInterpolationSessions.end())
  {
    ContourPositionPairList newList;
    m_ListOfInterpolationSessions.insert(std::pair<mitk::Image*, ContourPositionPairList>(m_SelectedSegmentation, newList));
    m_InterpolationResult = 0;
    m_CurrentNumberOfReducedContours = 0;

    itk::MemberCommand<SurfaceInterpolationController>::Pointer command = itk::MemberCommand<SurfaceInterpolationController>::New();
    command->SetCallbackFunction(this, &SurfaceInterpolationController::OnSegmentationDeleted);
    m_SegmentationObserverTags.insert( std::pair<mitk::Image*, unsigned long>( m_SelectedSegmentation, m_SelectedSegmentation->AddObserver( itk::DeleteEvent(), command ) ) );

  }
  else
  {
    for (unsigned int i = 0; i < m_ListOfInterpolationSessions[m_SelectedSegmentation].size(); i++)
    {
      m_ReduceFilter->SetInput(i, m_ListOfInterpolationSessions[m_SelectedSegmentation].at(i).contour);
    }

    m_ReduceFilter->Update();

    m_CurrentNumberOfReducedContours = m_ReduceFilter->GetNumberOfOutputs();

    for (unsigned int i = 0; i < m_CurrentNumberOfReducedContours; i++)
    {
      m_NormalsFilter->SetInput(i, m_ReduceFilter->GetOutput(i));
      m_InterpolateSurfaceFilter->SetInput(i, m_NormalsFilter->GetOutput(i));
    }
  }
  Modified();
}
コード例 #4
0
void mitk::DiffusionImageCreationFilter::SetReferenceImage( mitk::Image::Pointer reference_image )
{
  if( reference_image.IsNull() )
  {
    mitkThrow() << "Null-pointer image provided as reference. ";
  }

  if( ! DPH::IsDiffusionWeightedImage(reference_image) )
  {
    mitkThrow() << "The image provided as reference is not a diffusion-weighted image. Cannot proceed. ";
  }

  this->m_ReferenceImage = reference_image;
}
bool mitk::SurfaceInterpolationController::ReplaceInterpolationSession(mitk::Image::Pointer oldSession, mitk::Image::Pointer newSession)
{
  if (oldSession.IsNull() || newSession.IsNull())
    return false;

  if (oldSession.GetPointer() == newSession.GetPointer())
    return false;

  if (!mitk::Equal(*(oldSession->GetGeometry()), *(newSession->GetGeometry()), mitk::eps, false))
    return false;

  auto it = m_ListOfInterpolationSessions.find(oldSession.GetPointer());

  if (it == m_ListOfInterpolationSessions.end())
    return false;

  ContourPositionInformationVec2D oldList = (*it).second;
  m_ListOfInterpolationSessions.insert(std::pair<mitk::Image*, ContourPositionInformationVec2D>(newSession.GetPointer(), oldList));
  itk::MemberCommand<SurfaceInterpolationController>::Pointer command = itk::MemberCommand<SurfaceInterpolationController>::New();
  command->SetCallbackFunction(this, &SurfaceInterpolationController::OnSegmentationDeleted);
  m_SegmentationObserverTags.insert( std::pair<mitk::Image*, unsigned long>( newSession, newSession->AddObserver( itk::DeleteEvent(), command ) ) );

  if (m_SelectedSegmentation == oldSession)
    m_SelectedSegmentation = newSession;

  mitk::ImageTimeSelector::Pointer timeSelector = mitk::ImageTimeSelector::New();
  timeSelector->SetInput( m_SelectedSegmentation );
  timeSelector->SetTimeNr( m_CurrentTimeStep );
  timeSelector->SetChannelNr( 0 );
  timeSelector->Update();
  mitk::Image::Pointer refSegImage = timeSelector->GetOutput();
  m_NormalsFilter->SetSegmentationBinaryImage(refSegImage);

  this->RemoveInterpolationSession(oldSession);
  return true;
}
コード例 #6
0
ファイル: mitkPAVolume.cpp プロジェクト: Cdebus/MITK
mitk::pa::Volume::Volume(mitk::Image::Pointer image)
{
  MITK_INFO << "Initialized by mitk::Image";

  if (image.IsNull())
    mitkThrow() << "You may not initialize a mitk::Volume with a null reference to an mitk image";

  unsigned int* dimensions = image->GetDimensions();
  m_YDim = dimensions[0];
  m_XDim = dimensions[1];
  m_ZDim = dimensions[2];

  m_InternalMitkImage = image;

  m_FastAccessDataPointer = GetData();
}
コード例 #7
0
void mitk::DiffusionImageCreationFilter::GenerateData()
{
  const mitk::Image::Pointer input_image = this->GetInput(0);
  if( input_image.IsNull() )
  {
    mitkThrow() << "No input specified. Cannot proceed ";
  }

  if( !( m_HeaderDescriptorSet ^ m_ReferenceImage.IsNotNull() ) )
  {
    mitkThrow() << "Either a header descriptor or a reference diffusion-weighted image have to be provided. Terminating.";
  }

  mitk::Image::Pointer outputForCache = this->GetOutput();

  if( input_image->GetTimeSteps() > 1 )
  {
    mitk::Image::Pointer mitkvectorimage = mitk::GrabItkImageMemory<DPH::ImageType>( RemapIntoVectorImage( input_image ));
    outputForCache->Initialize( mitkvectorimage );
  }
  // no need to remap, we expect to have a vector image directly
  else
  {
    outputForCache->Initialize( input_image );
  }

  // header information
  GradientDirectionContainerType::Pointer DiffusionVectors =  this->InternalGetGradientDirections( );
  MeasurementFrameType MeasurementFrame = this->InternalGetMeasurementFrame();
  float BValue = this->InternalGetBValue();

  // create BValueMap
  mitk::BValueMapProperty::BValueMap BValueMap = mitk::BValueMapProperty::CreateBValueMap( DiffusionVectors, BValue );
  outputForCache->SetProperty( DPH::GRADIENTCONTAINERPROPERTYNAME.c_str(), mitk::GradientDirectionsProperty::New( DiffusionVectors ) );
  outputForCache->SetProperty( DPH::MEASUREMENTFRAMEPROPERTYNAME.c_str(), mitk::MeasurementFrameProperty::New( MeasurementFrame ) );
  outputForCache->SetProperty( DPH::BVALUEMAPPROPERTYNAME.c_str(), mitk::BValueMapProperty::New( BValueMap ) );
  outputForCache->SetProperty( DPH::REFERENCEBVALUEPROPERTYNAME.c_str(), mitk::FloatProperty::New( BValue ) );

  outputForCache->Modified();
}