()
| 26 | } |
| 27 | |
| 28 | public boolean showDialog() { |
| 29 | int[] wList = WindowManager.getIDList(); |
| 30 | if (wList==null) { |
| 31 | IJ.noImage(); |
| 32 | return false; |
| 33 | } |
| 34 | int nGoodImages = 0; |
| 35 | for (int i=0; i<wList.length; i++) { |
| 36 | ImagePlus imp = WindowManager.getImage(wList[i]); |
| 37 | if (imp == null || imp.getWidth() != imp.getHeight() || !FHT.isPowerOf2(imp.getWidth())) |
| 38 | wList[i] = 0; //mark images that are not a power of 2 |
| 39 | else |
| 40 | nGoodImages++; |
| 41 | } |
| 42 | if (nGoodImages == 0) { |
| 43 | IJ.error("FFT Math", "Images must be a power of 2 size (256x256, 512x512, etc.)"); |
| 44 | return false; |
| 45 | } |
| 46 | int[] wList2 = new int[nGoodImages]; |
| 47 | String[] titles = new String[nGoodImages]; |
| 48 | for (int i=0, i2=0; i<wList.length; i++) { |
| 49 | if (wList[i] == 0) continue; //ignore this image, not power of 2 |
| 50 | wList2[i2] = wList[i]; |
| 51 | ImagePlus imp = WindowManager.getImage(wList2[i2]); |
| 52 | if (imp!=null) |
| 53 | titles[i2] = imp.getTitle(); |
| 54 | else |
| 55 | titles[i2] = ""; |
| 56 | i2++; |
| 57 | } |
| 58 | if (index1>=wList2.length) index1 = 0; |
| 59 | if (index2>=wList2.length) index2 = 0; |
| 60 | if (WindowManager.getImage(title)!=null) |
| 61 | title = WindowManager.getUniqueName(title); |
| 62 | GenericDialog gd = new GenericDialog("FFT Math"); |
| 63 | gd.addChoice("Image1: ", titles, titles[index1]); |
| 64 | gd.addChoice("Operation:", ops, ops[operation]); |
| 65 | gd.addChoice("Image2: ", titles, titles[index2]); |
| 66 | gd.addStringField("Result:", title); |
| 67 | gd.addCheckbox("Do inverse transform", doInverse); |
| 68 | gd.addHelp(IJ.URL2+"/docs/menus/process.html#fft-math"); |
| 69 | gd.showDialog(); |
| 70 | if (gd.wasCanceled()) |
| 71 | return false; |
| 72 | index1 = gd.getNextChoiceIndex(); |
| 73 | operation = gd.getNextChoiceIndex(); |
| 74 | index2 = gd.getNextChoiceIndex(); |
| 75 | title = gd.getNextString(); |
| 76 | doInverse = gd.getNextBoolean(); |
| 77 | imp1 = WindowManager.getImage(wList2[index1]); |
| 78 | imp2 = WindowManager.getImage(wList2[index2]); |
| 79 | return true; |
| 80 | } |
| 81 | |
| 82 | public void doMath(ImagePlus imp1, ImagePlus imp2) { |
| 83 | FHT h1, h2=null; |
no test coverage detected