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

Method noise

ij/src/main/java/ij/process/ByteProcessor.java:872–893  ·  view source on GitHub ↗

Adds pseudorandom, Gaussian ("normally") distributed values, with mean 0.0 and the specified standard deviation, to this image or ROI.

(double standardDeviation)

Source from the content-addressed store, hash-verified

870 /** Adds pseudorandom, Gaussian ("normally") distributed values, with
871 mean 0.0 and the specified standard deviation, to this image or ROI. */
872 public void noise(double standardDeviation) {
873 if (rnd==null)
874 rnd = new Random();
875 if (!Double.isNaN(seed))
876 rnd.setSeed((int)seed);
877 seed = Double.NaN;
878 int v, ran;
879 boolean inRange;
880 for (int y=roiY; y<(roiY+roiHeight); y++) {
881 int i = y * width + roiX;
882 for (int x=roiX; x<(roiX+roiWidth); x++) {
883 inRange = false;
884 do {
885 ran = (int)Math.round(rnd.nextGaussian()*standardDeviation);
886 v = (pixels[i] & 0xff) + ran;
887 inRange = v>=0 && v<=255;
888 if (inRange) pixels[i] = (byte)v;
889 } while (!inRange);
890 i++;
891 }
892 }
893 }
894
895
896 /** Scales the image or selection using the specified scale factors.

Callers 6

fillNoiseRGBMethod · 0.95
filterRGBMethod · 0.95
runMethod · 0.45
fillNoiseByteMethod · 0.45
fillNoiseShortMethod · 0.45
fillNoiseFloatMethod · 0.45

Calls 2

setSeedMethod · 0.80
roundMethod · 0.45

Tested by

no test coverage detected