MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / doMasking

Method doMasking

ij/src/main/java/ij/plugin/FFT.java:370–402  ·  view source on GitHub ↗
(FHT ip)

Source from the content-addressed store, hash-verified

368 }
369
370 void doMasking(FHT ip) {
371 if (stackSize>1)
372 return;
373 float[] fht = (float[])ip.getPixels();
374 ImageProcessor mask = imp.getProcessor();
375 int bitDepth = mask.getBitDepth();
376 mask = mask.convertToByte(false);
377 if (mask.getWidth()!=ip.getWidth() || mask.getHeight()!=ip.getHeight())
378 return;
379 mask.resetRoi();
380 ImageStatistics stats = mask.getStats();
381 if (stats.histogram[0]==0 && stats.histogram[255]==0) {
382 if (bitDepth==8 && ip.powerSpectrumMean!=stats.mean)
383 IJ.showMessage("Inverse FFT", "No pixels have been set to 0 (black) or\n255 (white) so filtering will not be done.");
384 return;
385 }
386 boolean passMode = stats.histogram[255]!=0;
387 IJ.showStatus("Masking: "+(passMode?"pass":"filter"));
388 mask = mask.duplicate();
389 if (passMode)
390 changeValuesAndSymmetrize(mask, (byte)255, (byte)0); //0-254 become 0
391 else
392 changeValuesAndSymmetrize(mask, (byte)0, (byte)255); //1-255 become 255
393 for (int i=0; i<3; i++)
394 smooth(mask);
395 if (IJ.debugMode || IJ.altKeyDown())
396 new ImagePlus("mask", mask.duplicate()).show();
397 swapQuadrants(mask);
398 byte[] maskPixels = (byte[])mask.getPixels();
399 for (int i=0; i<fht.length; i++) {
400 fht[i] = (float)(fht[i]*(maskPixels[i]&255)/255.0);
401 }
402 }
403
404 // Change pixels not equal to v1 to the new value v2.
405 // For pixels equal to v1, also the symmetry-equivalent pixel is set to v1

Callers 1

doInverseTransformMethod · 0.95

Calls 15

getBitDepthMethod · 0.95
convertToByteMethod · 0.95
getWidthMethod · 0.95
getHeightMethod · 0.95
resetRoiMethod · 0.95
getStatsMethod · 0.95
showMessageMethod · 0.95
showStatusMethod · 0.95
duplicateMethod · 0.95
smoothMethod · 0.95
altKeyDownMethod · 0.95

Tested by

no test coverage detected