Various mathematical manipulations of 3D images. More...
#include <vcl_cassert.h>
#include <vcl_vector.h>
#include <vil3d/vil3d_image_view.h>
#include <vil3d/vil3d_plane.h>
#include <vcl_algorithm.h>
Go to the source code of this file.
Functions | |
template<class T > | |
void | vil3d_math_value_range (const vil3d_image_view< T > &im, T &min_value, T &max_value) |
Compute minimum and maximum values over im. | |
template<class T > | |
void | vil3d_math_value_range_percentile (const vil3d_image_view< T > &im, const double fraction, T &value) |
Compute value corresponding to a percentile of the range of im. | |
template<class T > | |
void | vil3d_math_value_range_percentiles (const vil3d_image_view< T > &im, const vcl_vector< double > fraction, vcl_vector< T > &value) |
Compute value corresponding to several percentiles of the range of im. | |
template<class aT , class sumT > | |
void | vil3d_math_mean_over_planes (const vil3d_image_view< aT > &src, vil3d_image_view< sumT > &dest) |
Calc the mean of each pixel over all the planes. | |
template<class inT , class outT , class sumT > | |
void | vil3d_math_mean_over_planes (const vil3d_image_view< inT > &src, vil3d_image_view< outT > &dest, sumT) |
Calc the mean of each pixel over all the planes. | |
template<class inT , class outT , class sumT > | |
void | vil3d_math_rms (const vil3d_image_view< inT > &src, vil3d_image_view< outT > &dest, sumT) |
Calculate the rms of each pixel over all the planes. | |
template<class imT , class sumT > | |
void | vil3d_math_sum (sumT &sum, const vil3d_image_view< imT > &im, unsigned p) |
Compute sum of values in plane p. | |
template<class imT , class sumT > | |
void | vil3d_math_mean (sumT &mean, const vil3d_image_view< imT > &im, unsigned p) |
Mean of elements in plane p of image. | |
template<class imT , class sumT > | |
void | vil3d_math_sum_squares (sumT &sum, sumT &sum_sq, const vil3d_image_view< imT > &im, unsigned p) |
Sum of squares of elements in plane p of image. | |
template<class imT , class sumT > | |
sumT | vil3d_math_ssd (const vil3d_image_view< imT > &imA, const vil3d_image_view< imT > &imB, sumT) |
Sum of squared differences between two images. | |
template<class imT , class offsetT > | |
void | vil3d_math_scale_and_offset_values (vil3d_image_view< imT > &image, double scale, offsetT offset) |
Multiply values in-place in image view by scale and add offset. | |
template<class imT , class sumT > | |
void | vil3d_math_mean_and_variance (sumT &mean, sumT &var, const vil3d_image_view< imT > &im, unsigned p) |
Mean and variance of elements in plane p of image. | |
template<class imT , class sumT > | |
sumT | vil3d_math_dot_product (const vil3d_image_view< imT > &imA, const vil3d_image_view< imT > &imB, sumT) |
Mean and variance of elements in plane p of image. | |
template<class aT , class bT , class sumT > | |
void | vil3d_math_image_difference (const vil3d_image_view< aT > &imA, const vil3d_image_view< bT > &imB, vil3d_image_view< sumT > &im_sum) |
Compute difference of two images (im_sum = imA-imB). | |
template<class aT , class bT , class sumT > | |
void | vil3d_math_image_sum (const vil3d_image_view< aT > &imA, const vil3d_image_view< bT > &imB, vil3d_image_view< sumT > &im_sum) |
Compute sum of two images (im_sum = imA+imB). | |
template<class aT , class bT , class prodT > | |
void | vil3d_math_image_product (const vil3d_image_view< aT > &imA, const vil3d_image_view< bT > &imB, vil3d_image_view< prodT > &im_prod) |
Compute pixel-wise product of two images (im_prod = imA*imB). | |
template<class aT , class bT , class scaleT > | |
void | vil3d_math_add_image_fraction (vil3d_image_view< aT > &imA, scaleT fa, const vil3d_image_view< bT > &imB, scaleT fb) |
imA = fa*imA + fb*imB (Useful for moving averages!). | |
template<class T > | |
void | vil3d_math_truncate_range (vil3d_image_view< T > &image, T min_v, T max_v) |
Truncate each pixel value so it fits into range [min_v,max_v]. | |
template<class aT , class sumT > | |
void | vil3d_math_integral_image (const vil3d_image_view< aT > &imA, vil3d_image_view< sumT > &im_sum) |
Calc integral image im_sum(i+1,j+1,k+1)= sum (x<=i,y<=j,z<=k) imA(x,y,z). | |
template<class aT , class sumT > | |
void | vil3d_math_integral_sqr_image (const vil3d_image_view< aT > &imA, vil3d_image_view< sumT > &im_sum, vil3d_image_view< sumT > &im_sum_sq) |
Calc integral image im_sum_sq(i+1,j+1,k+1) = sum (x<=i,y<=j,z<=k) imA^2. |
Various mathematical manipulations of 3D images.
Definition in file vil3d_math.h.
void vil3d_math_add_image_fraction | ( | vil3d_image_view< aT > & | imA, |
scaleT | fa, | ||
const vil3d_image_view< bT > & | imB, | ||
scaleT | fb | ||
) | [inline] |
imA = fa*imA + fb*imB (Useful for moving averages!).
Can do running sum using vil_add_image_fraction(running_mean,1-f,new_im,f) to update current mean by a fraction f of new_im
Definition at line 491 of file vil3d_math.h.
sumT vil3d_math_dot_product | ( | const vil3d_image_view< imT > & | imA, |
const vil3d_image_view< imT > & | imB, | ||
sumT | |||
) | [inline] |
Mean and variance of elements in plane p of image.
Definition at line 353 of file vil3d_math.h.
void vil3d_math_image_difference | ( | const vil3d_image_view< aT > & | imA, |
const vil3d_image_view< bT > & | imB, | ||
vil3d_image_view< sumT > & | im_sum | ||
) | [inline] |
Compute difference of two images (im_sum = imA-imB).
Definition at line 371 of file vil3d_math.h.
void vil3d_math_image_product | ( | const vil3d_image_view< aT > & | imA, |
const vil3d_image_view< bT > & | imB, | ||
vil3d_image_view< prodT > & | im_prod | ||
) | [inline] |
Compute pixel-wise product of two images (im_prod = imA*imB).
Definition at line 449 of file vil3d_math.h.
void vil3d_math_image_sum | ( | const vil3d_image_view< aT > & | imA, |
const vil3d_image_view< bT > & | imB, | ||
vil3d_image_view< sumT > & | im_sum | ||
) | [inline] |
Compute sum of two images (im_sum = imA+imB).
Definition at line 410 of file vil3d_math.h.
void vil3d_math_integral_image | ( | const vil3d_image_view< aT > & | imA, |
vil3d_image_view< sumT > & | im_sum | ||
) | [inline] |
Calc integral image im_sum(i+1,j+1,k+1)= sum (x<=i,y<=j,z<=k) imA(x,y,z).
Useful thing for quickly computing mean over large regions, as demonstrated in Viola and Jones (CVPR01). The sum of elements in the ni x nj x nk volume with corner (i,j,k) is given by im_sum(i,j,k+nk)+im_sum(i+ni,j+nj,j+nk)+im_sum(i,j+nj,k)+im_sum(i+ni,j,k) -im_sum(i,j,k)-im_sum(i+ni,j+nj,k)-im_sum(i+ni,n,k_nk)-im_sum(i,j+nj,k+nk
Definition at line 560 of file vil3d_math.h.
void vil3d_math_integral_sqr_image | ( | const vil3d_image_view< aT > & | imA, |
vil3d_image_view< sumT > & | im_sum, | ||
vil3d_image_view< sumT > & | im_sum_sq | ||
) | [inline] |
Calc integral image im_sum_sq(i+1,j+1,k+1) = sum (x<=i,y<=j,z<=k) imA^2.
Also calcs integral image, im_sum(i+1,j+1,k+1 = sum (x=i,y<=j,z<=kk) imA Useful thing for quickly computing mean and variance over large regions, as demonstrated in Viola and Jones (CVPR01). The sum of elements in the ni x nj x nk volume with corner (i,j,k) is given by: im_sum(i,j,k+nk)+im_sum(i+ni,j+nj,j+nk)+im_sum(i,j+nj,k)+im_sum(i+ni,j,k) -im_sum(i,j,k)-im_sum(i+ni,j+nj,k)-im_sum(i+ni,n,k_nk)-im_sum(i,j+nj,k+nk
Definition at line 657 of file vil3d_math.h.
void vil3d_math_mean | ( | sumT & | mean, |
const vil3d_image_view< imT > & | im, | ||
unsigned | p | ||
) | [inline] |
Mean of elements in plane p of image.
Definition at line 244 of file vil3d_math.h.
void vil3d_math_mean_and_variance | ( | sumT & | mean, |
sumT & | var, | ||
const vil3d_image_view< imT > & | im, | ||
unsigned | p | ||
) | [inline] |
Mean and variance of elements in plane p of image.
Definition at line 338 of file vil3d_math.h.
void vil3d_math_mean_over_planes | ( | const vil3d_image_view< aT > & | src, |
vil3d_image_view< sumT > & | dest | ||
) | [inline] |
Calc the mean of each pixel over all the planes.
Definition at line 156 of file vil3d_math.h.
void vil3d_math_mean_over_planes | ( | const vil3d_image_view< inT > & | src, |
vil3d_image_view< outT > & | dest, | ||
sumT | |||
) | [inline] |
Calc the mean of each pixel over all the planes.
Definition at line 174 of file vil3d_math.h.
void vil3d_math_rms | ( | const vil3d_image_view< inT > & | src, |
vil3d_image_view< outT > & | dest, | ||
sumT | |||
) | [inline] |
Calculate the rms of each pixel over all the planes.
Definition at line 193 of file vil3d_math.h.
void vil3d_math_scale_and_offset_values | ( | vil3d_image_view< imT > & | image, |
double | scale, | ||
offsetT | offset | ||
) | [inline] |
Multiply values in-place in image view by scale and add offset.
Definition at line 310 of file vil3d_math.h.
sumT vil3d_math_ssd | ( | const vil3d_image_view< imT > & | imA, |
const vil3d_image_view< imT > & | imB, | ||
sumT | |||
) | [inline] |
Sum of squared differences between two images.
Definition at line 289 of file vil3d_math.h.
void vil3d_math_sum | ( | sumT & | sum, |
const vil3d_image_view< imT > & | im, | ||
unsigned | p | ||
) | [inline] |
Compute sum of values in plane p.
Definition at line 213 of file vil3d_math.h.
void vil3d_math_sum_squares | ( | sumT & | sum, |
sumT & | sum_sq, | ||
const vil3d_image_view< imT > & | im, | ||
unsigned | p | ||
) | [inline] |
Sum of squares of elements in plane p of image.
Definition at line 256 of file vil3d_math.h.
void vil3d_math_truncate_range | ( | vil3d_image_view< T > & | image, |
T | min_v, | ||
T | max_v | ||
) | [inline] |
Truncate each pixel value so it fits into range [min_v,max_v].
If value < min_v value=min_v If value > max_v value=max_v
Definition at line 525 of file vil3d_math.h.
void vil3d_math_value_range | ( | const vil3d_image_view< T > & | im, |
T & | min_value, | ||
T & | max_value | ||
) | [inline] |
Compute minimum and maximum values over im.
Definition at line 20 of file vil3d_math.h.
void vil3d_math_value_range_percentile | ( | const vil3d_image_view< T > & | im, |
const double | fraction, | ||
T & | value | ||
) | [inline] |
Compute value corresponding to a percentile of the range of im.
Percentiles expressed as fraction, e.g. 0.05, or 0.95.
im | The image to examine. |
fraction | The fraction of the data range (from the lower end). |
value | The image data value corresponding to the specified percentile. |
Definition at line 70 of file vil3d_math.h.
void vil3d_math_value_range_percentiles | ( | const vil3d_image_view< T > & | im, |
const vcl_vector< double > | fraction, | ||
vcl_vector< T > & | value | ||
) | [inline] |
Compute value corresponding to several percentiles of the range of im.
Percentiles expressed as fraction, e.g. 0.05, or 0.95.
im | The image to examine. |
fraction | The fraction of the data range (from the lower end). |
value | The image data value corresponding to the specified percentiles. |
Definition at line 91 of file vil3d_math.h.