Skip to content

Commit 2cc7ffb

Browse files
committed
feat: add support for the function 'getStructuringElement'
1 parent 5bbc207 commit 2cc7ffb

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

cpp/FOCV_Function.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,6 +1079,16 @@ jsi::Object FOCV_Function::invoke(jsi::Runtime& runtime, const jsi::Value* argum
10791079

10801080
return FOCV_JsiObject::wrap(runtime, "mat", id);
10811081
} break;
1082+
case hashString("getStructuringElement", 21): {
1083+
auto shape = args.asNumber(1);
1084+
auto ksize = args.asSizePtr(2);
1085+
auto anchor = args.asPointPtr(3);
1086+
1087+
cv::Mat result = cv::getStructuringElement(shape, *ksize, *anchor);
1088+
std::string id = FOCV_Storage::save(result);
1089+
1090+
return FOCV_JsiObject::wrap(runtime, "mat", id);
1091+
} break;
10821092
case hashString("Laplacian", 9): {
10831093
auto src = args.asMatPtr(1);
10841094
auto dst = args.asMatPtr(2);

docs/pages/availablefunctions.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1842,6 +1842,23 @@ invoke(
18421842
): Mat;
18431843
```
18441844

1845+
### getStructuringElement
1846+
1847+
Returns a structuring element of the specified size and shape for morphological operations.
1848+
1849+
- shape Element shape that could be one of MorphShapes
1850+
- ksize Size of the structuring element.
1851+
- anchor Anchor position within the element. The default value means that the anchor is at the center. Note that only the shape of a cross-shaped element depends on the anchor position. In other cases the anchor just regulates how much the result of the morphological operation is shifted..
1852+
1853+
```js
1854+
invoke(
1855+
name: 'getGaussianKernel',
1856+
shape: MorphShapes,
1857+
ksize: Size,
1858+
anchor: Point
1859+
): Mat;
1860+
```
1861+
18451862
### Laplacian
18461863

18471864
Calculates the Laplacian of an image.

src/functions/ImageProcessing/ImageFiltering.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { BorderTypes } from '../../constants/Core';
22
import type { DataTypes } from '../../constants/DataTypes';
3-
import type { MorphTypes } from '../../constants/ImageProcessing';
3+
import type { MorphShapes, MorphTypes } from '../../constants/ImageProcessing';
44
import type { Mat, Point, Scalar, Size } from '../../objects/Objects';
55

66
export type ImageFiltering = {
@@ -192,6 +192,19 @@ export type ImageFiltering = {
192192
ktype: DataTypes.CV_32F | DataTypes.CV_64F
193193
): Mat;
194194

195+
/**
196+
* Returns a structuring element of the specified size and shape for morphological operations.
197+
* @param shape Element shape that could be one of MorphShapes
198+
* @param ksize Size of the structuring element.
199+
* @param anchor Anchor position within the element. The default value means that the anchor is at the center. Note that only the shape of a cross-shaped element depends on the anchor position. In other cases the anchor just regulates how much the result of the morphological operation is shifted.
200+
*/
201+
invoke(
202+
name: 'getStructuringElement',
203+
shape: MorphShapes,
204+
ksize: Size,
205+
anchor: Point
206+
): Mat;
207+
195208
/**
196209
* Calculates the Laplacian of an image.
197210
* @param name Function name.

0 commit comments

Comments
 (0)