我需要检测位于特定像素周围的xxx距离处的像素。
有没有什么最优的算法来实现这一点?
谢谢。
发布于 2013-11-05 14:01:46
在任意一个坐标小于半径绝对值的情况下,通过遍历(0,0)进行圆形扩展,并将结果的坐标添加到像素的坐标上。
发布于 2013-11-05 14:11:56
试试这个:
创建两个点对象:(http://help.adobe.com/pt_BR/FlashPlatform/reference/actionscript/3/flash/geom/Point.html)以获取所需像素的(x,y)和周围对象的(x,y)。
然后使用Point.distance获得两个对象的距离。所以,你得到了像素的像素半径。
我希望你已经理解了。
发布于 2013-11-05 18:33:11
如果我有一个具有宽度和高度的位图:
centerX = width/2;
centerY = height/2;
radius = 250; // max radius to scan
for (j = 0; j < radius; j++) {
for (i = 0; i < 360; i++) {
radialX = centerX + sin(i) * j;
radialY = centerY + cos(i) * j;
// I can found the pixel data at:
radialX + (radialY * width);
}
}
https://stackoverflow.com/questions/19790390
复制相似问题