当前位置: 首页>>代码示例>>Java>>正文


Java PlanarImage类代码示例

本文整理汇总了Java中javax.media.jai.PlanarImage的典型用法代码示例。如果您正苦于以下问题:Java PlanarImage类的具体用法?Java PlanarImage怎么用?Java PlanarImage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PlanarImage类属于javax.media.jai包,在下文中一共展示了PlanarImage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: grayToGray256

import javax.media.jai.PlanarImage; //导入依赖的package包/类
private static PlanarImage grayToGray256 (PlanarImage image)
{
    System.out.println("Converting gray image to gray-256 ...");

    ColorSpace colorSpace = ColorSpace.getInstance(java.awt.color.ColorSpace.CS_GRAY);

    //        int[] bits = new int[]{8};
    //        int opaque = Transparency.OPAQUE;
    //        int dataType = DataBuffer.TYPE_BYTE;
    //        ColorModel colorModel = new ComponentColorModel
    //            (colorSpace, bits, false, false, opaque, dataType);
    return JAI.create("colorConvert", image, colorSpace, null);
}
 
开发者ID:Audiveris,项目名称:audiveris,代码行数:14,代码来源:TestImage3.java

示例2: setColorModel

import javax.media.jai.PlanarImage; //导入依赖的package包/类
/**
 * Attempts to retrieve or create a <code>ColorModel</code> for the target
 * image.
 *
 * @throws UnsupportedOperationException if a compatible
 *                                       <code>ColorModel</code> is not found
 */
private void setColorModel() {
    assert (targetImage != null);

    colorModel = targetImage.getColorModel();

    if (colorModel == null) {
        SampleModel sm = targetImage.getSampleModel();
        colorModel = PlanarImage.createColorModel(sm);

        if (colorModel == null) {
            // try simple default
            if (ColorModel.getRGBdefault().isCompatibleSampleModel(sm)) {
                colorModel = ColorModel.getRGBdefault();

            } else {
                // admit defeat
                throw new UnsupportedOperationException(
                        "Failed to get or construct a ColorModel for the image");
            }
        }
    }
}
 
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:30,代码来源:DiskMemImageGraphicsOrbit.java

示例3: makeROIImage

import javax.media.jai.PlanarImage; //导入依赖的package包/类
private RecognitionFrame makeROIImage(RecognitionFrame rf, Shape roi) {
    TiledImagePainter ci = rf.bimg;
    if (roi != null) {
        Rectangle roiBounds = roi.getBounds();
        if (logger.isTraceEnabled() && (roiBounds.getWidth() == 0 || roiBounds.getHeight() == 0)) {
            logger.trace("Warning: ROI bounds with width=0 or height=0. Skipping tile.");
            //return null; // instead an error message will be thrown in getAsBufferedImage
        }
        BufferedImage bi = rf.bimg.getImage().getAsBufferedImage(roiBounds, rf.bimg.getImage().getColorModel());
        ci = new TiledImagePainter(PlanarImage.wrapRenderedImage(bi), "roi");
        ci.getImage().setUseCache(false);
    }
    RecognitionFrame rf2 = new RecognitionFrame(ci);
    rf2.setClassShapes(rf.getClassShapes());
    rf2.initializeClassColors();
    ci.getImage().setUseCache(false);
    return rf2;
}
 
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:19,代码来源:ObjectSegmentationWorker.java

示例4: process

import javax.media.jai.PlanarImage; //导入依赖的package包/类
public PlanarImage process(final PlanarImage image) {
    if (image == null || (image.getWidth() * image.getHeight() > 6000 * 6000L))
        throw new IllegalArgumentException("this implementation can only handle images where width*height<=6000*6000. (And image cannot be null)");

    TMAPointsResult res = findCircles(image);
    this.radius = res.getRadius();
    List<Point> pList = res.getSpotList();

    HashMap<Point, Point> pMap = clusterLines(pList);
    pMap = discardDuplicatePoints(pMap);

    BufferedImage buffImg = res.getSpotImage();
    Graphics g = buffImg.createGraphics();
    g.setColor(Color.blue);
    g.setFont(new Font("System", Font.PLAIN, 9));
    for (Point p : pMap.keySet()) {
        Point pos = pMap.get(p);
        g.drawString(pos.x + "/" + pos.y, p.x, p.y);
    }

    spotMap = pMap;

    return PlanarImage.wrapRenderedImage(buffImg);
}
 
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:25,代码来源:TMAPoints.java

示例5: reportPoints

import javax.media.jai.PlanarImage; //导入依赖的package包/类
/**
 * returns all UEP with a threshold > min in a pointlist.
 * The UEP process has to be applied before!
 *
 * @param img
 * @param min
 * @return
 */
private List<Point> reportPoints(PlanarImage img, int min) {
    Raster r = img.getData();
    int[] rgb = new int[3];
    double d;
    List<Point> pList = new ArrayList<Point>();
    for (int x = 0; x < img.getWidth(); x++)
        for (int y = 0; y < img.getHeight(); y++) {
            rgb = r.getPixel(x, y, rgb);
            d = (rgb[0]);
            if (d > min) {
                Point p = new Point(x, y);
                pList.add(p);
                if (logger.isTraceEnabled()) {
                    logger.trace(x + "," + y + ": " + d);
                }
            }
        }
    return pList;
}
 
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:28,代码来源:TMAPoints.java

示例6: toBinaryImagePlus

import javax.media.jai.PlanarImage; //导入依赖的package包/类
/**
 * Creats a binary ImagePlus based on a planar image. If a pixel is fg it is set to white, otherwise to black.
 *
 * @param image
 * @param fg
 * @return
 */
public static ImagePlus toBinaryImagePlus(PlanarImage image, Color fg) {
    if (image == null || (image.getWidth() * image.getHeight() > 6000 * 6000L))
        throw new IllegalArgumentException("this implementation can only handle images where width*height<=6000*6000. (And image cannot be null)");
    int width = image.getWidth();
    int height = image.getHeight();
    Raster raster = image.getData();
    int[] arr = new int[4];

    // set background to black and foreground to white for imageJ watershed
    BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
    int b = 0;
    for (int y = b; y < height - b; y++) {
        for (int x = b; x < width - b; x++) {
            arr = raster.getPixel(x, y, arr);
            if (arr[0] == fg.getRed() && arr[1] == fg.getGreen() && arr[2] == fg.getBlue()) {
                bi.setRGB(x, y, Color.WHITE.getRGB());
            } else {
                bi.setRGB(x, y, Color.BLACK.getRGB());
            }

        }
    }
    ImagePlus ip = new ImagePlus("watershed", bi);
    return ip;
}
 
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:33,代码来源:IJUtils.java

示例7: toPlanarImage

import javax.media.jai.PlanarImage; //导入依赖的package包/类
/**
 * Creats a planar image based on an ImagePlus. The originalImage is just used for dimensions and tileSize (could be replaced by its int values).
 *
 * @param ip
 * @param originalImage
 * @param fg
 * @param bg
 * @return
 */
public static PlanarImage toPlanarImage(ImagePlus ip, PlanarImage originalImage, Color fg, Color bg) {
    TiledImageWriter imageWriter = new TiledImageWriter(originalImage.getWidth(), originalImage.getHeight(), originalImage.getTileWidth(), originalImage.getTileHeight());

    // resImg
    Point[] tileArr = imageWriter.getImage().getTileIndices(null);
    int[] p = new int[4];
    int[] bgArr = new int[]{bg.getRed(), bg.getGreen(), bg.getBlue(), 255};
    int[] fgArr = new int[]{fg.getRed(), fg.getGreen(), fg.getBlue(), 255};
    for (Point tileNum : tileArr) {
        WritableRaster writeRaster = imageWriter.getImage().getWritableTile(tileNum.x, tileNum.y);
        for (int x = imageWriter.getImage().tileXToX(tileNum.x); x < Math.min(imageWriter.getImage().tileXToX(tileNum.x) + imageWriter.getImage().getTileWidth(), imageWriter.getImage().getWidth()); x++)
            for (int y = imageWriter.getImage().tileYToY(tileNum.y); y < Math.min(imageWriter.getImage().tileYToY(tileNum.y) + imageWriter.getImage().getTileHeight(), imageWriter.getImage().getHeight()); y++) {
                p = ip.getPixel(x, y);
                if (p[0] != 0) p = fgArr;
                else p = bgArr;
                writeRaster.setPixel(x, y, p);  // since it is not a gray-scale image, we just use the red channel
            } // x,y
        imageWriter.getImage().releaseWritableTile(tileNum.x, tileNum.y);
    } // tileNum

    return imageWriter.getImage();
}
 
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:32,代码来源:IJUtils.java

示例8: TiledImageWriter

import javax.media.jai.PlanarImage; //导入依赖的package包/类
public TiledImageWriter(PlanarImage inputImage, int xOffs, int yOffs) {
    this.width = inputImage.getWidth();
    this.height = inputImage.getHeight();
    this.tileWidth = inputImage.getTileWidth();
    this.tileHeight = inputImage.getTileHeight();
    colorModel = new ComponentColorModel(
            ColorSpace.getInstance(ColorSpace.CS_sRGB),
            new int[]{8, 8, 8, 8}, true, false,
            Transparency.TRANSLUCENT,
            DataBuffer.TYPE_BYTE);
    sampleModel = colorModel.createCompatibleSampleModel(tileWidth, tileHeight);
    image = new DiskMemImageOrbit(xOffs, yOffs, width, height, 0, 0, sampleModel, colorModel);
    ((DiskMemImageOrbit) image).setUseCommonCache(true);

    TiledImagePainter painter = new TiledImagePainter(inputImage, "");
    Graphics2D g2d = image.createGraphics();
    try { // 03.05.2010 Manuel (exception with JRE 1.5, with JRE 1.6 fine)
        painter.drawImage(g2d, xOffs, yOffs, width, height, 100d, -1);
    } catch (Throwable e) {
        //System.out.println("TiledImageWriter Error",e);
        //e.printStackTrace();
    }
}
 
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:24,代码来源:TiledImageWriter.java

示例9: getTileData

import javax.media.jai.PlanarImage; //导入依赖的package包/类
@Override
public Raster getTileData(int tileX, int tileY, float[] channelContributions, boolean analysis, float[] analysisHues) {
    try {
        
       BufferedImage img = getPlane(tileX, tileY,(analysis||channelContributions!=null)?channelContributions:this.channelContributions, analysis, analysisHues);
       // ensure tiles have always full tileWidth and tileHeight (even at borders)
       if (img.getWidth()!=getTileWidth() || img.getHeight()!=getTileHeight())
       {
           BufferedImage bi = new BufferedImage(getTileWidth(), getTileHeight(), img.getType());
           bi.getGraphics().drawImage(img, 0, 0, null);
           img = bi;
       }

      // set correct bounds
      Raster r = img.getData().createTranslatedChild(PlanarImage.tileXToX(tileX, img.getTileGridXOffset(), getTileWidth()), PlanarImage.tileYToY(tileY, img.getTileGridYOffset(), getTileHeight()));
      return r;

    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
 
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:23,代码来源:OrbitImageBioformats.java

示例10: getTileData

import javax.media.jai.PlanarImage; //导入依赖的package包/类
/**
 * Analysis and analysisHueMap is ignored here - works only for 8bit BF images
 */
@Override
public Raster getTileData(int tileX, int tileY, boolean analysis) {
    try {
        byte[] buf = buffer.get();
        byte[] data = tp.get().getTile(ifd,buf,tileY,tileX);
        BufferedImage image =getBufferedImage(data,tileWidth,tileHeight);

        // ensure tiles have always full tileWifth and tileHeight (even at borders)
        if (image.getWidth()!=getTileWidth() || image.getHeight()!=getTileHeight())
        {
            BufferedImage bi = new BufferedImage(getTileWidth(), getTileHeight(), BufferedImage.TYPE_INT_RGB);   // must be RGB
            bi.getGraphics().drawImage(image, 0, 0, null);
            image = bi;
        }

        Raster r = image.getData().createTranslatedChild(PlanarImage.tileXToX(tileX, image.getTileGridXOffset(), tileWidth), PlanarImage.tileYToY(tileY, image.getTileGridYOffset(), tileHeight));
        return r;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
 
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:26,代码来源:OrbitImageTiff.java

示例11: cellFeaturesBasic

import javax.media.jai.PlanarImage; //导入依赖的package包/类
@Test
public void cellFeaturesBasic() {
    BufferedImage bi = new BufferedImage(20, 20, BufferedImage.TYPE_INT_RGB);
    Color c1 = new Color(1, 2, 3);
    Color c2 = new Color(4, 8, 16);
    bi.setRGB(10, 10, c2.getRGB());
    bi.setRGB(8, 8, c1.getRGB());
    bi.setRGB(12, 12, c1.getRGB());

    TiledImagePainter tip = new TiledImagePainter(PlanarImage.wrapRenderedImage(bi), "test");
    RecognitionFrame rf = new RecognitionFrame(tip);
    Shape shape = new RectangleExt(9, 9, 3, 3);

    ObjectFeatureBuilderTiled cellFeatureBuilder = new ObjectFeatureBuilderTiled(null);
    double[] feats = cellFeatureBuilder.buildFeatures(shape, 1, rf, null, 3, 0, 0);
    assertEquals(4d, feats[1], delta);
    assertEquals(8d, feats[5], delta);
    assertEquals(16d, feats[9], delta);
    assertEquals(1d, feats[23], delta); // class

    System.out.println(Arrays.toString(feats));


}
 
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:25,代码来源:TestCellFeaturesBasic.java

示例12: computeEdgeDensityClutter

import javax.media.jai.PlanarImage; //导入依赖的package包/类
private double computeEdgeDensityClutter(PlanarImage image) {
  // first compute the RenderedOp that computes both vertical and
  // horizontal
  // edge detection
  KernelJAI sobelVertKernel = KernelJAI.GRADIENT_MASK_SOBEL_VERTICAL;
  KernelJAI sobelHorizKernel = KernelJAI.GRADIENT_MASK_SOBEL_HORIZONTAL;
  ParameterBlock pb = new ParameterBlock();
  pb.addSource(image);
  pb.add(sobelHorizKernel);
  pb.add(sobelVertKernel);
  RenderedOp renderedOp = JAI.create("gradientmagnitude", pb);
  BufferedImage edgeImage = renderedOp.getAsBufferedImage();

  // then compute a density value, i.e. the mean
  int edgeTotal = 0;
  for (int i = 0; i < edgeImage.getWidth(); i++)
    for (int j = 0; j < edgeImage.getHeight(); j++)
      edgeTotal += Math.abs(edgeImage.getRGB(i, j));

  return Math.abs(edgeTotal / (edgeImage.getWidth() * edgeImage.getHeight()));
}
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:22,代码来源:RasterClutterMethod.java

示例13: getTileData

import javax.media.jai.PlanarImage; //导入依赖的package包/类
@Override
public Raster getTileData(int tileX, int tileY, float[] channelContributions, boolean analysis, final float[] analysisHues) {
    try {
       BufferedImage img = getPlane(tileX, tileY, (analysis||channelContributions!=null)?channelContributions:this.channelContributions, analysis, analysisHues);
       // ensure tiles have always full tileWidth and tileHeight (even at borders)
       if (img.getWidth()!=getTileWidth() || img.getHeight()!=getTileHeight())
       {
           BufferedImage bi = new BufferedImage(getTileWidth(), getTileHeight(), img.getType());
           bi.getGraphics().drawImage(img, 0, 0, null);
           img = bi;
       }

      // set correct bounds
      Raster r = img.getData().createTranslatedChild(PlanarImage.tileXToX(tileX, img.getTileGridXOffset(), getTileWidth()), PlanarImage.tileYToY(tileY, img.getTileGridYOffset(), getTileHeight()));
      return r;

    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
 
开发者ID:mstritt,项目名称:image-provider-omero,代码行数:22,代码来源:OrbitImageBioformatsOmero.java

示例14: computeRectangles

import javax.media.jai.PlanarImage; //导入依赖的package包/类
private List<Rectangle> computeRectangles(List<PlanarImage> images) {
    List<Rectangle> reg = new ArrayList<>();
    Set<Integer> xSet= new TreeSet<>();
    Set<Integer> ySet = new TreeSet<>();
    for(PlanarImage image: images){
        xSet.add(image.getMinX());
        xSet.add(image.getMinX() + image.getWidth());
        ySet.add(image.getMinY());
        ySet.add(image.getMinY() + image.getHeight());
    }
    Integer[] xArray = xSet.toArray(new Integer[xSet.size()]);
    Integer[] yArray = ySet.toArray(new Integer[ySet.size()]);
    for(int x = 0; x < xArray.length - 1; x++){
        for(int y = 0; y < yArray.length - 1; y++ ){
            reg.add(new Rectangle(xArray[x],yArray[y], xArray[x+1]-xArray[x], yArray[y+1]-yArray[y]));
        }
    }
    return reg;
}
 
开发者ID:senbox-org,项目名称:s2tbx,代码行数:20,代码来源:S2MosaicMultiLevelSource.java

示例15: setup

import javax.media.jai.PlanarImage; //导入依赖的package包/类
@Before
public void setup() {

    sourceImages1 = new RenderedImage[]{
            ConstantDescriptor.create(10.0f, 10.0f, new Float[]{2.0f}, null),
            ConstantDescriptor.create(10.0f, 10.0f, new Float[]{3.0f}, null),
            ConstantDescriptor.create(10.0f, 10.0f, new Float[]{5.0f}, null),
            ConstantDescriptor.create(10.0f, 10.0f, new Float[]{7.0f}, null)
    };
    sourceImages2 = new RenderedImage[]{
            ConstantDescriptor.create(10.0f, 10.0f, new Float[]{7.0f}, null),
            ConstantDescriptor.create(10.0f, 10.0f, new Float[]{5.0f}, null),
            ConstantDescriptor.create(10.0f, 10.0f, new Float[]{3.0f}, null),
            ConstantDescriptor.create(10.0f, 10.0f, new Float[]{2.0f}, null)
    };

    alphaImages = new PlanarImage[]{
            PlanarImage.wrapRenderedImage(ConstantDescriptor.create(10.0f, 10.0f, new Float[]{1.0f}, null)),
            PlanarImage.wrapRenderedImage(ConstantDescriptor.create(10.0f, 10.0f, new Float[]{2.0f}, null)),
            PlanarImage.wrapRenderedImage(ConstantDescriptor.create(10.0f, 10.0f, new Float[]{3.0f}, null)),
            PlanarImage.wrapRenderedImage(ConstantDescriptor.create(10.0f, 10.0f, new Float[]{4.0f}, null))
    };


}
 
开发者ID:senbox-org,项目名称:s2tbx,代码行数:26,代码来源:S2tbxMosaicOpImageTest.java


注:本文中的javax.media.jai.PlanarImage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。