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