protected java.awt.image.BufferedImage extractSelectedPixels(
     java.awt.image.BufferedImage image, int[] deltaMatrix, int noDifferenceMarker) {
   int type = image.getType();
   WritableRaster imageRaster = image.getRaster();
   switch (type) {
     case java.awt.image.BufferedImage.TYPE_INT_ARGB:
     case java.awt.image.BufferedImage.TYPE_INT_ARGB_PRE:
     case java.awt.image.BufferedImage.TYPE_4BYTE_ABGR:
     case java.awt.image.BufferedImage.TYPE_4BYTE_ABGR_PRE:
       imageRaster.setSamples(0, 0, imageWidth, imageHeight, 3, deltaMatrix);
       break;
     default:
       int vectorLength = imageWidth * imageHeight;
       int[] imagePixels = new int[vectorLength];
       int bandNumber = imageRaster.getNumBands();
       for (int k = 0; k < bandNumber; k++) {
         imagePixels = imageRaster.getSamples(0, 0, imageWidth, imageHeight, k, imagePixels);
         for (int n = 0; n < vectorLength; n++) {
           if (deltaMatrix[n] == noDifferenceMarker) {
             imagePixels[n] = spaceColor;
           }
         }
         ;
         imageRaster.setSamples(0, 0, imageWidth, imageHeight, k, imagePixels);
       }
   }
   ;
   return image;
 }
 public synchronized java.awt.image.BufferedImage getSynthesizedImage() {
   if (synthesizedImage != null) {
     return synthesizedImage;
   }
   ;
   if (foregroundImage != null) {
     formAndGetConnectedGraphs();
     int vectorLength = imageWidth * imageHeight;
     boolean[] bitMask = new boolean[vectorLength];
     for (int n = 0; n < graphs.length; n++) {
       graphs[n].enablePixels(recentFrameNumber, bitMask, imageWidth, imageHeight, tracks);
     }
     ;
     java.awt.image.BufferedImage extractedImage =
         new java.awt.image.BufferedImage(
             imageWidth, imageHeight, java.awt.image.BufferedImage.TYPE_4BYTE_ABGR);
     WritableRaster raster = extractedImage.getRaster();
     raster.setDataElements(0, 0, foregroundImage.getRaster());
     java.awt.image.BufferedImage resultImage = applyMaskAndCreateImage(extractedImage, bitMask);
     synthesizedImage = resultImage;
     return synthesizedImage;
   } else {
     return null;
   }
 }
 protected java.awt.image.BufferedImage applyMaskAndCreateImage(
     java.awt.image.BufferedImage image, boolean[] bitMask) {
   int[] deltaMatrix = Arrays.copyOf(contourPixels, contourPixels.length);
   if (makeSquareBlobsInSynthesizedImage) {
     for (int n = 0; n < deltaMatrix.length; n++) {
       deltaMatrix[n] = differenceMarker; // Прямоугольники вместо блобов
     }
   } else {
     WritableRaster imageRaster = image.getRaster();
     int vectorLength = imageWidth * imageHeight;
     int[] imagePixels = new int[vectorLength];
     int bandNumber = imageRaster.getNumBands();
     for (int k = 0; k < bandNumber; k++) {
       imagePixels = imageRaster.getSamples(0, 0, imageWidth, imageHeight, k, imagePixels);
       for (int n = 0; n < vectorLength; n++) {
         if (imagePixels[n] == noDifferenceMarker) {
           deltaMatrix[n] = synthesizedImageTransparency;
         }
       }
       ;
       imageRaster.setSamples(0, 0, imageWidth, imageHeight, k, imagePixels);
     }
   }
   ;
   for (int n = 0; n < deltaMatrix.length; n++) {
     if (!bitMask[n]) {
       deltaMatrix[n] = synthesizedImageTransparency;
     }
   }
   ;
   return extractSelectedPixels(image, deltaMatrix, noDifferenceMarker);
 }
 public synchronized java.awt.image.BufferedImage getSigmaImage() {
   if (sigmaImage != null) {
     return sigmaImage;
   }
   ;
   if (backgroundN < 0) {
     return null;
   }
   ;
   int vectorLength = imageWidth * imageHeight;
   int[][] pixels = new int[numberOfBands][vectorLength];
   for (int k = 0; k < numberOfBands; k++) {
     for (int n = 0; n < vectorLength; n++) {
       int sum = backgroundSum[k][n];
       int mean = 0;
       if (backgroundN > 0) {
         mean = sum / backgroundN;
         double dispersion = (backgroundSumX2[k][n] / backgroundN) - mean * mean;
         pixels[k][n] = (int) Math.sqrt(dispersion);
       }
     }
   }
   ;
   java.awt.image.BufferedImage resultImage;
   if (numberOfBands == 1) {
     resultImage =
         new java.awt.image.BufferedImage(
             imageWidth, imageHeight, java.awt.image.BufferedImage.TYPE_BYTE_GRAY);
   } else {
     resultImage =
         new java.awt.image.BufferedImage(
             imageWidth, imageHeight, java.awt.image.BufferedImage.TYPE_3BYTE_BGR);
   }
   ;
   WritableRaster resultRaster = resultImage.getRaster();
   for (int k = 0; k < numberOfBands; k++) {
     resultRaster.setSamples(0, 0, imageWidth, imageHeight, k, pixels[k]);
   }
   ;
   sigmaImage = resultImage;
   return resultImage;
 }