mirror of
https://github.com/peterbraden/node-opencv.git
synced 2025-12-08 19:45:55 +00:00
Add kernel argument to Dilate and Erode methods
A second optional argument can be passed to `mat.erode` and `mat.dilate`. This argument define the kernel used for this morphological operation. A kernel can be generated by the GetStructuringElement function.
This commit is contained in:
parent
e3090f4176
commit
162b091f25
@ -1341,7 +1341,13 @@ NAN_METHOD(Matrix::Dilate) {
|
||||
Matrix *self = Nan::ObjectWrap::Unwrap<Matrix>(info.This());
|
||||
int niters = info[0]->NumberValue();
|
||||
|
||||
cv::dilate(self->mat, self->mat, cv::Mat(), cv::Point(-1, -1), niters);
|
||||
cv::Mat kernel = cv::Mat();
|
||||
if (info.Length() == 2) {
|
||||
Matrix *kernelMatrix = Nan::ObjectWrap::Unwrap<Matrix>(info[1]->ToObject());
|
||||
kernel = kernelMatrix->mat;
|
||||
}
|
||||
|
||||
cv::dilate(self->mat, self->mat, kernel, cv::Point(-1, -1), niters);
|
||||
|
||||
info.GetReturnValue().Set(Nan::Null());
|
||||
}
|
||||
@ -1352,7 +1358,12 @@ NAN_METHOD(Matrix::Erode) {
|
||||
Matrix *self = Nan::ObjectWrap::Unwrap<Matrix>(info.This());
|
||||
int niters = info[0]->NumberValue();
|
||||
|
||||
cv::erode(self->mat, self->mat, cv::Mat(), cv::Point(-1, -1), niters);
|
||||
cv::Mat kernel = cv::Mat();
|
||||
if (info.Length() == 2) {
|
||||
Matrix *kernelMatrix = Nan::ObjectWrap::Unwrap<Matrix>(info[1]->ToObject());
|
||||
kernel = kernelMatrix->mat;
|
||||
}
|
||||
cv::erode(self->mat, self->mat, kernel, cv::Point(-1, -1), niters);
|
||||
|
||||
info.GetReturnValue().Set(Nan::Null());
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user