forked from arrayfire/arrayfire
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsobel.cpp
More file actions
39 lines (34 loc) · 928 Bytes
/
sobel.cpp
File metadata and controls
39 lines (34 loc) · 928 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*******************************************************
* Copyright (c) 2014, ArrayFire
* All rights reserved.
*
* This file is distributed under 3-clause BSD license.
* The complete license agreement can be obtained at:
* http://arrayfire.com/licenses/BSD-3-Clause
********************************************************/
#include <af/image.h>
#include <af/arith.h>
#include <af/array.h>
#include "error.hpp"
namespace af
{
void sobel(array &dx, array &dy, const array &img, const unsigned ker_size)
{
af_array af_dx = 0;
af_array af_dy = 0;
AF_THROW(af_sobel_operator(&af_dx, &af_dy, img.get(), ker_size));
dx = array(af_dx);
dy = array(af_dy);
}
array sobel(const array &img, const unsigned ker_size, const bool isFast)
{
array dx;
array dy;
sobel(dx, dy, img, ker_size);
if (isFast) {
return abs(dx)+abs(dy);
} else {
return sqrt(dx*dx+dy*dy);
}
}
}