3、*/ 10.public int[] process() { 11. 1. // 对于圆的极坐标变换来说,我们需要360度的空间梯度叠加值 2. acc = new int[width * height]; 3. for (int y = 0; y < height; y++) { 4. for (int x = 0; x < width; x++) { 5. acc[y * width + x] = 0; 6. } 7
4、. } 8. int x0, y0; 9. double t; 10. for (int x = 0; x < width; x++) { 11. for (int y = 0; y < height; y++) { 12. 13. if ((input[y * width + x] & 0xff) == 255) { 14. 15. for (int theta = 0; theta < 360;
5、theta++) { 16. t = (theta * 3.) / 180; // 角度值0 ~ 2*PI 17. x0 = (int) Math.round(x - r * Math.cos(t)); 18. y0 = (int) Math.round(y - r * Math.sin(t)); 19. if (x0 < width && x0
6、> 0 && y0 < height && y0 > 0) { 20. acc[x0 + (y0 * width)] += 1; 21. } 22. } 23. } 24. } 25. } 26. 27. // now normalise to 255 and put in format for a pixel array 28
7、. int max = 0; 29. 30. // Find max acc value 31. for (int x = 0; x < width; x++) { 32. for (int y = 0; y < height; y++) { 33. 34. if (acc[x + (y * width)] > max) { 35. max = acc[x + (y * width)]; 36.
8、 } 37. } 38. } 39. 40. // 根据最大值,实现极坐标空间的灰度值归一化处理 41. int value; 42. for (int x = 0; x < width; x++) { 43. for (int y = 0; y < height; y++) { 1. value = (int) (((doub