Go to the documentation of this file.00001
00002 #include "vepl_histogram.h"
00003 #include <vcl_iostream.h>
00004 #include <vipl/accessors/vipl_accessors_vcl_vector.h>
00005 #include <vepl/accessors/vipl_accessors_vil_image_view_base.h>
00006 #include <vipl/vipl_histogram.h>
00007 #include <vil/vil_pixel_format.h>
00008 #include <vxl_config.h>
00009
00010 vcl_vector<unsigned int> vepl_histogram(vil_image_resource_sptr image)
00011 {
00012
00013 if (image->nplanes() > 1 || image->pixel_format() == VIL_PIXEL_FORMAT_RGB_BYTE) {
00014 vcl_cerr << __FILE__ ": vepl_histogram() cannot be implemented for colour images\n";
00015 return vcl_vector<unsigned int>();
00016 }
00017
00018
00019 else if (image->pixel_format() == VIL_PIXEL_FORMAT_BYTE) {
00020 vil_image_view<vxl_byte> in = image->get_view();
00021 vcl_vector<unsigned int> out(256);
00022 vipl_histogram<vil_image_view_base,vcl_vector<unsigned int>, vxl_byte,unsigned int> op;
00023 op.put_in_data_ptr(&in);
00024 op.put_out_data_ptr(&out);
00025 op.filter();
00026 return out;
00027 }
00028
00029
00030 else if (image->pixel_format() == VIL_PIXEL_FORMAT_UINT_16) {
00031 vil_image_view<vxl_uint_16> in = image->get_view();
00032 vcl_vector<unsigned int> out(65536);
00033 vipl_histogram<vil_image_view_base,vcl_vector<unsigned int>, vxl_uint_16,unsigned int> op;
00034 op.put_in_data_ptr(&in);
00035 op.put_out_data_ptr(&out);
00036 op.filter();
00037 return out;
00038 }
00039
00040
00041 else if (image->pixel_format() == VIL_PIXEL_FORMAT_FLOAT) {
00042 vil_image_view<float> in = image->get_view();
00043 vcl_vector<unsigned int> out(1000);
00044
00045 vipl_histogram<vil_image_view_base,vcl_vector<unsigned int>, float,unsigned int> op(0.001f);
00046 op.put_in_data_ptr(&in);
00047 op.put_out_data_ptr(&out);
00048 op.filter();
00049 return out;
00050 }
00051
00052
00053 else if (image->pixel_format() == VIL_PIXEL_FORMAT_DOUBLE) {
00054 vil_image_view<double> in = image->get_view();
00055 vcl_vector<unsigned int> out(1000);
00056
00057 vipl_histogram<vil_image_view_base,vcl_vector<unsigned int>, double,unsigned int> op(0.001);
00058 op.put_in_data_ptr(&in);
00059 op.put_out_data_ptr(&out);
00060 op.filter();
00061 return out;
00062 }
00063
00064
00065 else {
00066 vcl_cerr << __FILE__ ": vepl_histogram() not implemented for " << image << '\n';
00067 return vcl_vector<unsigned int>();
00068 }
00069 }
00070