Go to the documentation of this file.00001 #ifndef OPENTISSUE_GPU_IMAGE_IMAGE_GET_MAX_OCTAVES_H
00002 #define OPENTISSUE_GPU_IMAGE_IMAGE_GET_MAX_OCTAVES_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <cmath>
00013
00014 namespace OpenTissue
00015 {
00016 namespace image
00017 {
00018
00026 template<typename image_type>
00027 inline size_t get_max_octaves( image_type const & image)
00028 {
00029 using std::max;
00030
00031 size_t width = image.width();
00032 size_t height = image.height();
00033 size_t pixel_resolution = max(width,height);
00034
00035 size_t mask = 0;
00036 if(pixel_resolution<0)
00037 mask = -pixel_resolution;
00038 else
00039 mask = pixel_resolution;
00040
00041 size_t i=0;
00042 while(mask>0)
00043 {
00044 mask = mask >> 1;
00045 ++i;
00046 }
00047 size_t octaves = max(1u,i-2u);
00048 return octaves;
00049 }
00050
00051 }
00052 }
00053
00054
00055 #endif