Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

MakeCooccurenceMatrix.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_Histogram_MakeCooccurenceMatrix_h
00002 #define Impala_Core_Histogram_MakeCooccurenceMatrix_h
00003 
00004 #include "Core/Histogram/Histogram2dTem.h"
00005 #include "Core/Array/MakeRoi.h"
00006 #include "Core/Histogram/NgbOutCooccurence.h"
00007 #include "Core/Array/Pattern/PatNgbOp2d.h"
00008 #include "Core/Array/Pattern/PatSetBorder.h"
00009 
00010 namespace Impala
00011 {
00012 namespace Core
00013 {
00014 namespace Histogram
00015 {
00016 
00017 
00018 /*
00019 call function something like this:
00020 
00021     Array::Array2dScalarReal64* im1 = MakeFromValue<Array::Array2dScalarReal64>(0.1, 10, 10);
00022     Histogram::Histogram2dTem<double> hist(0, 1, 4, 0, 1, 4);
00023     Histogram::MakeCooccurenceMatrix(&hist, im1, Geometry::Rectangle(0,0,9,9));
00024     hist.Dump(true);
00025 
00026 */
00027 template<class HistT, class ArrayT>
00028 void
00029 MakeCooccurenceMatrix(HistT* hist, ArrayT* im, Geometry::Rectangle rect, typename ArrayT::ArithType safeBorderValue = -1)
00030 {
00031     const int borderSize = 1;
00032     ArrayT* borderedIm = CheckBorderSize(im, borderSize, borderSize);
00033     typename ArrayT::ArithType dummy = 0;
00034     Array::Pattern::PatSetBorder(borderedIm, borderSize, borderSize, 
00035                                  Array::Pattern::BORDERCONSTANT, safeBorderValue,
00036                                  dummy, dummy, dummy, dummy);
00037     Geometry::Rectangle borderedRect = GrowBorder(rect, borderSize);
00038     ArrayT* roi = Array::MakeRoi(borderedIm, borderedRect);
00039     if(borderedIm != im)
00040         delete borderedIm;
00041     roi->GrowBorder(borderSize);
00042 
00043     hist->Clear();
00044     Histogram::NgbOutCooccurence cooccurence(hist);
00045     Array::Pattern::PatNgbOp2d(roi, roi, cooccurence, true);
00046     delete roi;
00047 }
00048 
00049 template<class HistT, class ArrayT>
00050 void
00051 MakeCooccurenceMatrix(HistT* hist, ArrayT* im)
00052 {
00053     MakeCooccurenceMatrix<HistT, ArrayT>(hist, im, Geometry::Rectangle(0,0,im->CW()-1, im->CH()-1));
00054 }
00055 
00056 } // namespace Histogram
00057 } // namespace Core
00058 } // namespace Impala
00059 
00060 #endif

Generated on Fri Mar 19 09:31:10 2010 for ImpalaSrc by  doxygen 1.5.1