Exemplo n.º 1
0
  public void run(ImageProcessor image) {
    /**
     * ********************************************************************************* Initial
     * phase *********************************************************************************
     */
    int width = image.getWidth();
    int heigh = image.getHeight();
    ByteProcessor bp = Service.getByteProcessor(image);

    /**
     * ********************************************************************************* Convolve
     * with LoG kernel
     * *********************************************************************************
     */
    Convolver convolver = new Convolver();
    convolver.setNormalize(false);
    convolver.convolve(bp, log, (int) Math.sqrt(log.length), (int) Math.sqrt(log.length));
    ImagePlus outImg = new ImagePlus("Later Log kernel", bp);
    outImg.show();

    /**
     * ********************************************************************************* threshold
     * *********************************************************************************
     */
    ByteProcessor bpThreshold = Service.getByteProcessor(bp);
    int lut[] = new int[256];
    int i = 0;
    for (; i < threshold; i++) lut[i] = 0;
    for (int j = i; j < lut.length; j++) lut[j] = 255;
    bpThreshold.applyTable(lut);
    ImagePlus outImg1 = new ImagePlus("Later threshold phase", bpThreshold);
    outImg1.show();

    /**
     * ********************************************************************************* Find Zero
     * crossing *********************************************************************************
     */
    ByteProcessor out = new ByteProcessor(width, heigh);
    for (i = 0; i < width; i++) for (int j = 0; j < heigh; j++) out.set(i, j, 255);
    for (int x = 0; x < width - 1; x++) {
      for (int y = 0; y < heigh - 1; y++) {
        if (bpThreshold.get(x, y) != bpThreshold.get(x, y + 1)) out.set(x, y, 0);
        if (bpThreshold.get(x, y) != bpThreshold.get(x + 1, y)) out.set(x, y, 0);
        if (bpThreshold.get(x, y) != bpThreshold.get(x + 1, y + 1)) out.set(x, y, 0);
      }
    }
    ImagePlus outImg2 = new ImagePlus("Edge Find", out);
    outImg2.show();
  }
Exemplo n.º 2
0
 private void calculateGreyValues() {
   int size = image.getPixelCount();
   int gray;
   for (int pos = 0; pos < size; pos++) {
     gray = image.get(pos);
     grayValue[pos] = (byte) (gray / GRAY_SCALE); // quantized for texture analysis
     grayHistogram[gray]++;
   }
   Arrays2.div(grayHistogram, size);
 }