contrib/mul/vil3d/algo/vil3d_distance_transform.h
Go to the documentation of this file.
00001 #ifndef vil3d_distance_transform_h_
00002 #define vil3d_distance_transform_h_
00003 //:
00004 // \file
00005 // \brief Compute 3D distance transform
00006 // \author Kola Babalola
00007 
00008 #include <vil3d/vil3d_image_view.h>
00009 #include <vil/vil_rgb.h>
00010 
00011 //: Compute 3d distance transform from zeros in original image.
00012 //  Image is assumed to be filled with max_dist where there is
00013 //  background, and zero at the places of interest. On exit,
00014 //  the values are the 8-connected distance to the nearest
00015 //  original zero voxel.
00016 // \param distance_link_i use when calculating connected distance between i and i+1
00017 // \param distance_link_j use when calculating connected distance between j and j+1
00018 // \param distance_link_k use when calculating connected distance between k and k+1
00019 void vil3d_distance_transform(vil3d_image_view<float>& image, const float distance_link_i=1, const float distance_link_j=1, const float distance_link_k=1);
00020 
00021 //: Compute 3d distance transform from zeros in original image.
00022 //  Image is assumed to be filled with max_dist where there is
00023 //  background, and zero at the places of interest. On exit,
00024 //  the values are the 8-connected distance to the nearest
00025 //  original zero voxel.
00026 //  One pass of distance transform, going from low to high i,j,k.
00027 // \param distance_link_i use when calculating connected distance between i and i+1
00028 // \param distance_link_j use when calculating connected distance between j and j+1
00029 // \param distance_link_k use when calculating connected distance between k and k+1
00030 void vil3d_distance_transform_one_way(vil3d_image_view<float>& image, const float distance_link_i=1, const float distance_link_j=1, const float distance_link_k=1);
00031 
00032 //: Compute 3D distance function from true elements in mask.
00033 //  On exit, the values are the 26-connected distance to the
00034 //  nearest original zero region (or max_dist, if that is smaller).
00035 void vil_distance_transform(const vil3d_image_view<bool>& mask,
00036                             vil3d_image_view<float>& distance_image,
00037                             float max_dist);
00038 
00039 //: Compute signed distance transform in 3d from zeros in original image.
00040 //  Image is assumed to be filled with max_dist
00041 //  where there is background, and zero in the places of interest.
00042 //  On exit, the values are the signed 26-connected distance
00043 //  to the nearest original zero region. Positive values are
00044 //  outside the bounded region and negative values are inside.
00045 //  The values on the boundary are zero
00046 // \param distance_link_i use when calculating connected distance between i and i+1
00047 // \param distance_link_j use when calculating connected distance between j and j+1
00048 // \param distance_link_k use when calculating connected distance between k and k+1
00049 void vil3d_signed_distance_transform(vil3d_image_view<float>& image,
00050                                      const float distance_link_i=1,
00051                                      const float distance_link_j=1,
00052                                      const float distance_link_k=1);
00053 
00054 float vil3d_min_equal(float const& a, float const& b, bool& eq);
00055 
00056 void vil3d_distance_transform_one_way_with_dir(vil3d_image_view<float>& image,
00057                                                vil3d_image_view<vil_rgb<float> >& orient,
00058                                                const float distance_link_i=1,
00059                                                const float distance_link_j=1,
00060                                                const float distance_link_k=1);
00061 
00062 void vil3d_distance_transform_with_dir(vil3d_image_view<float>& image,
00063                                        vil3d_image_view<vil_rgb<float> >& orient,
00064                                        const float distance_link_i,
00065                                        const float distance_link_j,
00066                                        const float distance_link_k);
00067 
00068 //: Compute 3d signed distance transform from true elements in mask.
00069 //  On exit, values are 26 connected distance from the 'true' boundary.
00070 //  There are no zero values because the true boundary is the infinitesimally
00071 //  thin edge of the true and false regions of the mask. The values inside
00072 //  the mask are negative and those outside are positive
00073 // \param distance_link_i use when calculating connected distance between i and i+1
00074 // \param distance_link_j use when calculating connected distance between j and j+1
00075 // \param distance_link_k use when calculating connected distance between k and k+1
00076 void vil3d_signed_distance_transform(const vil3d_image_view<bool>& mask,
00077                                      vil3d_image_view<float>& image,
00078                                      float max_dist,
00079                                      const float distance_link_i=1,
00080                                      const float distance_link_j=1,
00081                                      const float distance_link_k=1);
00082 
00083 #endif // vil3d_distance_transform_h_