Esempio n. 1
0
 private void doRGBProjection(ImageStack stack) {
   ImageStack[] channels = ChannelSplitter.splitRGB(stack, true);
   ImagePlus red = new ImagePlus("Red", channels[0]);
   ImagePlus green = new ImagePlus("Green", channels[1]);
   ImagePlus blue = new ImagePlus("Blue", channels[2]);
   imp.unlock();
   ImagePlus saveImp = imp;
   imp = red;
   color = "(red)";
   doProjection();
   ImagePlus red2 = projImage;
   imp = green;
   color = "(green)";
   doProjection();
   ImagePlus green2 = projImage;
   imp = blue;
   color = "(blue)";
   doProjection();
   ImagePlus blue2 = projImage;
   int w = red2.getWidth(), h = red2.getHeight(), d = red2.getStackSize();
   if (method == SD_METHOD) {
     ImageProcessor r = red2.getProcessor();
     ImageProcessor g = green2.getProcessor();
     ImageProcessor b = blue2.getProcessor();
     double max = 0;
     double rmax = r.getStatistics().max;
     if (rmax > max) max = rmax;
     double gmax = g.getStatistics().max;
     if (gmax > max) max = gmax;
     double bmax = b.getStatistics().max;
     if (bmax > max) max = bmax;
     double scale = 255 / max;
     r.multiply(scale);
     g.multiply(scale);
     b.multiply(scale);
     red2.setProcessor(r.convertToByte(false));
     green2.setProcessor(g.convertToByte(false));
     blue2.setProcessor(b.convertToByte(false));
   }
   RGBStackMerge merge = new RGBStackMerge();
   ImageStack stack2 =
       merge.mergeStacks(w, h, d, red2.getStack(), green2.getStack(), blue2.getStack(), true);
   imp = saveImp;
   projImage = new ImagePlus(makeTitle(), stack2);
 }
Esempio n. 2
0
 ImagePlus doMedianProjection() {
   IJ.showStatus("Calculating median...");
   ImageStack stack = imp.getStack();
   ImageProcessor[] slices = new ImageProcessor[sliceCount];
   int index = 0;
   for (int slice = startSlice; slice <= stopSlice; slice += increment)
     slices[index++] = stack.getProcessor(slice);
   ImageProcessor ip2 = slices[0].duplicate();
   ip2 = ip2.convertToFloat();
   float[] values = new float[sliceCount];
   int width = ip2.getWidth();
   int height = ip2.getHeight();
   int inc = Math.max(height / 30, 1);
   for (int y = 0; y < height; y++) {
     if (y % inc == 0) IJ.showProgress(y, height - 1);
     for (int x = 0; x < width; x++) {
       for (int i = 0; i < sliceCount; i++) values[i] = slices[i].getPixelValue(x, y);
       ip2.putPixelValue(x, y, median(values));
     }
   }
   if (imp.getBitDepth() == 8) ip2 = ip2.convertToByte(false);
   IJ.showProgress(1, 1);
   return new ImagePlus(makeTitle(), ip2);
 }