- stllcv_0_7_7.zip
- stllcv_0_7_7
- stllcv_0_5_1.zip
- stllcv_0_5_1
- Doxyfile
- include
- stllcv
- LICENSE
- src
- stllcv_0_7_5.zip
- stllcv_0_7_5
- stllcv_0_7_2.zip
- stllcv_0_7_2
- include
- stllcv
- src
- example
- basicimage.cpp
- basicimage.vcproj
- basicimage.vcproj.LETSNOTE.niitsuma.user
- basicimage.vcproj.REX.niitsuma.user
- CvMatWrap.cpp
- CvMatWrap.vcproj
- CvMatWrap.vcproj.LETSNOTE.niitsuma.user
- CvMatWrap.vcproj.REX.niitsuma.user
- gil_wrap_iplimage_example.cpp
- gil_wrap_iplimage_example.vcproj
- histogram.cpp
- histogram.vcproj
- histogram.vcproj.LETSNOTE.niitsuma.user
- histogram.vcproj.REX.niitsuma.user
- lena.jpg
- lena2.jpg
- matrix.cpp
- matrix.vcproj
- matrix.vcproj.LETSNOTE.niitsuma.user
- matrix.vcproj.REX.niitsuma.user
- test.jpg
- Imageregistration
- lena.jpg
- lena2.jpg
- lenaSub.jpg
- PhaseOnlyCorrelation.cpp
- PhaseOnlyCorrelation.vcproj
- PhaseOnlyCorrelation.vcproj.LETSNOTE.niitsuma.user
- PhaseOnlyCorrelation.vcproj.REX.niitsuma.user
- stllcv.sln
|
#include "stllcv/iplvhistogram.hxx"
#include "stllcv/iplvbasicimage.hxx"
#include "highgui.h"
#define PEXORGIMG unsigned char
#if !DebugFileRead
#define Filename argv[1]
#define Filename2 argv[2]
#define OutImageName argv[3]
#endif
float iplvMutualInformation(
CiplvHistogram<1> &hist1
,CiplvHistogram<1> &hist2
,CiplvHistogram<2> &hist12)
{
float sum=0;
float N=hist1.size(0);
vigra::MultiIterator< 1, float> i1=hist1.traverser_begin() ,iend1=hist1.traverser_end();
//vigra::MultiIterator< 2, float> i;
//i3.template dim<1>()++; // increment outer dimension
//i3.template dim<0>()++; // increment inner dimension
vigra::MultiIterator<2, float> k2 = hist12.traverser_begin(),kend2 =hist12.traverser_end();
for(; k2 != kend2; ++k2, ++i1)
{
vigra::MultiIterator< 1, float> j1=hist2.traverser_begin() ,jend1=hist2.traverser_end();
vigra::MultiIterator<2, float>::next_type k1 = k2.begin(), kend1 = k2.end();
for(; k1 != kend1; ++k1, ++j1)
{
if(k1[0]>0 && i1[0]>0 && j1[0]>0){
sum += k1[0]/N * log( k1[0]*N/(i1[0])*(j1[0]) ); // do something with the current element
}
}
}
return sum;
}
int main( int argc, char** argv )
{
CiplvBasicImage<PEXORGIMG> image1("lena.jpg");
CiplvBasicImage<PEXORGIMG> image2("lena2.jpg");
int hist_size = 256;
float range_0[]={0,255};
float* ranges[]={ range_0 };
CiplvHistogram<1> hist1(&hist_size,ranges);
CiplvHistogram<1> hist2(&hist_size,ranges);
cvCalcHist( &image1.pIplImage, hist1.pCvHistogram, 0, 0 );
cvCalcHist( &image2.pIplImage, hist2.pCvHistogram, 0, 0 );
float range_1[]={0,255};
float* ranges2[]={ range_0 ,range_1 };
int hist_sizes[] = {256,256};
CiplvHistogram<2> hist12(hist_sizes,ranges2);
float mutInf= iplvMutualInformation(hist1,hist2,hist12);
return 0;
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.