TuttleOFX
1
|
00001 #ifndef _TERRY_FILTER_SOBEL_HPP_ 00002 #define _TERRY_FILTER_SOBEL_HPP_ 00003 00004 #include "gaussianKernel.hpp" 00005 00006 #include <terry/filter/convolve.hpp> 00007 #include <terry/numeric/operations.hpp> 00008 00009 namespace terry { 00010 namespace filter { 00011 00012 /** 00013 * @brief Sobel filtering. 00014 */ 00015 template<template<typename> class Alloc, class SView, class DView> 00016 void sobel( const SView& srcView, const DView& dstViewX, const DView& dstViewY, const point2<double>& size, const convolve_boundary_option boundary_option ) 00017 { 00018 typedef typename SView::point_t Point; 00019 typedef typename channel_mapping_type<DView>::type DChannel; 00020 typedef typename floating_channel_type_t<DChannel>::type DChannelFloat; 00021 typedef pixel<DChannelFloat, gray_layout_t> DPixelGray; 00022 00023 const bool normalizedKernel = false; 00024 const double kernelEpsilon = 0.001; 00025 const Point proc_tl( 0, 0 ); 00026 00027 typedef float Scalar; 00028 kernel_1d<Scalar> xKernelGaussianDerivative = buildGaussianDerivative1DKernel<Scalar>( size.x, normalizedKernel, kernelEpsilon ); 00029 kernel_1d<Scalar> xKernelGaussian = buildGaussian1DKernel<Scalar>( size.x, normalizedKernel, kernelEpsilon ); 00030 kernel_1d<Scalar> yKernelGaussianDerivative = buildGaussianDerivative1DKernel<Scalar>( size.y, normalizedKernel, kernelEpsilon ); 00031 kernel_1d<Scalar> yKernelGaussian = buildGaussian1DKernel<Scalar>( size.y, normalizedKernel, kernelEpsilon ); 00032 00033 correlate_rows_cols_auto<DPixelGray, Alloc>( 00034 color_converted_view<DPixelGray>( srcView ), 00035 xKernelGaussianDerivative, 00036 xKernelGaussian, 00037 dstViewX, 00038 proc_tl, 00039 boundary_option ); 00040 00041 correlate_rows_cols_auto<DPixelGray, Alloc>( 00042 color_converted_view<DPixelGray>( srcView ), 00043 yKernelGaussian, 00044 yKernelGaussianDerivative, 00045 dstViewY, 00046 proc_tl, 00047 boundary_option ); 00048 } 00049 00050 } 00051 } 00052 00053 #endif 00054