Go to the documentation of this file.00001 #include "vepl1_erode_disk.h"
00002 #include <vipl/accessors/vipl_accessors_vil1_image.h>
00003 #include <vipl/vipl_erode_disk.h>
00004 #include <vil1/vil1_memory_image_of.h>
00005 #include <vil1/vil1_rgb.h>
00006 #include <vxl_config.h>
00007
00008 vil1_image vepl1_erode_disk(vil1_image const& image, float radius)
00009 {
00010
00011 if (vil1_pixel_format(image) == VIL1_BYTE) {
00012 vil1_memory_image_of<vxl_byte> mem(image);
00013 vil1_memory_image_of<vxl_byte> out(image);
00014 vipl_erode_disk<vil1_image,vil1_image,vxl_byte,vxl_byte> op(radius);
00015 op.put_in_data_ptr(&mem);
00016 op.put_out_data_ptr(&out);
00017 op.filter();
00018 return out;
00019 }
00020
00021
00022 else if (vil1_pixel_format(image) == VIL1_RGB_BYTE)
00023 {
00024 #define r_g_b vil1_rgb<vxl_byte> // cannot use typedef since that may cause ambiguous overload problems
00025 vil1_memory_image_of<r_g_b > in(image);
00026 vil1_memory_image_of<r_g_b > out(image);
00027 vil1_memory_image_of<vxl_byte> mem((vxl_byte*)(in.get_buffer()),3*in.width(),in.height());
00028 vil1_memory_image_of<vxl_byte> mout((vxl_byte*)(out.get_buffer()),3*in.width(),in.height());
00029 vipl_erode_disk<vil1_image,vil1_image,vxl_byte,vxl_byte> op(radius);
00030 op.put_in_data_ptr(&mem);
00031 op.put_out_data_ptr(&mout);
00032 op.filter();
00033 return out;
00034 }
00035
00036
00037 else if (vil1_pixel_format(image) == VIL1_UINT16)
00038 {
00039 vil1_memory_image_of<vxl_uint_16> mem(image);
00040 vil1_memory_image_of<vxl_uint_16> out(image);
00041 vipl_erode_disk<vil1_image,vil1_image,vxl_uint_16,vxl_uint_16> op(radius);
00042 op.put_in_data_ptr(&mem);
00043 op.put_out_data_ptr(&out);
00044 op.filter();
00045 return out;
00046 }
00047
00048 #if 0 // currently no erosion for 32-bit integers
00049
00050 else if (vil1_pixel_format(image) == VIL1_UINT32)
00051 {
00052 vil1_memory_image_of<vxl_uint_32> mem(image);
00053 vil1_memory_image_of<vxl_uint_32> out(image);
00054 vipl_erode_disk<vil1_image,vil1_image,vxl_uint_32,vxl_uint_32> op(radius);
00055 op.put_in_data_ptr(&mem);
00056 op.put_out_data_ptr(&out);
00057 op.filter();
00058 return out;
00059 }
00060 #endif
00061
00062
00063 else if (vil1_pixel_format(image) == VIL1_FLOAT) {
00064 vil1_memory_image_of<float> mem(image);
00065 vil1_memory_image_of<float> out(image);
00066 vipl_erode_disk<vil1_image,vil1_image,float,float> op(radius);
00067 op.put_in_data_ptr(&mem);
00068 op.put_out_data_ptr(&out);
00069 op.filter();
00070 return out;
00071 }
00072
00073
00074 else if (vil1_pixel_format(image) == VIL1_DOUBLE) {
00075 vil1_memory_image_of<double> mem(image);
00076 vil1_memory_image_of<double> out(image);
00077 vipl_erode_disk<vil1_image,vil1_image,double,double> op(radius);
00078 op.put_in_data_ptr(&mem);
00079 op.put_out_data_ptr(&out);
00080 op.filter();
00081 return out;
00082 }
00083
00084
00085 else {
00086 vcl_cerr << __FILE__ ": vepl1_erode_disk() not implemented for " << image << vcl_endl;
00087 return 0;
00088 }
00089 }
00090