#include <section/section.h>
#include <vipl/vipl_with_section/accessors/vipl_accessors_section.h>
#include <vipl/vipl_dilate_disk.h>
#include <vxl_config.h>
typedef section<vxl_byte,2> img_type;
#include <vil/vil_image_view.h>
#include <vil/vil_load.h>
#include <vil/vil_save.h>
#include <vcl_iostream.h>
#include <vcl_cstdlib.h>
#include <vcl_cstring.h>
int
main(int argc, char** argv) {
if (argc < 3) { vcl_cerr << "Syntax: example_dilate_disk file_in file_out [radius]\n"; return 1; }
vil_image_view<vxl_byte> in = vil_load(argv[1]);
if (!in) { vcl_cerr << "Please use a greyscale image as input\n"; return 2; }
vil_image_view<vxl_byte> out(in.ni(),in.nj(),in.nplanes());
int xs = in.ni();
int ys = in.nj();
float radius = (argc < 4) ? 1.0f : (float)vcl_atof(argv[3]);
img_type src(xs,ys);
img_type dst(xs,ys);
vcl_memcpy(src.buffer, in.memory_chunk()->const_data(), in.size_bytes());
vipl_dilate_disk<img_type,img_type,vxl_byte,vxl_byte> op(radius);
op.put_in_data_ptr(&src);
op.put_out_data_ptr(&dst);
op.filter();
vcl_memcpy(out.memory_chunk()->data(), dst.buffer, out.size_bytes());
vil_save(out, argv[2], "pnm");
vcl_cout << "Written image of type PPM to " << argv[2] << vcl_endl;
return 0;
}
#include <vipl/vipl_with_section/accessors/vipl_accessors_section.txx>
#include <vipl/vipl_dilate_disk.txx>
template class vipl_dilate_disk<img_type,img_type,vxl_byte,vxl_byte>;