矩形
Mat shape = getStructuringElement(MORPH_RECT, {5,5});
for (int i=0; i<shape.rows; i++) {
for (int j=0; j<shape.cols; j++) {
printf("%d,",shape.data[i*shape.cols+j]);
}
printf("\n");
}
1,1,1,1,1,
1,1,1,1,1,
1,1,1,1,1,
1,1,1,1,1,
1,1,1,1,1,
十字形
Mat shape = getStructuringElement(MORPH_CROSS, {5,5});
for (int i=0; i<shape.rows; i++) {
for (int j=0; j<shape.cols; j++) {
printf("%d,",shape.data[i*shape.cols+j]);
}
printf("\n");
}
0,0,1,0,0,
0,0,1,0,0,
1,1,1,1,1,
0,0,1,0,0,
0,0,1,0,0,
椭圆
Mat shape = getStructuringElement(MORPH_ELLIPSE, {9,9});
for (int i=0; i<shape.rows; i++) {
for (int j=0; j<shape.cols; j++) {
printf("%d,",shape.data[i*shape.cols+j]);
}
printf("\n");
}
0,0,0,0,1,0,0,0,0,
0,1,1,1,1,1,1,1,0,
0,1,1,1,1,1,1,1,0,
1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,
0,1,1,1,1,1,1,1,0,
0,1,1,1,1,1,1,1,0,
0,0,0,0,1,0,0,0,0,
用于不同形状的剃度处理,可以用于权重操作