[Insight-users] circles looking like squares?

Seniha Esen Yuksel eseny99 at yahoo.com
Thu Oct 6 16:10:45 EDT 2005


I received my email back only as an attachment, so I am sending the text part again. And the attachment is at
http://public.kitware.com/pipermail/insight-users/attachments/20051006/686a1039/userInitialization.bin
 
Thanks!
 
Hi all,
 
I am trying to make 3 user defined circles ( filled black on white background), so I defined an image and let a fastmarchingfilter grow on the 3 seeds with speed 1 and stopping time = radius. However, the outcome is not 3 spheres but 3 squares (somewhat) -- I am attaching the image. Do you have any idea why this happened? 
 
A second question is, I added an adaptor into this function but it doesn't seem to make any difference. Could you please inform me more on where we need to use adaptors?
 
And below is the code....
 
#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkRescaleIntensityImageFilter.h"
#include "itkGradientAnisotropicDiffusionImageFilter.h"
#include "iostream.h"
#include "itkFastMarchingImageFilter.h"
#include "itkImageAdaptor.h"
class CastPixelAccessor
{
public:
typedef unsigned char InternalType;
typedef float ExternalType;
static void Set(InternalType & output, const ExternalType & input)
{
output = static_cast<InternalType>( input );
}
static ExternalType Get( const InternalType & input )
{
return static_cast<ExternalType>( input );
}
};
 
int main( int argc, char * argv[] )
{
 
....
....
 
typedef itk::Image< unsigned char, 2 > ImageType;
ImageType::Pointer deformableImage = ImageType::New();
.....
....
  deformableImage->SetRegions( region );
  deformableImage->Allocate();
  deformableImage->FillBuffer(0);
  deformableImage->Update();
  
  
  float Radius = 20;
  typedef itk::FastMarchingImageFilter<ImageType,ImageType> FastMarchingFilterType;
 
  FastMarchingFilterType::Pointer fastMarching = FastMarchingFilterType::New();
  typedef FastMarchingFilterType::NodeContainer NodeContainer;
  typedef FastMarchingFilterType::NodeType NodeType;
  
  NodeType node1;
  NodeType node2;
  NodeType node3;
  
  node1.SetValue(0.0);
  node2.SetValue(0.0);
  node3.SetValue(0.0);
 
  NodeContainer::Pointer seeds = NodeContainer::New();
  ImageType::IndexType seed1  = {89,128};
  ImageType::IndexType seed2 = {91,305};
  ImageType::IndexType seed3 = {253,80};
  node1.SetIndex(seed1);
  node2.SetIndex(seed2);
  node3.SetIndex(seed3);
  seeds->InsertElement(0, node1);
  seeds->InsertElement(1, node2);
  seeds->InsertElement(2, node3);
  fastMarching->SetTrialPoints(seeds);
  fastMarching->SetSpeedConstant(1.0);


//define an adaptor
  typedef itk::ImageAdaptor< ImageType, CastPixelAccessor > ImageAdaptorType;
  ImageAdaptorType::Pointer adaptor = ImageAdaptorType::New();
  adaptor->SetImage( deformableImage);

 fastMarching->SetOutputSize(adaptor->GetBufferedRegion().GetSize());
 fastMarching->SetStoppingValue(Radius);
 fastMarching->Update();
 

  //test if the image is working
  //typedef unsigned char WritePixelType;
  typedef itk::Image< WritePixelType, 2 > WriteImageType;
  typedef itk::ImageFileWriter< WriteImageType >  WriterType;
  writer->SetFileName("userInitialization.png" );
  writer->SetInput( fastMarching->GetOutput() );
  writer->Update();
 
  return 0;
}

 
-----------------------------------------------------------------------------------
 
Thank you very much for all your answers up until now and for all the coming ones. I really appreciate your help a lot. 
 
Seniha




Seniha Esen Yuksel 
Research Assistant 
Computer Vision and Image Processing Lab, 
Lutz Hall Rm 414, 
University of Louisville, 
Louisville, KY 
work ph: 502- 8521528 
home ph: 502- 8549856 
email: esen at cvip.uofl.edu // esenyuksel at ieee.org 
web: http://www.cvip.louisville.edu/~esen/

		
---------------------------------
Yahoo! for Good
 Click here to donate to the Hurricane Katrina relief effort. 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20051006/ce2d6a87/attachment.htm


More information about the Insight-users mailing list