Go to the documentation of this file.00001
00002 #include "vepl1_y_gradient.h"
00003 #include <vipl/accessors/vipl_accessors_vil1_image.h>
00004 #include <vipl/vipl_y_gradient.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_y_gradient(vil1_image const& image, double scale, double shift)
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_y_gradient<vil1_image,vil1_image,vxl_byte,vxl_byte> op(scale, vxl_byte(shift+0.5));
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 #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 > mem(image);
00026 vil1_memory_image_of<r_g_b > out(image);
00027 vipl_y_gradient<vil1_image,vil1_image,r_g_b,r_g_b > op(scale, r_g_b(vxl_byte(shift+0.5)) );
00028 op.put_in_data_ptr(&mem);
00029 op.put_out_data_ptr(&out);
00030 op.filter();
00031 return out;
00032 }
00033
00034
00035 else if (vil1_pixel_format(image) == VIL1_UINT16) {
00036 vil1_memory_image_of<vxl_uint_16> mem(image);
00037 vil1_memory_image_of<vxl_uint_16> out(image);
00038 vipl_y_gradient<vil1_image,vil1_image,vxl_uint_16,vxl_uint_16> op(scale, vxl_uint_16(shift+0.5));
00039 op.put_in_data_ptr(&mem);
00040 op.put_out_data_ptr(&out);
00041 op.filter();
00042 return out;
00043 }
00044
00045
00046 else if (vil1_pixel_format(image) == VIL1_FLOAT) {
00047 vil1_memory_image_of<float> mem(image);
00048 vil1_memory_image_of<float> out(image);
00049 vipl_y_gradient<vil1_image,vil1_image,float,float> op(scale, (float)shift);
00050 op.put_in_data_ptr(&mem);
00051 op.put_out_data_ptr(&out);
00052 op.filter();
00053 return out;
00054 }
00055
00056
00057 else if (vil1_pixel_format(image) == VIL1_DOUBLE) {
00058 vil1_memory_image_of<double> mem(image);
00059 vil1_memory_image_of<double> out(image);
00060 vipl_y_gradient<vil1_image,vil1_image,double,double> op(scale, shift);
00061 op.put_in_data_ptr(&mem);
00062 op.put_out_data_ptr(&out);
00063 op.filter();
00064 return out;
00065 }
00066
00067
00068 else {
00069 vcl_cerr << __FILE__ ": vepl1_y_gradient() not implemented for " << image << vcl_endl;
00070 return 0;
00071 }
00072 }
00073