Skip to content

Commit 29ec8b2

Browse files
committed
feat: add Sobel function
1 parent 3acf7bc commit 29ec8b2

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed

cpp/FOCV_Function.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -1150,6 +1150,19 @@ jsi::Object FOCV_Function::invoke(jsi::Runtime& runtime, const jsi::Value* argum
11501150

11511151
cv::integral(*src, *dst);
11521152
} break;
1153+
case hashString("Sobel", 5): {
1154+
auto src = args.asMatPtr(1);
1155+
auto dst = args.asMatPtr(2);
1156+
auto ddepth = args.asNumber(3);
1157+
auto dx = args.asNumber(4);
1158+
auto dy = args.asNumber(5);
1159+
auto ksize = args.asNumber(6);
1160+
auto scale = args.asNumber(7);
1161+
auto delta = args.asNumber(8);
1162+
auto borderType = args.asNumber(9);
1163+
1164+
cv::Sobel(*src, *dst, ddepth, dx, dy, ksize, scale, delta, borderType);
1165+
} break;
11531166
case hashString("threshold", 9): {
11541167
auto src = args.asMatPtr(1);
11551168
auto dst = args.asMatPtr(2);

docs/pages/availablefunctions.md

+30
Original file line numberDiff line numberDiff line change
@@ -1999,6 +1999,36 @@ Calculates the integral of an image
19991999
invoke(name: 'integral', src: Mat, sum: Mat): void;
20002000
```
20012001

2002+
### Sobel
2003+
2004+
Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator.
2005+
2006+
- name Function name.
2007+
- src input image.
2008+
- dst output image of the same size and the same number of channels as src .
2009+
- ddepth output image depth, see combinations; in the case of 8-bit input images it will result in truncated derivatives.
2010+
- dx order of the derivative x.
2011+
- dy order of the derivative y.
2012+
- ksize size of the extended Sobel kernel; it must be 1, 3, 5, or 7.
2013+
- scale scale factor for the computed derivative values; by default, no scaling is applied (see getDerivKernels for details).
2014+
- delta delta value that is added to the results prior to storing them in dst.
2015+
- borderType Pixel extrapolation method, see BorderTypes. BORDER_WRAP is not supported.
2016+
2017+
```js
2018+
invoke(
2019+
name: 'Sobel',
2020+
src: Mat,
2021+
dst: Mat,
2022+
ddepth: number,
2023+
dx: number,
2024+
dy: number,
2025+
ksize: 1 | 3 | 5 | 7,
2026+
scale: number,
2027+
delta: number,
2028+
borderType: Exclude<BorderTypes, BorderTypes.BORDER_WRAP>
2029+
): void;
2030+
```
2031+
20022032
### threshold
20032033

20042034
Applies a fixed-level threshold to each array element

src/functions/ImageProcessing/ImageFiltering.ts

+26
Original file line numberDiff line numberDiff line change
@@ -267,4 +267,30 @@ export type ImageFiltering = {
267267
borderType: BorderTypes,
268268
borderValue: Scalar
269269
): void;
270+
271+
/**
272+
* Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator.
273+
* @param name Function name.
274+
* @param src input image.
275+
* @param dst output image of the same size and the same number of channels as src .
276+
* @param ddepth output image depth, see combinations; in the case of 8-bit input images it will result in truncated derivatives.
277+
* @param dx order of the derivative x.
278+
* @param dy order of the derivative y.
279+
* @param ksize size of the extended Sobel kernel; it must be 1, 3, 5, or 7.
280+
* @param scale scale factor for the computed derivative values; by default, no scaling is applied (see getDerivKernels for details).
281+
* @param delta delta value that is added to the results prior to storing them in dst.
282+
* @param borderType Pixel extrapolation method, see BorderTypes. BORDER_WRAP is not supported.
283+
*/
284+
invoke(
285+
name: 'Sobel',
286+
src: Mat,
287+
dst: Mat,
288+
ddepth: number,
289+
dx: number,
290+
dy: number,
291+
ksize: 1 | 3 | 5 | 7,
292+
scale: number,
293+
delta: number,
294+
borderType: Exclude<BorderTypes, BorderTypes.BORDER_WRAP>
295+
): void;
270296
};

0 commit comments

Comments
 (0)