aimsalgo 6.0.0
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
38#include <cartodata/volume/volume.h>
39
42template <class T>
44 const carto::rc_ptr<carto::Volume<T> > &mat );
45
46
47template <class T> inline
50{
51 ASSERT(mat->getSizeZ()==1 && mat->getSizeT()==1);
53 mat->getSizeX(), mat->getSizeY(), 1, 1, mat->getBorders()[0] );
54 curv.fillBorder(0);
55 curv = 0.0;
56 curv.setVoxelSize( mat->getVoxelSize() );
57 std::vector<int> dim = mat->getSize();
58 float fx,fy,fxx,fyy,fxy;
59
60 for (int y=2;y<dim[1]-2;y++)
61 for (int x=2;x<dim[0]-2;x++)
62 {
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) );
76 }
77 else curv(x,y) = 0;
78 }
79 return curv;
80}
81
82#endif
#define ASSERT(EX)
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.
Definition curv2Diso.h:49
T cube(const T &val)