(ImageProcessor ip)
| 335 | } |
| 336 | |
| 337 | ImageProcessor pad(ImageProcessor ip) { |
| 338 | originalWidth = ip.getWidth(); |
| 339 | originalHeight = ip.getHeight(); |
| 340 | int maxN = Math.max(originalWidth, originalHeight); |
| 341 | int i = 2; |
| 342 | while(i<maxN) i *= 2; |
| 343 | if (i==maxN && originalWidth==originalHeight) { |
| 344 | padded = false; |
| 345 | return ip; |
| 346 | } |
| 347 | maxN = i; |
| 348 | showStatus("Padding to "+ maxN + "x" + maxN); |
| 349 | if (maxN>=65536) { |
| 350 | IJ.error("FFT", "Padded image is too large ("+maxN+"x"+maxN+")"); |
| 351 | return null; |
| 352 | } |
| 353 | ImageStatistics stats = ImageStatistics.getStatistics(ip, MEAN, null); |
| 354 | ImageProcessor ip2 = ip.createProcessor(maxN, maxN); |
| 355 | ip2.setValue(stats.mean); |
| 356 | ip2.fill(); |
| 357 | ip2.insert(ip, 0, 0); |
| 358 | padded = true; |
| 359 | Undo.reset(); |
| 360 | return ip2; |
| 361 | } |
| 362 | |
| 363 | void showStatus(String msg) { |
| 364 | if (stackSize>1) |
no test coverage detected