Go to the documentation of this file.00001
00002
00003
00004
00005
00006 #include "vil3d_histogram.h"
00007
00008
00009
00010 void vil3d_histogram_byte(const vil3d_image_view<vxl_byte>& image,
00011 vcl_vector<double>& histo)
00012 {
00013 histo.resize(256);
00014 vcl_fill(histo.begin(),histo.end(),0.0);
00015
00016 const vxl_byte* plane = image.origin_ptr();
00017 unsigned ni = image.ni(),nj = image.nj(),nk = image.nk(),np = image.nplanes();
00018 vcl_ptrdiff_t istep=image.istep(),jstep=image.jstep(),kstep=image.kstep(),pstep = image.planestep();
00019 for (unsigned p=0;p<np;++p,plane += pstep)
00020 {
00021 const vxl_byte* slice = plane;
00022 for (unsigned k=0;k<nk;++k,slice += kstep)
00023 {
00024 const vxl_byte* row = slice;
00025 for (unsigned j=0;j<nj;++j,row += jstep)
00026 {
00027 const vxl_byte* pixel = row;
00028 for (unsigned i=0;i<ni;++i,pixel+=istep) histo[*pixel]+=1;
00029 }
00030 }
00031 }
00032 }