原理和Grayscale Dilation类似,只是Erosion是找minimun。
1
#include "stdafx.h"
2
#include <vector>
3
#include <algorithm>
4
5
using namespace System::Drawing;
6
using namespace System::Drawing::Imaging;
7
8
typedef std::pair<int, int> MyPoint;
9
typedef std::vector<MyPoint> MyPointVec;
10
typedef int GrayLevel;
11
12
// Make kernel by radius
13
MyPointVec makeKernel(const int&);
14
// Process erosion
15
Bitmap^ erosion(Bitmap^, const MyPointVec%);
16
// Get min gray level by kernel
17
GrayLevel getMinByKernel(Bitmap^, const MyPointVec%, const MyPoint%);
18
// Get gray level from Color object
19
GrayLevel getGrayLevelFromColor(Color^);
20
21
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
原图
执行结果
See Also
如何使用C++/CLI对图片做Grayscale Dilation?
如何使用C++/CLI对图片做Grayscale Opening?
如何使用C++/CLI对图片做Grayscale Closing?