Skip to content

Commit 855c0df

Browse files
committed
feat: add Sobel function
1 parent 1bb7a7e commit 855c0df

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
@@ -1151,6 +1151,19 @@ jsi::Object FOCV_Function::invoke(jsi::Runtime& runtime, const jsi::Value* argum
11511151

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

docs/pages/availablefunctions.md

+30
Original file line numberDiff line numberDiff line change
@@ -1940,6 +1940,36 @@ Calculates the integral of an image
19401940
invoke(name: 'integral', src: Mat, sum: Mat): void;
19411941
```
19421942

1943+
### Sobel
1944+
1945+
Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator.
1946+
1947+
- name Function name.
1948+
- src input image.
1949+
- dst output image of the same size and the same number of channels as src .
1950+
- ddepth output image depth, see combinations; in the case of 8-bit input images it will result in truncated derivatives.
1951+
- dx order of the derivative x.
1952+
- dy order of the derivative y.
1953+
- ksize size of the extended Sobel kernel; it must be 1, 3, 5, or 7.
1954+
- scale scale factor for the computed derivative values; by default, no scaling is applied (see getDerivKernels for details).
1955+
- delta delta value that is added to the results prior to storing them in dst.
1956+
- borderType Pixel extrapolation method, see BorderTypes. BORDER_WRAP is not supported.
1957+
1958+
```js
1959+
invoke(
1960+
name: 'Sobel',
1961+
src: Mat,
1962+
dst: Mat,
1963+
ddepth: number,
1964+
dx: number,
1965+
dy: number,
1966+
ksize: 1 | 3 | 5 | 7,
1967+
scale: number,
1968+
delta: number,
1969+
borderType: Exclude<BorderTypes, BorderTypes.BORDER_WRAP>
1970+
): void;
1971+
```
1972+
19431973
### threshold
19441974
Applies a fixed-level threshold to each array element
19451975
- name Function name.

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)