Initial snark14m import
[snark14.git] / src / snark / sec_cri2.cpp
1 /*
2  ***********************************************************
3  $SNARK_Header: S N A R K  1 4 - A PICTURE RECONSTRUCTION PROGRAM $
4  $HeadURL: svn://dig.cs.gc.cuny.edu/snark/trunk/src/snark/sec_cri2.cpp $
5  $LastChangedRevision: 107 $
6  $Date: 2014-07-07 12:06:15 -0400 (Mon, 07 Jul 2014) $
7  $Author: olangthaler $
8  ***********************************************************
9  */
10
11 #include "sec_cri2.h"
12 #include "math.h"
13 #include "anglst.h"
14 #include "blob.h"
15
16 using namespace std;
17
18 REAL sec_cri2_class::Run(REAL* image)
19 {
20         INTEGER dimensions = GeoPar.nelem;
21         // pixels over which to iterate (skip last line and new bottom right pixel)
22         INTEGER pixelcount = GeoPar.area - dimensions - 2;
23
24         REAL psi = 0;
25         for (INTEGER i = dimensions + 2; i < pixelcount; i++)
26         {
27                 // skip right-most column
28                 if (i % (dimensions) == 0) continue;
29                 // skip left column
30                 if (i % (dimensions) == 1) continue;
31
32                 psi += pow(image[i - 1] - ((image[i - 1 - dimensions - 1] + image[i - 1 - dimensions] + image[i - dimensions] + image[i - 2] + image[i] + image[i - 1 + dimensions - 1] + image[i - 1 + dimensions] + image[i + dimensions]) / 8), 2);
33         }
34
35         return psi;
36 }