我使用Soble
运算符来获取一些有用的点。这是我的al:
for (int x = 0; x < mWidth; x++) {
for (int y = 0; y < mHeight; y++) {
int grayX = getGrayPoint(x + 1, y - 1) + 2 * getGrayPoint(x + 1, y) + getGrayPoint(x + 1, y + 1) -
(getGrayPoint(x - 1, y - 1) + 2 * getGrayPoint(x - 1, y) + getGrayPoint(x - 1, y + 1));
int grayY = (getGrayPoint(x - 1, y + 1) + 2 * getGrayPoint(x, y + 1) + getGrayPoint(x + 1, y + 1)) -
(getGrayPoint(x - 1, y - 1) + 2 * getGrayPoint(x, y - 1) + getGrayPoint(x + 1, y - 1));
int gradient = (int) Math.sqrt(grayX * grayX + grayY * grayY);
if (gradient > 40){
mEdgePoints.add(new int[]{x,y});
}
}
}
我知道Douglas-Peucker可以帮我简化边缘,但关键是边缘点的顺序。
那么我如何使用Douglas-Peucker al?