Commit 543c34d8 authored by Julien Michel's avatar Julien Michel
Browse files

MAJ release notes.

Intégration examples Kullback leibler.
parent 16a5806b
......@@ -82,6 +82,8 @@ namespace Functor {
virtual ~KullbackLeiblerProfile () { }
// Gives the radius min and max of neighborhood
void SetRadius ( const unsigned char & min, const unsigned char & max );
unsigned char GetRadiusMin(void);
unsigned char GetRadiusMax(void);
// Gives the size of the profile
int GetNumberOfComponentsPerPixel() const { return m_mask.size(); }
// functor
......
......@@ -338,6 +338,23 @@ namespace Functor {
MakeMultiscaleProfile();
}
template< class TInput1, class TInput2, class TOutput >
unsigned char
KullbackLeiblerProfile<TInput1,TInput2,TOutput>
::GetRadiusMin(void)
{
return m_RadiusMin;
}
template< class TInput1, class TInput2, class TOutput >
unsigned char
KullbackLeiblerProfile<TInput1,TInput2,TOutput>
::GetRadiusMax(void)
{
return m_RadiusMax;
}
/* ====== Make the set of masks to play the increase in window size == */
template< class TInput1, class TInput2, class TOutput >
......
......@@ -129,6 +129,12 @@ protected:
virtual void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread,
int threadId );
/**
* Since the number of components per pixel depends on the radius range, one must reimplement
* this method to set the proper number of component on the filter output.
*/
virtual void GenerateOutputInformation(void);
RadiusSizeType m_Radius;
private:
......
......@@ -75,12 +75,27 @@ template <class TInputImage1, class TInputImage2,
class TOutputImage, class TFunction >
void
BinaryFunctorNeighborhoodVectorImageFilter<TInputImage1,TInputImage2,TOutputImage,TFunction>
::SetRadius ( const unsigned char & min, const unsigned char & max )
::SetRadius( const unsigned char & min, const unsigned char & max )
{
this->SetRadius( max );
GetFunctor().SetRadius( min, max );
}
/**
* Generate the output information
*/
template <class TInputImage1, class TInputImage2, class TOutputImage, class TFunction >
void
BinaryFunctorNeighborhoodVectorImageFilter<TInputImage1, TInputImage2, TOutputImage, TFunction>
::GenerateOutputInformation(void)
{
Superclass::GenerateOutputInformation();
int nbComponents = static_cast<int>(m_Functor.GetRadiusMax())+1
- static_cast<int>(m_Functor.GetRadiusMin());
this->GetOutput()->SetNumberOfComponentsPerPixel(nbComponents);
}
/**
* ThreadedGenerateData Performs the neighborhood-wise operation
......
......@@ -22,6 +22,8 @@ TARGET_LINK_LIBRARIES(JHMIChDet OTBIO OTBCommon gdal ITKCommon ITKIO ITKStatisti
ADD_EXECUTABLE(KullbackLeiblerDistanceChDet KullbackLeiblerDistanceChDet.cxx)
TARGET_LINK_LIBRARIES(KullbackLeiblerDistanceChDet OTBIO OTBCommon gdal ITKCommon ITKIO ITKStatistics)
ADD_EXECUTABLE(KullbackLeiblerProfileChDet KullbackLeiblerProfileChDet.cxx)
TARGET_LINK_LIBRARIES(KullbackLeiblerProfileChDet OTBIO OTBCommon gdal ITKCommon ITKIO ITKStatistics)
IF( NOT OTB_DISABLE_CXX_TESTING AND NOT OTB_DISABLE_CXX_EXAMPLES_TESTING)
......@@ -84,7 +86,20 @@ ADD_TEST(KullbackLeiblerDistanceChDetTest ${EXE_TESTS}
${INPUTDATA}/GomaAvant.png
${INPUTDATA}/GomaApres.png
${TEMP}/KullbackLeiblerDistanceChDetTest.png
35
35
)
# ------- KullbackLeiblerProfileChDetTest----------
ADD_TEST(KullbackLeiblerProfileChDetTest ${EXE_TESTS}
--compare-n-images ${TOL} 1
${BASELINE}/KullbackLeiblerProfileChDetTest.png
${TEMP}/KullbackLeiblerProfileChDet.png
KullbackLeiblerProfileChDetTest
${INPUTDATA}/GomaAvant.png
${INPUTDATA}/GomaApres.png
${TEMP}/KullbackLeiblerProfileChDetTest.png
5 51 1 12 24
)
INCLUDE_DIRECTORIES("${OTBTesting_BINARY_DIR}")
......
......@@ -27,24 +27,15 @@
// \doxygen{otb}{KullbackLeiblerDistanceImageFilter} for detecting changes
// between pairs of images. This filter computes the Kullback-Leibler
// distance between probability density functions (pdfs).
// In the neighborhood of each pixel of the pair of images $I_1$ and $I_2$
// to be compared, the distance between local pdfs $f_1$ and $f_2$ of random
// variables $X_1$ and $X_2$ is evaluated by:
// \begin{align}
// {\cal K}(X_1,X_2) &= K(X_1|X_2) + K(X_2|X_1) \\
// \text{with} \qquad
// K(X_j | X_i) &= \int_{\mathbbm{R}}
// \log \frac{f_{X_i}(x)}{f_{X_j}(x)} f_{X_i}(x) dx,\qquad i,j=1,2.
// \end{align}
// Instead of estimating pdfs $f_1$ and $f_2$ by using an histogram technique,
// moments, up to order 4, are estimated to perform an Edgeworth development
// of $f_1$ and $f_2$. Then, the Kullback-Leibler distance is evaluated by an
// cumulant-based approximation:
// In fact, the Kullback-Leibler distance is itself approximated through
// a cumulant-based expansion, since the pdfs are approximated through an
// Egdeworth series.
// The Kullback-Leibler distance is evaluated by:
// \begin{multline}\label{eqKLapprox1D}
// K_{\text{Edgeworth}}(X_1 | X_2) = \frac{1}{12} \frac{\kappa_{X_1;3}^2}{\kappa_{X_1;2}^2}
// + \frac{1}{2} \left( \log \frac{\kappa_{X_2;2}}{\kappa_{X_1;2}}
// -1+\frac{1}{\kappa_{X_2;2}}
// \left( \kappa_{X_1;1} - \kappa_{X_2;1} + \kappa_{X_1;2}^{1/2} \right)^2
// -1+\frac{1}{\kappa_{X_2;2}}
// \left( \kappa_{X_1;1} - \kappa_{X_2;1} + \kappa_{X_1;2}^{1/2} \right)^2
// \right) \\
// - \left( \kappa_{X_2;3} \frac{a_1}{6} + \kappa_{X_2;4} \frac{a_2}{24}
// + \kappa_{X_2;3}^2 \frac{a_3}{72} \right)
......@@ -72,12 +63,13 @@
// $\kappa_{X_i;1}$, $\kappa_{X_i;2}$, $\kappa_{X_i;3}$ and $\kappa_{X_i;4}$
// are the cumulants up to order 4 of the random variable $X_i$ ($i=1,2$).
// This example will use the images shown in
// figure ~\ref{fig:RATCHDETINIM}. These correspond to 2 Radarsat fine
// figure~\ref{fig:RATCHDETINIM}. These correspond to 2 Radarsat fine
// mode acquisitions before and after a lava flow resulting from a
// volcanic eruption.
//
// The program itself is very similar to the ratio of mean detector,
// implemented in \doxygen{otb}{MeanRatioImageFilter}. Nevertheless
// implemented in \doxygen{otb}{MeanRatioImageFilter}, *
// in section~\ref{sec:RatioOfMeans}. Nevertheless
// the corresponding header file has to be used instead.
//
// Software Guide : EndLatex
......@@ -151,7 +143,7 @@ int main(int argc, char * argv[])
// Software Guide : BeginLatex
//
// The only parametter for this change detector is the radius of
// The only parameter for this change detector is the radius of
// the window used for computing the cumulants.
//
// Software Guide : EndLatex
......@@ -215,3 +207,4 @@ int main(int argc, char * argv[])
return EXIT_SUCCESS;
}
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
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.
=========================================================================*/
// Software Guide : BeginCommandLineArgs
// INPUTS: {GomaAvant.png}, {GomaApres.png}
// OUTPUTS: {KLProfileChDet.png}
// 5 51 1 12 24
// Software Guide : EndCommandLineArgs
// Software Guide : BeginLatex
//
// This example illustrates the class
// \doxygen{otb}{KullbackLeiblerProfileImageFilter} for detecting changes
// between pairs of images, according to a range of window size.
// This example is very similar, in its principle, to all of the change
// detection examples, especially the distance between distribution one
// (section~\ref{sec:KullbackLeiblerDistance} which uses a fixed window size.
//
// The main differences are:
// \begin{enumerate}
// \item a set of window range instead of a fixed size of window;
// \item an output of type \doxygen[otb}{VectorImage}.
// \end{enumerate}
// Then, the program begins with the \doxygen{otb}{VectorImage} and the
// \doxygen{otb}{KullbackLeiblerProfileImageFilter} header files in complements
// to those already details in the \doxygen{otb}{MeanRatioImageFilter} example.
//
// Software Guide : EndLatex
#include "itkExceptionObject.h"
#include "otbImage.h"
#include "otbMultiChannelExtractROI.h"
#include "otbVectorRescaleIntensityImageFilter.h"
// Software Guide : BeginCodeSnippet
#include "otbVectorImage.h"
// Software Guide : EndCodeSnippet
#include "otbImageFileReader.h"
#include "otbImageFileWriter.h"
// Software Guide : BeginCodeSnippet
#include "otbKullbackLeiblerProfileImageFilter.h"
// Software Guide : EndCodeSnippet
int main(int argc, char * argv[])
{
try
{
if(argc != 9)
{
std::cerr<<"Detection de changements par mesure de Kullback-Leibler, optimisee par un developpement de Edgeworth\n";
std::cerr << argv[0] << " imgAv imgAp imgResu winSizeMin winSizeMax outRedIndex outGreenIndex outBlueIndex\n";
return 1;
}
char * fileName1 = argv[1];
char * fileName2 = argv[2];
char * fileNameOut = argv[3];
int winSizeMin = atoi(argv[4]);
int winSizeMax = atoi(argv[5]);
unsigned int ri = atoi(argv[6]);
unsigned int gi = atoi(argv[7]);
unsigned int bi = atoi(argv[8]);
const unsigned int Dimension = 2;
typedef double PixelType;
typedef unsigned char OutPixelType;
// Software Guide : BeginLatex
//
// The \doxygen{otb}{KullbackLeiblerProfileImageFilter} is templated over
// the types of the two input images and the type of the generated change
// image (which is now of multi-component), in a similar way as the
// \doxygen{otb}{KullbackLeiblerDistanceImageFilter}.
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
typedef otb::Image<PixelType,Dimension> ImageType;
typedef otb::VectorImage<PixelType,Dimension> VectorImageType;
typedef otb::KullbackLeiblerProfileImageFilter<ImageType,ImageType,VectorImageType> FilterType;
// Software Guide : EndCodeSnippet
typedef otb::VectorImage<OutPixelType,Dimension> OutVectorImageType;
typedef otb::ImageFileReader<ImageType> ReaderType;
typedef otb::ImageFileWriter<OutVectorImageType> WriterType;
typedef otb::MultiChannelExtractROI<PixelType,PixelType> ChannelSelecterType;
typedef otb::VectorRescaleIntensityImageFilter<VectorImageType,OutVectorImageType> RescalerType;
ReaderType::Pointer reader1 = ReaderType::New();
reader1->SetFileName( fileName1 );
ReaderType::Pointer reader2 = ReaderType::New();
reader2->SetFileName( fileName2 );
// Software Guide : BeginLatex
//
// The different elements of the pipeline can now be instantiated in the
// same way as the ratio of mean change detector example.
//
// Two parameters are now required to give the minimum and the maximum size
// of the analysis window. The program will begin by performing change
// detection through the smaller window size and then applying moments update
// of eq.~\eqref{eqMomentN} by incrementing the radius of the analysis window
// (i.e. add a ring of width 1 pixel arround the current neightborhood shape).
// The process is applied until the larger window size is reached.
//
// Software Guide : EndLatex
//
// Software Guide : BeginCodeSnippet
FilterType::Pointer filter = FilterType::New();
filter->SetRadius( (winSizeMin-1)/2,(winSizeMax-1)/2 );
filter->SetInput1( reader1->GetOutput() );
filter->SetInput2( reader2->GetOutput() );
// Software Guide : EndCodeSnippet
ChannelSelecterType::Pointer channelSelecter = ChannelSelecterType::New();
channelSelecter->SetInput(filter->GetOutput());
channelSelecter->SetChannel(ri);
channelSelecter->SetChannel(gi);
channelSelecter->SetChannel(bi);
RescalerType::Pointer rescaler = RescalerType::New();
rescaler->SetInput(channelSelecter->GetOutput());
OutVectorImageType::PixelType min,max;
min.SetSize(3);
max.SetSize(3);
min.Fill(0);
max.Fill(255);
rescaler->SetOutputMinimum(min);
rescaler->SetOutputMaximum(max);
WriterType::Pointer writer = WriterType::New();
writer->SetFileName(fileNameOut);
writer->SetInput(rescaler->GetOutput());
writer->Update();
// Software Guide : BeginLatex
//
// Figure \ref{fig:RESKLPCHDET} shows the result of the change
// detection by computing the Kullback-Leibler distance between
// local pdf through an Edgeworth approximation.
// \begin{figure}
// \center
// \includegraphics[width=0.35\textwidth]{KLProfileChDet.eps}
// \itkcaption[Kullback-Leibler profile Change Detection Results]{Result of the
// Kullback-Leibler profile change detector, colored composition including the first, 12th and 24th
// channel of the generated output.}
// \label{fig:RESKLPCHDET}
// \end{figure}
//
// Software Guide : EndLatex
}
catch( itk::ExceptionObject & err )
{
std::cout << "Exception itk::ExceptionObject thrown !" << std::endl;
std::cout << err << std::endl;
return EXIT_FAILURE;
}
catch( ... )
{
std::cout << "Unknown exception thrown !" << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
......@@ -29,6 +29,7 @@ REGISTER_TEST(CorrelChDetTest);
REGISTER_TEST(DiffChDetTest);
REGISTER_TEST(RatioChDetTest);
REGISTER_TEST(KullbackLeiblerDistanceChDetTest);
REGISTER_TEST(KullbackLeiblerProfileChDetTest);
}
#undef main
......@@ -46,3 +47,7 @@ REGISTER_TEST(KullbackLeiblerDistanceChDetTest);
#undef main
#define main KullbackLeiblerDistanceChDetTest
#include "KullbackLeiblerDistanceChDet.cxx"
#undef main
#define main KullbackLeiblerProfileChDetTest
#include "KullbackLeiblerProfileChDet.cxx"
OTB-v.1.4.0 - Changes since version 1.2.1
-----------------------------------------
*IO:
- Added the LineSpatialObject class.
- Added the ArcSpatialObject class.
- Added a DXF file reader to read spatial objects from DXF files.
*Common:
- Added a PolylineParametricPathWithValue class, to store a likehood value along with
a polyline.
- DrawPathFilter and DrawPathListFilter can now use the internal likehood values of the path
(if present) as a value to draw the path.
- Improved performances of the DrawPathFilter and DrawPathListFilter.
- Added the base class otbBinaryFunctorNeighborhoodVectorImageFilter (see ChangeDetection)
*BasicFilters:
- Added the ImportGeoInformationImageFilter providing a workaround for metadata handling
in pipeline execution.
- Added a VectorRescaleIntensityImageFilter, which rescale a vector image on a per-band basis,
clamping a user-defined percent of the pixels lowest and highest values.
- Added a filter to compute spectral angle distance image with respect to a reference pixel.
*FeatureExtraction:
- Added a set of image and path filters to perform road extraction.
- Added a composite filter to perform road extraction.
* ChangeDetection:
- Added the Kullback-Leibler distance change detector with optimized algorithm.
- Added a Kullback-Leibler multi-scale change profile image filter with optimized algorithm.
* DisparityMap:
- Added the DisparityMapEstimationMethod, performing local disparity estimation with respect
to a given transform using the ITK registration framework.
- Added several method for deformation field estimation from the estimated disparity map
(represented as a pointset with associated point data).
*Documentation:
- Corrected several warning and french comments in doxygen.
*Utilities:
- Split of the OSSIM lib to support compilation on the mingw platform.
- DXFlib integration.
- InsightJournal code integration : ScatteredDataPointSetImageFilter.
*Platforms:
- Corrected runtime errors of the interactive change detection application under cygwin.
- Workaround for ImageViewer on very specific mandrake version.
OTB-v.1.2.1 - Changes since version 1.2.0
-----------------------------------------
......
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