Go to the documentation of this file.00001
00002 #include "vepl1_histogram.h"
00003 #include <vcl_iostream.h>
00004 #include <vipl/accessors/vipl_accessors_vcl_vector.h>
00005 #include <vipl/accessors/vipl_accessors_vil1_image.h>
00006 #include <vipl/vipl_histogram.h>
00007 #include <vil1/vil1_memory_image_of.h>
00008 #include <vxl_config.h>
00009
00010 vcl_vector<unsigned int> vepl1_histogram(vil1_image const& image)
00011 {
00012
00013 if (vil1_pixel_format(image) == VIL1_BYTE) {
00014 vil1_memory_image_of<vxl_byte> mem(image);
00015 vcl_vector<unsigned int> out(256);
00016 vipl_histogram<vil1_image,vcl_vector<unsigned int>, vxl_byte,unsigned int> op;
00017 op.put_in_data_ptr(&mem);
00018 op.put_out_data_ptr(&out);
00019 op.filter();
00020 return out;
00021 }
00022
00023
00024 if (vil1_pixel_format(image) == VIL1_UINT16) {
00025 vil1_memory_image_of<vxl_uint_16> mem(image);
00026 vcl_vector<unsigned int> out(65536);
00027 vipl_histogram<vil1_image,vcl_vector<unsigned int>, vxl_uint_16,unsigned int> op;
00028 op.put_in_data_ptr(&mem);
00029 op.put_out_data_ptr(&out);
00030 op.filter();
00031 return out;
00032 }
00033
00034
00035 else if (vil1_pixel_format(image) == VIL1_RGB_BYTE) {
00036 vcl_cerr << __FILE__ ": vepl1_histogram() cannot be implemented for colour images\n";
00037 return vcl_vector<unsigned int>();
00038 }
00039
00040
00041 else if (vil1_pixel_format(image) == VIL1_FLOAT) {
00042 vil1_memory_image_of<float> mem(image);
00043 vcl_vector<unsigned int> out(1000);
00044
00045 vipl_histogram<vil1_image,vcl_vector<unsigned int>, float,unsigned int> op(0.001f);
00046 op.put_in_data_ptr(&mem);
00047 op.put_out_data_ptr(&out);
00048 op.filter();
00049 return out;
00050 }
00051
00052
00053 else if (vil1_pixel_format(image) == VIL1_DOUBLE) {
00054 vil1_memory_image_of<double> mem(image);
00055 vcl_vector<unsigned int> out(1000);
00056
00057 vipl_histogram<vil1_image,vcl_vector<unsigned int>, double,unsigned int> op(0.001);
00058 op.put_in_data_ptr(&mem);
00059 op.put_out_data_ptr(&out);
00060 op.filter();
00061 return out;
00062 }
00063
00064
00065 else {
00066 vcl_cerr << __FILE__ ": vepl1_histogram() not implemented for " << image << vcl_endl;
00067 return vcl_vector<unsigned int>();
00068 }
00069 }
00070