[Insight-users] an expansion to LiverTumorSegmentation but with display error

diaoxianfen diaoxianfen at asisz.com
Sat Nov 20 22:49:43 EST 2004


Hi Luis,
   Hope you will help me again.
I want to use LiverTumorSegmentation to do segmentation.But I intend to extract a subregion and do segmentation on this subregion.
By two times respond to LeftButtonPressEvent I register the region.For example, in different z-axial slices I click the left button and register the positions.Then the two position record a cuboid region.The functions as follows:
// record a position in three dimensions
void LiverTumorSegmentation::RecordStartPoint()
{
 m_StartPoint[0] = int(saggitalViewSlider->value());
 m_StartPoint[1] = int(coronalViewSlider->value());
 m_StartPoint[2] = int(axialViewSlider->value());
 
}
//record another positon in three dimensions
void LiverTumorSegmentation::RecordEndPoint()
{
 m_EndPoint[0] = int(saggitalViewSlider->value());
 m_EndPoint[1] = int(coronalViewSlider->value());
 m_EndPoint[2] = int(axialViewSlider->value());
 
}
//extract region
void LiverTumorSegmentation::ExtractRegion()
{   
 typedef itk::Image<unsigned char ,3>  OutputImageType;
 OutputImageType::Pointer m_ExtractedImage = OutputImageType::New();
 if(m_LoadedVolume)
 {
  OutputImageType::IndexType index; 
  index[0]=m_StartPoint[0];
  index[1]=m_StartPoint[1];
  index[2]=m_StartPoint[2];
  if(m_LoadedVolume->GetLargestPossibleRegion().IsInside( index))
  {   
  }
  else
  {
   fl_message("Index is out of largest region");
  }
  index[0]=m_EndPoint[0];
  index[1]=m_EndPoint[1];
  index[2]=m_EndPoint[2];
  if(m_LoadedVolume->GetLargestPossibleRegion().IsInside( index))
  {
  }
  else
  {
   fl_message("Index is out of largest region");
  } 
  
  OutputImageType::IndexType tempIndex; 
  if(m_StartPoint[0]<m_EndPoint[0])
  {
   tempIndex[0]=m_StartPoint[0];
  }
  else
  {
   tempIndex[0]=m_EndPoint[0];
  }
  
  if(m_StartPoint[1]<m_EndPoint[1])
  {
   tempIndex[1]=m_StartPoint[1];
  }
  else
  {
   tempIndex[1]=m_EndPoint[1];
  }
  
  if(m_StartPoint[2]<m_EndPoint[2])
  {
   tempIndex[2]=m_StartPoint[2];
  }
  else
  {
   tempIndex[2]=m_EndPoint[2];
  }    
  
  
  OutputImageType::IndexType start;
  start[0] = 0;
  start[1] = 0;
  start[2] = 0;
  
  OutputImageType::SizeType size;
  size[0] = abs(m_EndPoint[0] - m_StartPoint[0]+1);
  size[1] = abs(m_EndPoint[1] - m_StartPoint[1]+1);
  size[2] = abs(m_EndPoint[2] - m_StartPoint[2]+1);
  
  OutputImageType::RegionType desiredRegion;
  desiredRegion.SetSize( size );
  desiredRegion.SetIndex( start );
  
  m_ExtractedImage->SetRegions(desiredRegion);
  m_ExtractedImage->Allocate();

  OutputImageType::SpacingType sp;
  sp=m_LoadedVolume->GetSpacing();  
  m_ExtractedImage->SetSpacing(sp);
  
  double origin[3];
  origin[0] = m_LoadedVolume->GetOrigin()[0];
  origin[1] = m_LoadedVolume->GetOrigin()[1];
  origin[2] = m_LoadedVolume->GetOrigin()[2];
  
  double newOrigin[3];
  newOrigin[0] = origin[0]+sp[0]*tempIndex[0];
  newOrigin[1] = origin[1]+sp[1]*tempIndex[1];
  newOrigin[2] = origin[2]+sp[2]*tempIndex[2];
  m_ExtractedImage->SetOrigin(newOrigin);
  OutputImageType::IndexType pixelIndex;
  OutputImageType::IndexType corPixelIndex;
  OutputImageType::PixelType pixelValue;
  for(int i=0;i<size[0];i++)
  {
   pixelIndex[0] = i;
   corPixelIndex[0] = i+tempIndex[0];
   for(int j=0;j<size[1];j++)
   {
    pixelIndex[1] = j;
    corPixelIndex[1] = j+tempIndex[1];
    for(int k=0;k<size[2];k++)
    {
     pixelIndex[2]=k;
     corPixelIndex[2]=k+tempIndex[2];
     pixelValue = m_LoadedVolume->GetPixel(corPixelIndex);
     m_ExtractedImage->SetPixel(pixelIndex,pixelValue);
     
    }
   }
  }
  
 } 
 
 
 m_LoadedVolume = m_ExtractedImage;
 
 m_ShiftScaleImageFilter->SetInput( m_ITK2VTKAdaptor->GetOutput() );
 
 this->SetSegmentedVolumeOpacityControlOff();
 
 this->LoadPostProcessing();
 
}

In the LiverTumorSegmentation I added the "int m_StartPoint[3]" and "int m_EndPoint[3]".


By these functions I get the interested region.But the display is still slantwise.I write the m_ExtractedImage to a MetaImage File.This file can be viewed by SNAP.
Is there something wrong?Why the visualization is slant? I really need your help.

Thanks
Diaoxianfen

 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20041121/67c0dcc2/attachment.htm


More information about the Insight-users mailing list