Skip to content

Commit cb2be45

Browse files
committed
feat: add support for the function 'getStructuringElement'
1 parent 2d7113f commit cb2be45

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

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

docs/pages/availablefunctions.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,6 +1793,23 @@ invoke(
17931793
): Mat;
17941794
```
17951795

1796+
### getStructuringElement
1797+
1798+
Returns a structuring element of the specified size and shape for morphological operations.
1799+
1800+
- shape Element shape that could be one of MorphShapes
1801+
- ksize Size of the structuring element.
1802+
- 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..
1803+
1804+
```js
1805+
invoke(
1806+
name: 'getGaussianKernel',
1807+
shape: MorphShapes,
1808+
ksize: Size,
1809+
anchor: Point
1810+
): Mat;
1811+
```
1812+
17961813
### Laplacian
17971814
Calculates the Laplacian of an image.
17981815
- name Function name.

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)