35 #ifndef AIMS_MATH_CURV2DISO_H
36 #define AIMS_MATH_CURV2DISO_H
47 template <
class T>
inline
51 ASSERT(mat->getSizeZ()==1 && mat->getSizeT()==1);
53 mat->getSizeX(), mat->getSizeY(), 1, 1, mat->getBorders()[0] );
57 std::vector<int> dim = mat->getSize();
58 float fx,fy,fxx,fyy,fxy;
60 for (
int y=2;y<dim[1]-2;y++)
61 for (
int x=2;x<dim[0]-2;x++)
63 if (mat->at(x-1,y)!=mat->at(x+1,y) || mat->at(x,y-1)!=mat->at(x,y+1))
64 { fx = ((float)mat->at(x+1,y) - (float)mat->at(x-1,y) ) / 2;
65 fy = ((float)mat->at(x,y+1) - (float)mat->at(x,y-1) ) / 2;
66 fxx = ((float)mat->at(x+2,y) - 2 * (float)mat->at(x,y) +
67 (float)mat->at(x-2,y) ) / 4;
68 fyy = ((float)mat->at(x,y+2) - 2 * (float)mat->at(x,y) +
69 (float)mat->at(x,y-2) ) / 4;
70 fxy = ((float)mat->at(x+1,y+1) -
71 (float)mat->at(x-1,y+1) -
72 (float)mat->at(x+1,y-1) +
73 (float)mat->at(x-1,y-1) ) / 4;
74 curv(x,y) = (- fxx*fy*fy + 2*fx*fy*fxy - fyy*fx*fx) /
75 cube( sqrt(fx*fx + fy*fy) );
void setVoxelSize(float vx, float vy=1., float vz=1., float vt=1.)
void fillBorder(const T &value)
carto::VolumeRef< float > AimsIsoIntensityCurvature2D(const carto::rc_ptr< carto::Volume< T > > &mat)
2D Curvature functions on an intensity image f(x,y) = I.