app-corrcoef.C

Go to the documentation of this file.
00001 /*! @file AppMedia/app-corrcoef.C simple app to compute the
00002   correlation coefficient between two images, and also print basic
00003   first order statistics for each image */
00004 
00005 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/AppMedia/app-corrcoef.C $
00006 // $Id: app-corrcoef.C 6263 2006-02-18 00:07:18Z rjpeters $
00007 
00008 #include "Image/Image.H"
00009 #include "Image/MathOps.H"
00010 #include "Image/Range.H"
00011 #include "Raster/Raster.H"
00012 #include <cstdio>
00013 
00014 #ifdef HAVE_FENV_H
00015 #include <fenv.h>
00016 #endif
00017 
00018 int main(int argc, char** argv)
00019 {
00020   if (argc != 3)
00021     {
00022       printf("usage: %s image1 image2\n", argv[0]);
00023       return 1;
00024     }
00025 
00026   const Image<float> img1 = Raster::ReadFloat(argv[1]);
00027   const Image<float> img2 = Raster::ReadFloat(argv[2]);
00028 
00029 #ifdef HAVE_FEENABLEEXCEPT
00030   feenableexcept(FE_DIVBYZERO|FE_INVALID);
00031 #endif
00032 
00033   const double rsq = corrcoef(img1, img2);
00034 
00035   const Range<float> r1 = rangeOf(img1);
00036   const Range<float> r2 = rangeOf(img2);
00037 
00038   printf("mean(%s)=%e\n", argv[1], mean(img1));
00039   printf("mean(%s)=%e\n", argv[2], mean(img2));
00040   printf("stdev(%s)=%e\n", argv[1], stdev(img1));
00041   printf("stdev(%s)=%e\n", argv[2], stdev(img2));
00042   printf("range(%s)=[%e .. %e]\n", argv[1], r1.min(), r1.max());
00043   printf("range(%s)=[%e .. %e]\n", argv[2], r2.min(), r2.max());
00044   printf("corrcoef(%s,%s)=%e\n", argv[1], argv[2], sqrt(rsq));
00045 }
Generated on Sun May 8 08:04:10 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3