aimsalgo  5.0.5
Neuroimaging image processing
curv2Diso.h
Go to the documentation of this file.
1 /* This software and supporting documentation are distributed by
2  * Institut Federatif de Recherche 49
3  * CEA/NeuroSpin, Batiment 145,
4  * 91191 Gif-sur-Yvette cedex
5  * France
6  *
7  * This software is governed by the CeCILL-B license under
8  * French law and abiding by the rules of distribution of free software.
9  * You can use, modify and/or redistribute the software under the
10  * terms of the CeCILL-B license as circulated by CEA, CNRS
11  * and INRIA at the following URL "http://www.cecill.info".
12  *
13  * As a counterpart to the access to the source code and rights to copy,
14  * modify and redistribute granted by the license, users are provided only
15  * with a limited warranty and the software's author, the holder of the
16  * economic rights, and the successive licensors have only limited
17  * liability.
18  *
19  * In this respect, the user's attention is drawn to the risks associated
20  * with loading, using, modifying and/or developing or reproducing the
21  * software by the user in light of its specific status of free software,
22  * that may mean that it is complicated to manipulate, and that also
23  * therefore means that it is reserved for developers and experienced
24  * professionals having in-depth computer knowledge. Users are therefore
25  * encouraged to load and test the software's suitability as regards their
26  * requirements in conditions enabling the security of their systems and/or
27  * data to be ensured and, more generally, to use and operate it in the
28  * same conditions as regards security.
29  *
30  * The fact that you are presently reading this means that you have had
31  * knowledge of the CeCILL-B license and that you accept its terms.
32  */
33 
34 
35 #ifndef AIMS_MATH_CURV2DISO_H
36 #define AIMS_MATH_CURV2DISO_H
37 
39 
42 template <class T>
44 
45 
46 template <class T> inline
49 { ASSERT(mat.dimZ()==1 && mat.dimT()==1);
50  aims::AimsFastAllocationData<float> curv(mat.dimX(),mat.dimY(),1,1,mat.borderWidth());
51  curv.fillBorder(0);
52  curv = 0.0;
53  curv.setSizeX(mat.sizeX());
54  curv.setSizeY(mat.sizeY());
55  float fx,fy,fxx,fyy,fxy;
56 
57  for (int y=2;y<mat.dimY()-2;y++)
58  for (int x=2;x<mat.dimX()-2;x++)
59  { if (mat(x-1,y)!=mat(x+1,y) || mat(x,y-1)!=mat(x,y+1))
60  { fx = ((float)mat(x+1,y) - (float)mat(x-1,y) ) / 2;
61  fy = ((float)mat(x,y+1) - (float)mat(x,y-1) ) / 2;
62  fxx = ((float)mat(x+2,y) - 2 * (float)mat(x,y) +
63  (float)mat(x-2,y) ) / 4;
64  fyy = ((float)mat(x,y+2) - 2 * (float)mat(x,y) +
65  (float)mat(x,y-2) ) / 4;
66  fxy = ((float)mat(x+1,y+1) -
67  (float)mat(x-1,y+1) -
68  (float)mat(x+1,y-1) +
69  (float)mat(x-1,y-1) ) / 4;
70  curv(x,y) = (- fxx*fy*fy + 2*fx*fy*fxy - fyy*fx*fx) /
71  cube( sqrt(fx*fx + fy*fy) );
72  }
73  else curv(x,y) = 0;
74  }
75  return(curv);
76 }
77 
78 #endif
int dimZ() const
int dimY() const
float sizeX() const
T cube(const T &val)
void fillBorder(const T &val)
AimsData< float > AimsIsoIntensityCurvature2D(const AimsData< T > &mat)
2D Curvature functions on an intensity image f(x,y) = I.
Definition: curv2Diso.h:48
float sizeY() const
int dimT() const
#define ASSERT(EX)
int dimX() const
int borderWidth() const