23 #include <fvfilters/sobel.h> 25 #include <core/exception.h> 29 #elif defined(HAVE_OPENCV) 31 # include <opencv2/imgproc.hpp> 33 # error "Neither IPP nor OpenCV available" 74 k[0] = 1; k[1] = 2; k[2] = 1;
75 k[3] = 0; k[4] = 0; k[5] = 0;
76 k[6] = -1; k[7] = -2; k[8] = -1;
79 k[0] = 2; k[1] = 1; k[2] = 0;
80 k[3] = 1; k[4] = 0; k[5] = -1;
81 k[6] = 0; k[7] = -1; k[8] = -2;
84 k[0] = 1; k[1] = 0; k[2] = -1;
85 k[3] = 2; k[4] = 0; k[5] = -2;
86 k[6] = 1; k[7] = 0; k[8] = -1;
89 k[0] = 0; k[1] = -1; k[2] = -2;
90 k[3] = 1; k[4] = 0; k[5] = -1;
91 k[6] = 2; k[7] = 1; k[8] = 0;
94 k[0] = -1; k[1] = -2; k[2] = -1;
95 k[3] = 0; k[4] = 0; k[5] = 0;
96 k[6] = 1; k[7] = 2; k[8] = 1;
99 k[0] = -2; k[1] = -1; k[2] = 0;
100 k[3] = -1; k[4] = 0; k[5] = 1;
101 k[6] = 0; k[7] = 1; k[8] = 2;
104 k[0] = -1; k[1] = 0; k[2] = 1;
105 k[3] = -2; k[4] = 0; k[5] = 2;
106 k[6] = -1; k[7] = 0; k[8] = 1;
109 k[0] = 0; k[1] = 1; k[2] = 2;
110 k[3] = -1; k[4] = 0; k[5] = 1;
111 k[6] = -2; k[7] = -1; k[8] = 0;
114 throw fawkes::Exception(
"Cannot generate Sobel kernel for the given orientation");
125 #if defined(HAVE_IPP) 132 if (
ori[0] == ORI_HORIZONTAL) {
137 }
else if (
ori[0] == ORI_VERTICAL) {
142 }
else if ( (
ori[0] == ORI_DEG_0) ||
143 (
ori[0] == ORI_DEG_45) ||
144 (
ori[0] == ORI_DEG_90) ||
145 (
ori[0] == ORI_DEG_135) ||
146 (
ori[0] == ORI_DEG_180) ||
147 (
ori[0] == ORI_DEG_225) ||
148 (
ori[0] == ORI_DEG_270) ||
149 (
ori[0] == ORI_DEG_315) ||
150 (
ori[0] == ORI_DEG_360)
154 generate_kernel(kernel,
ori[0]);
156 IppiSize kernel_size;
157 kernel_size.width = kernel_size.height = 3;
160 anchor.x = anchor.y = 1;
171 status = ippStsNullPtrErr;
174 if ( status != ippStsNoErr ) {
177 #elif defined(HAVE_OPENCV) 182 src_roi[0]->line_step);
192 if (
ori[0] == ORI_HORIZONTAL) {
197 cv::Sobel(srcm, dstm, -1, 1, 0,
199 }
else if (
ori[0] == ORI_VERTICAL) {
204 cv::Sobel(srcm, dstm, -1, 0, 1,
206 }
else if ( (
ori[0] == ORI_DEG_0) ||
207 (
ori[0] == ORI_DEG_45) ||
208 (
ori[0] == ORI_DEG_90) ||
209 (
ori[0] == ORI_DEG_135) ||
210 (
ori[0] == ORI_DEG_180) ||
211 (
ori[0] == ORI_DEG_225) ||
212 (
ori[0] == ORI_DEG_270) ||
213 (
ori[0] == ORI_DEG_315) ||
214 (
ori[0] == ORI_DEG_360)
217 cv::Mat kernel(3, 3, CV_32F);
218 generate_kernel((
float *)kernel.ptr(),
ori[0]);
220 cv::filter2D(srcm, dstm, -1, kernel, cv::Point(1, 1));
fawkes::point_t start
ROI start.
unsigned int x
x coordinate
unsigned int width
ROI width.
FilterSobel(orientation_t ori=ORI_HORIZONTAL)
Constructor.
virtual void apply()
Apply the filter.
void shrink_region(ROI *r, unsigned int n)
This shrinks the regions as needed for a N x N matrix.
unsigned char ** src
Source buffers, dynamically allocated by Filter ctor.
Base class for exceptions in Fawkes.
unsigned int y
y coordinate
ROI ** src_roi
Source ROIs, dynamically allocated by Filter ctor.
unsigned int height
ROI height.
unsigned int line_step
line step
unsigned char * dst
Destination buffer.
unsigned int pixel_step
pixel step
orientation_t * ori
Orientations, one for each source image.
ROI * dst_roi
Destination ROI.