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
00020
00021
00022
00023
00024
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 }
00057 }
00058 }
00059
00060 #endif