34 #include <visp3/core/vpException.h>
35 #include <visp3/ustk_volume_processing/usVolumeProcessing.h>
46 for (
unsigned int i = 0; i < src.
getSize(); i++)
57 if (size <= 0 || (size % 2) != 1) {
59 vpException::badValue,
60 "usVolumeProcessing::generateGaussianDerivativeFilterI(): Bad filter size, should be positive and odd");
63 double sigma2 = vpMath::sqr(sigma);
64 int m = (size - 1) / 2;
68 for (
int k = 0; k < size; k++) {
69 gk = exp(-vpMath::sqr(k - m) / (2.0 * sigma2)) / (sigma * sqrt(2.0 * M_PI));
70 for (
int j = 0; j < size; j++) {
71 gj = exp(-vpMath::sqr(j - m) / (2.0 * sigma2)) / (sigma * sqrt(2.0 * M_PI));
72 for (
int i = 0; i < size; i++) {
73 dgi = -(i - m) * exp(-vpMath::sqr(i - m) / (2.0 * sigma2)) / (2.0 * sigma * sigma2 * sqrt(2.0 * M_PI));
74 filter(i, j, k, dgi * gj * gk);
88 if (size <= 0 || (size % 2) != 1) {
90 vpException::badValue,
91 "usVolumeProcessing::generateGaussianDerivativeFilterJ(): Bad filter size, should be positive and odd");
94 double sigma2 = vpMath::sqr(sigma);
95 int m = (size - 1) / 2;
99 for (
int k = 0; k < size; k++) {
100 gk = exp(-vpMath::sqr(k - m) / (2.0 * sigma2)) / (sigma * sqrt(2.0 * M_PI));
101 for (
int j = 0; j < size; j++) {
102 dgj = -(j - m) * exp(-vpMath::sqr(j - m) / (2.0 * sigma2)) / (2.0 * sigma * sigma2 * sqrt(2.0 * M_PI));
103 for (
int i = 0; i < size; i++) {
104 gi = exp(-vpMath::sqr(i - m) / (2.0 * sigma2)) / (sigma * sqrt(2.0 * M_PI));
105 filter(i, j, k, gi * dgj * gk);
119 if (size <= 0 || (size % 2) != 1) {
121 vpException::badValue,
122 "usVolumeProcessing::generateGaussianDerivativeFilterK(): Bad filter size, should be positive and odd");
125 double sigma2 = vpMath::sqr(sigma);
126 int m = (size - 1) / 2;
130 for (
int k = 0; k < size; k++) {
131 dgk = -(k - m) * exp(-vpMath::sqr(k - m) / (2.0 * sigma2)) / (2.0 * sigma * sigma2 * sqrt(2.0 * M_PI));
132 for (
int j = 0; j < size; j++) {
133 gj = exp(-vpMath::sqr(j - m) / (2.0 * sigma2)) / (sigma * sqrt(2.0 * M_PI));
134 for (
int i = 0; i < size; i++) {
135 gi = exp(-vpMath::sqr(i - m) / (2.0 * sigma2)) / (sigma * sqrt(2.0 * M_PI));
136 filter(i, j, k, gi * gj * dgk);
150 if (size <= 0 || (size % 2) != 1) {
152 vpException::badValue,
153 "usVolumeProcessing::generateGaussianDerivativeFilterII(): Bad filter size, should be positive and odd");
156 double sigma2 = vpMath::sqr(sigma);
157 int m = (size - 1) / 2;
161 for (
int k = 0; k < size; k++) {
162 gk = exp(-vpMath::sqr(k - m) / (2.0 * sigma2)) / (sigma * sqrt(2.0 * M_PI));
163 for (
int j = 0; j < size; j++) {
164 gj = exp(-vpMath::sqr(j - m) / (2.0 * sigma2)) / (sigma * sqrt(2.0 * M_PI));
165 for (
int i = 0; i < size; i++) {
166 ddgi = (vpMath::sqr(i - m) / (4.0 * vpMath::sqr(sigma2) * sqrt(2.0 * M_PI)) -
167 1.0 / (2.0 * sigma * sigma2 * sqrt(2.0 * M_PI))) *
168 exp(-vpMath::sqr(i - m) / (2.0 * sigma2));
169 filter(i, j, k, ddgi * gj * gk);
183 if (size <= 0 || (size % 2) != 1) {
185 vpException::badValue,
186 "usVolumeProcessing::generateGaussianDerivativeFilterJJ(): Bad filter size, should be positive and odd");
189 double sigma2 = vpMath::sqr(sigma);
190 int m = (size - 1) / 2;
194 for (
int k = 0; k < size; k++) {
195 gk = exp(-vpMath::sqr(k - m) / (2.0 * sigma2)) / (sigma * sqrt(2.0 * M_PI));
196 for (
int j = 0; j < size; j++) {
197 ddgj = (vpMath::sqr(j - m) / (4.0 * vpMath::sqr(sigma2) * sqrt(2.0 * M_PI)) -
198 1.0 / (2.0 * sigma * sigma2 * sqrt(2.0 * M_PI))) *
199 exp(-vpMath::sqr(j - m) / (2.0 * sigma2));
200 for (
int i = 0; i < size; i++) {
201 gi = exp(-vpMath::sqr(i - m) / (2.0 * sigma2)) / (sigma * sqrt(2.0 * M_PI));
202 filter(i, j, k, gi * ddgj * gk);
216 if (size <= 0 || (size % 2) != 1) {
218 vpException::badValue,
219 "usVolumeProcessing::generateGaussianDerivativeFilterKK(): Bad filter size, should be positive and odd");
222 double sigma2 = vpMath::sqr(sigma);
223 int m = (size - 1) / 2;
227 for (
int k = 0; k < size; k++) {
228 ddgk = (vpMath::sqr(k - m) / (4.0 * vpMath::sqr(sigma2) * sqrt(2.0 * M_PI)) -
229 1.0 / (2.0 * sigma * sigma2 * sqrt(2.0 * M_PI))) *
230 exp(-vpMath::sqr(k - m) / (2.0 * sigma2));
231 for (
int j = 0; j < size; j++) {
232 gj = exp(-vpMath::sqr(j - m) / (2.0 * sigma2)) / (sigma * sqrt(2.0 * M_PI));
233 for (
int i = 0; i < size; i++) {
234 gi = exp(-vpMath::sqr(i - m) / (2.0 * sigma2)) / (sigma * sqrt(2.0 * M_PI));
235 filter(i, j, k, gi * gj * ddgk);
249 if (size <= 0 || (size % 2) != 1) {
251 vpException::badValue,
252 "usVolumeProcessing::generateGaussianDerivativeFilterIJ(): Bad filter size, should be positive and odd");
255 double sigma2 = vpMath::sqr(sigma);
256 int m = (size - 1) / 2;
260 for (
int k = 0; k < size; k++) {
261 gk = exp(-vpMath::sqr(k - m) / (2.0 * sigma2)) / (sigma * sqrt(2.0 * M_PI));
262 for (
int j = 0; j < size; j++) {
263 dgj = -(j - m) * exp(-vpMath::sqr(j - m) / (2.0 * sigma2)) / (2.0 * sigma * sigma2 * sqrt(2.0 * M_PI));
264 for (
int i = 0; i < size; i++) {
265 dgi = -(i - m) * exp(-vpMath::sqr(i - m) / (2.0 * sigma2)) / (2.0 * sigma * sigma2 * sqrt(2.0 * M_PI));
266 filter(i, j, k, dgi * dgj * gk);
280 if (size <= 0 || (size % 2) != 1) {
282 vpException::badValue,
283 "usVolumeProcessing::generateGaussianDerivativeFilterIK(): Bad filter size, should be positive and odd");
286 double sigma2 = vpMath::sqr(sigma);
287 int m = (size - 1) / 2;
291 for (
int k = 0; k < size; k++) {
292 dgk = -(k - m) * exp(-vpMath::sqr(k - m) / (2.0 * sigma2)) / (2.0 * sigma * sigma2 * sqrt(2.0 * M_PI));
293 for (
int j = 0; j < size; j++) {
294 gj = exp(-vpMath::sqr(j - m) / (2.0 * sigma2)) / (sigma * sqrt(2.0 * M_PI));
295 for (
int i = 0; i < size; i++) {
296 dgi = -(i - m) * exp(-vpMath::sqr(i - m) / (2.0 * sigma2)) / (2.0 * sigma * sigma2 * sqrt(2.0 * M_PI));
297 filter(i, j, k, dgi * gj * dgk);
311 if (size <= 0 || (size % 2) != 1) {
313 vpException::badValue,
314 "usVolumeProcessing::generateGaussianDerivativeFilterJK(): Bad filter size, should be positive and odd");
317 double sigma2 = vpMath::sqr(sigma);
318 int m = (size - 1) / 2;
322 for (
int k = 0; k < size; k++) {
323 dgk = -(k - m) * exp(-vpMath::sqr(k - m) / (2.0 * sigma2)) / (2.0 * sigma * sigma2 * sqrt(2.0 * M_PI));
324 for (
int j = 0; j < size; j++) {
325 dgj = -(j - m) * exp(-vpMath::sqr(j - m) / (2.0 * sigma2)) / (2.0 * sigma * sigma2 * sqrt(2.0 * M_PI));
326 for (
int i = 0; i < size; i++) {
327 gi = exp(-vpMath::sqr(i - m) / (2.0 * sigma2)) / (sigma * sqrt(2.0 * M_PI));
328 filter(i, j, k, gi * dgj * dgk);
Representation of a physical image volume.
unsigned int getNumberOfFrames() const
unsigned int getSize() const
void resize(unsigned int height, unsigned int width, unsigned int numberOfFrames)
Type * getConstData() const
unsigned int getHeight() const
unsigned int getWidth() const
static usImage3D< double > generateGaussianDerivativeFilterJJ(double sigma, int size)
static usImage3D< double > generateGaussianDerivativeFilterIJ(double sigma, int size)
static usImage3D< double > generateGaussianDerivativeFilterJ(double sigma, int size)
static usImage3D< double > generateGaussianDerivativeFilterI(double sigma, int size)
static usImage3D< double > generateGaussianDerivativeFilterIK(double sigma, int size)
static usImage3D< double > generateGaussianDerivativeFilterII(double sigma, int size)
static usImage3D< double > generateGaussianDerivativeFilterKK(double sigma, int size)
static void norm(const usImage3D< vpColVector > &src, usImage3D< double > &dst)
static usImage3D< double > generateGaussianDerivativeFilterK(double sigma, int size)
static usImage3D< double > generateGaussianDerivativeFilterJK(double sigma, int size)