Commit d107df83 authored by Manuel Grizonnet's avatar Manuel Grizonnet

STYLE:kwstyle

parent 41a1eb14
......@@ -34,61 +34,55 @@ namespace otb
\*
\* This class is meant to be used in the MRF framework with the otb:: MarkovRandomFieldFilter
*/
*/
template< class TInput1, class TInput2>
class ITK_EXPORT MRFEnergyFisherClassification:public MRFEnergy< TInput1, TInput2>
{
public:
typedef MRFEnergyFisherClassification Self;
typedef MRFEnergy< TInput1, TInput2> Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
typedef TInput1 InputImageType;
typedef TInput2 LabelledImageType;
typedef typename InputImageType::PixelType InputImagePixelType;
typedef typename LabelledImageType::PixelType LabelledImagePixelType;
typedef itk::Array < double > ParametersType;
itkNewMacro(Self);
itkTypeMacro(MRFEnergyFisherClassification, MRFEnergy);
Gamma g;
void SetNumberOfParameters(const unsigned int nParameters)
{
Superclass::SetNumberOfParameters(nParameters);
this->m_Parameters.SetSize(nParameters);
this->Modified();
}
double GetSingleValue(const InputImagePixelType & value1, const LabelledImagePixelType & value2)
{
if ((unsigned int)value2 >= this->GetNumberOfParameters()/3)
{
itkExceptionMacro(<<"Number of parameters does not correspond to number of classes" );
}
double val1 = static_cast<double>(value1);
double mu = this->m_Parameters[3*static_cast<double>(value2)] ;
double l = this->m_Parameters[3*static_cast<double>(value2)+1] ;
double m = this->m_Parameters[3*static_cast<double>(value2)+2] ;
double result = -vcl_log((g.gamma(l+m)/(g.gamma(l)*g.gamma(m))) * (2/(mu)) * (vcl_sqrt(l/m)) *
((pow((vcl_sqrt(l/m)*(val1/mu)),((2*l)-1))) / (pow(1+(vcl_sqrt(l/m)*(val1/mu)*vcl_sqrt(l/m)*(val1/mu)),(l+m)))));
return static_cast<double>( result );
}
{
public:
typedef MRFEnergyFisherClassification Self;
typedef MRFEnergy< TInput1, TInput2> Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
typedef TInput1 InputImageType;
typedef TInput2 LabelledImageType;
typedef typename InputImageType::PixelType InputImagePixelType;
typedef typename LabelledImageType::PixelType LabelledImagePixelType;
typedef itk::Array < double > ParametersType;
itkNewMacro(Self);
itkTypeMacro(MRFEnergyFisherClassification, MRFEnergy);
Gamma g;
void SetNumberOfParameters(const unsigned int nParameters)
{
Superclass::SetNumberOfParameters(nParameters);
this->m_Parameters.SetSize(nParameters);
this->Modified();
}
protected:
// The constructor and destructor.
MRFEnergyFisherClassification() {};
virtual ~MRFEnergyFisherClassification() {};
double GetSingleValue(const InputImagePixelType & value1, const LabelledImagePixelType & value2)
{
if ((unsigned int)value2 >= this->GetNumberOfParameters()/3)
{
itkExceptionMacro(<<"Number of parameters does not correspond to number of classes" );
}
double val1 = static_cast<double>(value1);
double mu = this->m_Parameters[3*static_cast<double>(value2)];
double l = this->m_Parameters[3*static_cast<double>(value2)+1];
double m = this->m_Parameters[3*static_cast<double>(value2)+2];
double result = -vcl_log((g.gamma(l+m)/(g.gamma(l)*g.gamma(m))) * (2/(mu)) * (vcl_sqrt(l/m)) *
((pow((vcl_sqrt(l/m)*(val1/mu)),((2*l)-1))) /
(pow(1+(vcl_sqrt(l/m)*(val1/mu)*vcl_sqrt(l/m)*(val1/mu)),(l+m)))));
return static_cast<double>( result );
}
protected:
// The constructor and destructor.
MRFEnergyFisherClassification() {};
virtual ~MRFEnergyFisherClassification() {};
};
}
#endif
......@@ -36,7 +36,8 @@
// The optimization is done using a Metropolis algorithm with a random sampler. The
// regularization energy is defined by a Potts model and the fidelity or likelihood energy is modelled by a
// Fisher distribution.
// The parameter of the fisher distribution was determined for each class in a supervised step. ( See the File OtbParameterEstimatioOfFisherDistribution )
// The parameter of the fisher distribution was determined for each class in a supervised step.
// ( See the File OtbParameterEstimatioOfFisherDistribution )
// This example is a contribution from Jan Wegner.
//
// Software Guide : EndLatex
......@@ -65,7 +66,8 @@ int main(int argc, char* argv[] )
{
std::cerr << "Missing Parameters "<< argc << std::endl;
std::cerr << "Usage: " << argv[0];
std::cerr << " inputImage output_gray_label output_color_label lambda iterations optimizerTemperature useRandomValue " << std::endl;
std::cerr << " inputImage output_gray_label output_color_label lambda iterations "
"optimizerTemperature useRandomValue " << std::endl;
return 1;
}
// Software Guide : BeginLatex
......@@ -79,9 +81,10 @@ int main(int argc, char* argv[] )
// Software Guide : BeginCodeSnippet
const unsigned int Dimension = 2;
typedef double InternalPixelType;
typedef double InternalPixelType;
typedef unsigned char LabelledPixelType;
typedef otb::Image<InternalPixelType, Dimension> InputImageType;
typedef otb::Image<InternalPixelType, Dimension> InputImageType;
typedef otb::Image<LabelledPixelType, Dimension> LabelledImageType;
// Software Guide : EndCodeSnippet
......@@ -94,7 +97,7 @@ int main(int argc, char* argv[] )
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
typedef otb::ImageFileReader< InputImageType > ReaderType;
typedef otb::ImageFileReader< InputImageType > ReaderType;
typedef otb::StreamingImageFileWriter< LabelledImageType > WriterType;
ReaderType::Pointer reader = ReaderType::New();
......@@ -165,7 +168,7 @@ int main(int argc, char* argv[] )
typedef otb::MRFEnergyPotts
<LabelledImageType, LabelledImageType> EnergyRegularizationType;
typedef otb::MRFEnergyFisherClassification
<InputImageType, LabelledImageType> EnergyFidelityType;
<InputImageType, LabelledImageType> EnergyFidelityType;
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
......@@ -185,7 +188,8 @@ int main(int argc, char* argv[] )
// Software Guide : BeginLatex
//
// Parameter for the MRFEnergyFisherClassification class are created. The shape parameters M,L and the weighting parameter mu are computed in a supervised step
// Parameter for the MRFEnergyFisherClassification class are created. The shape parameters M,L
// and the weighting parameter mu are computed in a supervised step
//
// Software Guide : EndLatex
......@@ -268,10 +272,10 @@ int main(int argc, char* argv[] )
writer->Update();
// Software Guide : EndCodeSnippet
//convert output image to color
typedef itk::RGBPixel<unsigned char> RGBPixelType;
typedef otb::Image<RGBPixelType, 2> RGBImageType;
typedef itk::Functor::ScalarToRGBPixelFunctor<unsigned long>
ColorMapFunctorType;
typedef itk::RGBPixel<unsigned char> RGBPixelType;
typedef otb::Image<RGBPixelType, 2> RGBImageType;
typedef itk::Functor::ScalarToRGBPixelFunctor<unsigned long> ColorMapFunctorType;
typedef itk::UnaryFunctorImageFilter< LabelledImageType,RGBImageType,ColorMapFunctorType> ColorMapFilterType;
ColorMapFilterType::Pointer colormapper = ColorMapFilterType::New();
......
......@@ -6,20 +6,19 @@
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
// this file defines the otbMultiScaleTest for the test driver
// and all it expects is that you have a function called RegisterTests
=========================================================================*/
#if defined(_MSC_VER)
#pragma warning ( disable : 4786 )
#endif
#include <iostream>
#include "otbTestMain.h"
......
......@@ -73,4 +73,3 @@ int otbMRFEnergyFisherClassification(int argc, char * argv[])
return EXIT_SUCCESS;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment