Thirion's registration filter is templated over the fixed  , moving image and the output image types.·
It takes in 2 input images registers them, generates a deformation field and writes out the registered output image.

We implement the algorithm by parsing the input , preprocessing them and
registring the processed images.

1.Parsing
The images are initialized by the ValidationInputParser . This function reads
in the arguments from the parameter file.It also sets the orientation of the 
moving image to that of the fixed image. 

2.PreProcessing
In the next step the DemonsPreProcessor normalizes the images and does the
histogram matching. It uses 3 itk filters itkHistogramMatchingImageFilter
itkMinimumMaximumImageFilter and itkShiftScaleImageFilter .

We get the minimum and maximum of the image by the itkMinMaxImageFilter and
normalizing is done by the shiftscale filter. 
ItkShiftScaleImageFilter shifts the input pixel by Shift  and then
 scales the pixel by Scale . All computattions are performed in 
the precison of the input pixel's RealType. Before assigning the computed 
value to the output pixel, the value is clamped at the NonpositiveMin and
max of the pixel type. 

The normalized images are given as inputs to the itkHistogramMatching filter.
ITKHistogramMatchingImageFilter normalizes the grayscale values of a source 
image based on the grayscale values of a reference image. This filter uses
 a histogram matching technique where the histograms of the two images are 
 matched only at a specified number of quantile values.
 
 3.Registration
 The resulting moving Image and the fixed image are given as inputs to the
 demons registrator. This implements the demons deformable  algorithm that
  register two images by computing the deformation field which will map a 
  moving image onto a fixed image.

 A deformation field is represented as a image whose pixel type is some vector
 type with at least N elements, where N is the dimension of the fixed image. 
 The vector type must support element access via operator []. 
 It is assumed that the vector elements behave like floating point scalars.
 Each vector in the deformation field represent the distance between a 
geometric point in the input space and a point in the output space.

 The output image is generated by warping the input image with the deformation
 field  using the ItkWarpImageFilter.
WarpImageFilter warps an existing image with respect to a given deformation
 field.The output image is produced by inverse mapping: the output pixels are
  mapped back onto the input image. 
  This scheme avoids the creation of any holes and overlaps in the output image.
  Typically the mapped position does not correspond to an integer pixel position in the input image. Interpolation via an image function is used to compute values at non-integer positions. 

  We have used the LinearInterpolateImageFunction for our application. 
  Position mapped to outside of the input image buffer are assigned a edge padding value.
The LargetPossibleRegion for the output is inherited from the input deformation
 field.


The methods used by the filter are
//Set the Moving Image.
SetTheMovingImageFilename( std::string MovingImagefilename );
//Set the Fixed Image.
SetTheFixedImageFilename( std::string FixedImagefilename );
//Set the parameter filename.
SetParameterFilename( std::string parameterfile );
//If you want the output displacement fields set the prefix of the displacement field. Suffix of _xdisp.hdr,_ydisp.hdr,_zdisp.hdr will be added to it.
SetDisplacementBaseName(std::string displacementprefixname);
//The checkerboard output will be written by
SetCheckerBoardFilename(std::string Checkerfilename);
//The checker board pattern will be specified by
SetCheckerBoardPattern(unsigned int checkerarray)
//Set Output filename.
SetWarpedImageName( std::string Outputfilename);






