00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <section/section.h>
00020 #include <vipl/vipl_with_section/accessors/vipl_accessors_section.h>
00021 #include <vil/vil_rgb.h>
00022
00023 #include <vipl/vipl_x_gradient.h>
00024
00025 #include <vxl_config.h>
00026 typedef vil_rgb<vxl_byte> rgbcell;
00027 typedef section<rgbcell,2> img_type;
00028
00029
00030 #include <vil/vil_image_view.h>
00031 #include <vil/vil_load.h>
00032 #include <vil/vil_save.h>
00033 #include <vcl_iostream.h>
00034 #include <vcl_cstring.h>
00035
00036 int
00037 main(int argc, char** argv)
00038 {
00039 if (argc < 3) { vcl_cerr << "Syntax: example_x_gradient file_in file_out\n"; return 1; }
00040
00041
00042 vil_image_view<rgbcell> in = vil_load(argv[1]);
00043 if (!in) { vcl_cerr << "Please use a colour image as input\n"; return 2; }
00044
00045
00046 vil_image_view<rgbcell> out(in.ni(),in.nj(),in.nplanes());
00047
00048
00049 int xs = in.ni();
00050 int ys = in.nj();
00051
00052 img_type src(xs,ys);
00053 img_type dst(xs,ys);
00054
00055
00056 vcl_memcpy(src.buffer, in.memory_chunk()->const_data(), in.size_bytes());
00057
00058
00059 vipl_x_gradient<img_type,img_type,rgbcell,rgbcell> op;
00060 op.put_in_data_ptr(&src);
00061 op.put_out_data_ptr(&dst);
00062 op.filter();
00063
00064
00065 vcl_memcpy(out.memory_chunk()->data(), dst.buffer, out.size_bytes());
00066 vil_save(out, argv[2], "pnm");
00067 vcl_cout << "Written image of type PPM to " << argv[2] << vcl_endl;
00068
00069 return 0;
00070 }