00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <section/section.h>
00026 #include <vipl/vipl_with_section/accessors/vipl_accessors_section.h>
00027 #include <vipl/vipl_histogram.h>
00028
00029
00030 #include <vil/vil_load.h>
00031 #include <vil/vil_image_view.h>
00032 #include <vcl_iostream.h>
00033 #include <vcl_cstring.h>
00034
00035 #include <vxl_config.h>
00036
00037 #ifdef VCL_VC_5
00038 #define vxl_byte int // this is a hack!!! See the Description.
00039 #endif
00040
00041 int
00042 main(int argc, char** argv)
00043 {
00044 if (argc < 2) { vcl_cerr << "Syntax: example_histogram file_in\n"; return 1; }
00045
00046
00047 vil_image_view<vxl_byte> in = vil_load(argv[1]);
00048
00049 section<vxl_byte,2> src(in.ni(),in.nj());
00050 section<int,2> dst(1,256);
00051
00052
00053 if (!in) { vcl_cerr << "Please use a ubyte image as input\n"; return 2; }
00054 vcl_memcpy(src.buffer, in.memory_chunk()->const_data(), in.size_bytes());
00055
00056
00057 vipl_histogram<section<vxl_byte,2>,section<int,2>,vxl_byte,int> op;
00058 op.put_in_data_ptr(&src);
00059 op.put_out_data_ptr(&dst);
00060 op.filter();
00061
00062
00063 {for (int i=0; i<256; ++i) if (src.buffer[i] != 0)
00064 vcl_cout << i << ": " << int(src.buffer[i]) << vcl_endl;
00065 }
00066
00067 return 0;
00068 }