Go to the documentation of this file.00001
00002 #include "ipts_entropy_pyramid.h"
00003
00004
00005
00006
00007
00008 #include "ipts_local_entropy.h"
00009 #include <vimt/vimt_scale_pyramid_builder_2d.h>
00010 #include <vcl_cassert.h>
00011
00012
00013
00014
00015
00016
00017
00018
00019 void ipts_entropy_pyramid(const vimt_image_2d_of<vxl_byte>& image,
00020 vimt_image_pyramid& entropy_pyramid,
00021 vimt_image_pyramid& smooth_pyramid,
00022 double scale_step, unsigned half_width)
00023 {
00024 vimt_scale_pyramid_builder_2d<vxl_byte> pyr_builder;
00025 pyr_builder.set_scale_step(scale_step);
00026 pyr_builder.build(smooth_pyramid,image);
00027
00028 ipts_entropy_pyramid(smooth_pyramid,entropy_pyramid,half_width,0,255);
00029 }
00030
00031
00032
00033
00034
00035
00036 void ipts_entropy_pyramid(const vimt_image_pyramid& smooth_pyramid,
00037 vimt_image_pyramid& entropy_pyramid,
00038 unsigned half_width, int min_v, int max_v)
00039 {
00040 if (smooth_pyramid.n_levels()==0) return;
00041
00042 assert(smooth_pyramid(0).is_a()=="vimt_image_2d_of<vxl_byte>");
00043
00044
00045 vimt_transform_2d translate;
00046 translate.set_translation(-1.0*half_width,-1.0*half_width);
00047
00048
00049 int n_levels = 0;
00050 for (int i=0;i<smooth_pyramid.n_levels();++i)
00051 {
00052 const vimt_image_2d_of<vxl_byte>& smooth_im
00053 = static_cast<const vimt_image_2d_of<vxl_byte>&>(smooth_pyramid(i));
00054 if (smooth_im.image().ni()>2*half_width+1 &&
00055 smooth_im.image().nj()>2*half_width+1) n_levels++;
00056 }
00057
00058
00059 entropy_pyramid.resize(n_levels,vimt_image_2d_of<float>());
00060 for (int i=0;i<n_levels;++i)
00061 {
00062 const vimt_image_2d_of<vxl_byte>& smooth_im
00063 = static_cast<const vimt_image_2d_of<vxl_byte>&>(smooth_pyramid(i));
00064 vimt_image_2d_of<float>& entropy_im
00065 = static_cast<vimt_image_2d_of<float>&>(entropy_pyramid(i));
00066 ipts_local_entropy(smooth_im.image(),entropy_im.image(),half_width,min_v,max_v);
00067
00068 entropy_im.set_world2im(translate*smooth_im.world2im());
00069 }
00070 }