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
00028 #include <vipl/vipl_dilate_disk.h>
00029
00030 #include <vxl_config.h>
00031 typedef section<vxl_byte,2> img_type;
00032
00033
00034 #include <vil/vil_image_view.h>
00035 #include <vil/vil_load.h>
00036 #include <vil/vil_save.h>
00037 #include <vcl_iostream.h>
00038 #include <vcl_cstdlib.h>
00039 #include <vcl_cstring.h>
00040
00041 int
00042 main(int argc, char** argv) {
00043 if (argc < 3) { vcl_cerr << "Syntax: example_dilate_disk file_in file_out [radius]\n"; return 1; }
00044
00045
00046 vil_image_view<vxl_byte> in = vil_load(argv[1]);
00047 if (!in) { vcl_cerr << "Please use a greyscale image as input\n"; return 2; }
00048
00049
00050 vil_image_view<vxl_byte> out(in.ni(),in.nj(),in.nplanes());
00051
00052
00053 int xs = in.ni();
00054 int ys = in.nj();
00055
00056
00057 float radius = (argc < 4) ? 1.0f : (float)vcl_atof(argv[3]);
00058
00059 img_type src(xs,ys);
00060 img_type dst(xs,ys);
00061
00062
00063 vcl_memcpy(src.buffer, in.memory_chunk()->const_data(), in.size_bytes());
00064
00065
00066 vipl_dilate_disk<img_type,img_type,vxl_byte,vxl_byte> op(radius);
00067 op.put_in_data_ptr(&src);
00068 op.put_out_data_ptr(&dst);
00069 op.filter();
00070
00071
00072 vcl_memcpy(out.memory_chunk()->data(), dst.buffer, out.size_bytes());
00073 vil_save(out, argv[2], "pnm");
00074 vcl_cout << "Written image of type PPM to " << argv[2] << vcl_endl;
00075
00076 return 0;
00077 }
00078
00079
00080
00081 #include <vipl/vipl_with_section/accessors/vipl_accessors_section.txx>
00082 #include <vipl/vipl_dilate_disk.txx>
00083
00084 template class vipl_dilate_disk<img_type,img_type,vxl_byte,vxl_byte>;