-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMMops.cpp
More file actions
31 lines (28 loc) · 827 Bytes
/
MMops.cpp
File metadata and controls
31 lines (28 loc) · 827 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//
// Created by nenec on 05/11/2024.
//
#include "MMops.h"
int erode(Mat& frame, Mat& element, int i, int j){
int value = 255;
for (int u=0; u<element.rows; u++) {
for (int v=0; v<element.cols; v++) {
if (element.at<uchar>(u,v) == 1) {
int temp = frame.at<uchar>(i+u, j+v);
value = min(temp, value);
}
}
}
return value;
}
int dilate(Mat& frame, Mat& element, int i, int j){
int value = 0;
for (int u=0; u<element.rows; u++) {
for (int v=0; v<element.cols; v++) {
if (element.at<uchar>(u,v) == 1) {
int temp = frame.at<uchar>(i-u, j-v);
value = max(temp, value);
}
}
}
return value;
}