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


Java PlanarImage.getAsBufferedImage方法代码示例

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


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

示例1: executeTransformOperation

import javax.media.jai.PlanarImage; //导入方法依赖的package包/类
/**
 * Performs the image rotation when being handled as a TransformOperation.
 * @param image The image to perform the transformation on.
 * @return the transformed image.
 */
@Override
public PlanarImage executeTransformOperation(PlanarImage image) {
    for (ImageOperation instr : instructions) {
        if (instr instanceof DrawOperation) {
            // If this TransformOperation has DrawOperation children
            // then Rotate the first child and return.
            System.out.println("Exec'ing Draws");
            PlanarImage op = ((DrawOperation) instr).executeDrawOperation();
            return performRotate(op);
        }
        if (instr instanceof TransformOperation) {
            BufferedImage bi = image.getAsBufferedImage();
            System.out.println("Exec'ing Transforms");
            image = ((TransformOperation) instr)
                .executeTransformOperation(PlanarImage.wrapRenderedImage(bi));
        }
    }
    System.out.println("Exec'ing as TransformOperation");
    image = performRotate(image);
    System.out.println(image);
    return image;
}
 
开发者ID:apache,项目名称:ant,代码行数:28,代码来源:Rotate.java

示例2: doInBackground

import javax.media.jai.PlanarImage; //导入方法依赖的package包/类
@Override
protected Image doInBackground() throws Exception {
    RenderedImage sourceImage = FileLoadDescriptor.create(imageFilePath, null, true, null);
    int width = sourceImage.getWidth();
    int height = sourceImage.getHeight();

    float scale = (float) (targetDimension.getWidth() / width);
    scale = (float) Math.min(scale, targetDimension.getHeight() / height);
    if (scale > 1) {
        scale = 1.0f;
    }

    Interpolation interpolation = Interpolation.getInstance(Interpolation.INTERP_NEAREST);
    RenderedImage scaledImage = ScaleDescriptor.create(sourceImage,
                                                       scale, scale,
                                                       0.0f, 0.0f,
                                                       interpolation, null);
    PlanarImage planarImage = PlanarImage.wrapRenderedImage(scaledImage);
    BufferedImage bufferedImage = planarImage.getAsBufferedImage();
    planarImage.dispose();
    return bufferedImage;
}
 
开发者ID:senbox-org,项目名称:snap-desktop,代码行数:23,代码来源:ImageFileAssistantPage1.java

示例3: run

import javax.media.jai.PlanarImage; //导入方法依赖的package包/类
public void run() {
    try {
        ClassShape classShape = annotation.getShape();
        if (classShape != null && classShape.getShapeList() != null) {
            if (classShape.getShapeList() != null && classShape.getShapeList().size() > 0) {
                IScaleableShape p = (IScaleableShape) classShape.getShapeList().get(0); // only the first shape
                ImageFrame iFrame = OrbitImageAnalysis.getInstance().getIFrame();
                if (iFrame != null) {
                    final long maxW = 2000;
                    Rectangle rect = p.getScaledInstance(100d, new Point(0, 0)).getBounds();
                    extendBB(rect, bbExtend);
                    PlanarImage img = iFrame.recognitionFrame.bimg.getImage();
                    if ((long) rect.getWidth() * rect.getHeight() > (maxW * maxW)) {
                        if (iFrame.recognitionFrame.bimg.getMipMaps() != null && iFrame.recognitionFrame.bimg.getMipMaps().length > 0) {
                            img = iFrame.recognitionFrame.bimg.getMipMaps()[iFrame.recognitionFrame.bimg.getMipMaps().length - 1].getImage();
                            double scale = (double) img.getWidth() / (double) iFrame.recognitionFrame.bimg.getImage().getWidth();
                            rect = p.getScaledInstance(scale * 100d, new Point(0, 0)).getBounds();
                        }
                    }
                    BufferedImage bi = img.getAsBufferedImage(rect, iFrame.recognitionFrame.bimg.getImage().getColorModel());
                    bi = TiffConverter.makeScaledImage(bi, thumbnailWidth, thumbnailHeight);
                    ImageIcon icon = new ImageIcon(bi);
                    if ((cellCache != null) && (icon != null)) {
                        cellCache.put(hash, icon);
                        list.revalidate();
                        list.repaint();
                    }
                }
            }
        }

    } catch (Throwable t) {
        // can happen (e.g, outofmemory), but no problem
    }

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

示例4: findCirclesUEP

import javax.media.jai.PlanarImage; //导入方法依赖的package包/类
private TMAPointsResult findCirclesUEP(PlanarImage image) {
    ImagePlus ip = new ImagePlus("TMAPoints", image.getAsBufferedImage());

    // blur: this fills small 'holes'
    GaussianBlur blur = new GaussianBlur();
    blur.blur(ip.getProcessor(), 2d);

    // Make Binary
    thresholder.applyThreshold(ip);

    // fill holes
    binary.setup("fill", null);
    binary.run(ip.getProcessor());

    // open
    binary.setup("open", null);
    binary.run(ip.getProcessor());

    // UEP
    edm.setup("points", null); // "points" for Ultimate points
    edm.run(ip.getProcessor());

    PlanarImage img = PlanarImage.wrapRenderedImage(ip.getBufferedImage());
    List<Point> pList = reportPoints(img, 1);
    double radius = guessRadius(pList);
    return new TMAPointsResult(pList, radius, ip.getBufferedImage());
}
 
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:28,代码来源:TMAPoints.java

示例5: run

import javax.media.jai.PlanarImage; //导入方法依赖的package包/类
public void run() {
    try {
        ClassShape classShape = annotation.getShape();
        if (classShape != null && classShape.getShapeList() != null) {
            if (classShape.getShapeList() != null && classShape.getShapeList().size() > 0) {
                IScaleableShape p = (IScaleableShape) classShape.getShapeList().get(0); // only the first shape

                ImageFrame iFrame = OrbitImageAnalysis.getInstance().getIFrame();
                if (iFrame != null) {
                    final long maxW = 2000;
                    Rectangle rect = p.getScaledInstance(100d, new Point(0, 0)).getBounds();
                    PlanarImage img = iFrame.recognitionFrame.bimg.getImage();
                    if ((long) rect.getWidth() * rect.getHeight() > (maxW * maxW)) {
                        if (iFrame.recognitionFrame.bimg.getMipMaps() != null && iFrame.recognitionFrame.bimg.getMipMaps().length > 0) {
                            img = iFrame.recognitionFrame.bimg.getMipMaps()[iFrame.recognitionFrame.bimg.getMipMaps().length - 1].getImage();
                            double scale = (double) img.getWidth() / (double) iFrame.recognitionFrame.bimg.getImage().getWidth();
                            rect = p.getScaledInstance(scale * 100d, new Point(0, 0)).getBounds();
                        }
                    }
                    BufferedImage bi = img.getAsBufferedImage(rect, iFrame.recognitionFrame.bimg.getImage().getColorModel());
                    bi = TiffConverter.makeScaledImage(bi, thumbnailWidth, thumbnailHeight);
                    ImageIcon icon = new ImageIcon(bi);
                    if ((cellCache != null) && (icon != null)) {
                        cellCache.put(hash, icon);
                        list.revalidate();
                        list.repaint();
                    }
                }
            }
        }

    } catch (Throwable t) {
        // can happen (e.g, outofmemory), but no problem
    }

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

示例6: executeDrawOperation

import javax.media.jai.PlanarImage; //导入方法依赖的package包/类
/** {@inheritDoc}. */
@Override
public PlanarImage executeDrawOperation() {
    BufferedImage bi = new BufferedImage(width + (stroke_width * 2),
        height + (stroke_width * 2), BufferedImage.TYPE_4BYTE_ABGR_PRE);

    Graphics2D graphics = bi.createGraphics();

    if (!"transparent".equalsIgnoreCase(stroke)) {
        BasicStroke bStroke = new BasicStroke(stroke_width);
        graphics.setColor(ColorMapper.getColorByName(stroke));
        graphics.setStroke(bStroke);
        graphics.draw(new Arc2D.Double(stroke_width, stroke_width, width,
            height, start, stop, type));
    }

    if (!"transparent".equalsIgnoreCase(fill)) {
        graphics.setColor(ColorMapper.getColorByName(fill));
        graphics.fill(new Arc2D.Double(stroke_width, stroke_width,
            width, height, start, stop, type));
    }

    for (ImageOperation instr : instructions) {
        if (instr instanceof DrawOperation) {
            PlanarImage img = ((DrawOperation) instr).executeDrawOperation();
            graphics.drawImage(img.getAsBufferedImage(), null, 0, 0);
        } else if (instr instanceof TransformOperation) {
            PlanarImage image = ((TransformOperation) instr)
                .executeTransformOperation(PlanarImage.wrapRenderedImage(bi));
            bi = image.getAsBufferedImage();
            graphics = bi.createGraphics();
        }
    }
    return PlanarImage.wrapRenderedImage(bi);
}
 
开发者ID:apache,项目名称:ant,代码行数:36,代码来源:Arc.java

示例7: executeTransformOperation

import javax.media.jai.PlanarImage; //导入方法依赖的package包/类
/** {@inheritDoc}. */
@Override
public PlanarImage executeTransformOperation(PlanarImage image) {
    for (ImageOperation instr : instructions) {
        if (instr instanceof DrawOperation) {
            return performScale(image);
        }
        if (instr instanceof TransformOperation) {
            BufferedImage bi = image.getAsBufferedImage();
            image = ((TransformOperation) instr)
                .executeTransformOperation(PlanarImage.wrapRenderedImage(bi));
        }
    }
    return performScale(image);
}
 
开发者ID:apache,项目名称:ant,代码行数:16,代码来源:Scale.java

示例8: executeDrawOperation

import javax.media.jai.PlanarImage; //导入方法依赖的package包/类
/** {@inheritDoc}. */
@Override
public PlanarImage executeDrawOperation() {
    BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR_PRE);

    Graphics2D graphics = bi.createGraphics();

    if (!"transparent".equalsIgnoreCase(stroke)) {
        BasicStroke bStroke = new BasicStroke(stroke_width);
        graphics.setColor(ColorMapper.getColorByName(stroke));
        graphics.setStroke(bStroke);
        graphics.draw(new Ellipse2D.Double(0, 0, width, height));
    }

    if (!"transparent".equalsIgnoreCase(fill)) {
        graphics.setColor(ColorMapper.getColorByName(fill));
        graphics.fill(new Ellipse2D.Double(0, 0, width, height));
    }

    for (ImageOperation instr : instructions) {
        if (instr instanceof DrawOperation) {
            PlanarImage img = ((DrawOperation) instr).executeDrawOperation();
            graphics.drawImage(img.getAsBufferedImage(), null, 0, 0);
        } else if (instr instanceof TransformOperation) {
            PlanarImage image = ((TransformOperation) instr)
                .executeTransformOperation(PlanarImage.wrapRenderedImage(bi));
            bi = image.getAsBufferedImage();
            graphics = bi.createGraphics();
        }
    }
    return PlanarImage.wrapRenderedImage(bi);
}
 
开发者ID:apache,项目名称:ant,代码行数:33,代码来源:Ellipse.java

示例9: process

import javax.media.jai.PlanarImage; //导入方法依赖的package包/类
public SegmentationResult 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)");

        logger.debug("voronoi start");

        // ImageJ implementation
        ImagePlus ip = new ImagePlus("skeleton", image.getAsBufferedImage());

        ThresholderOrbit thresholder = new ThresholderOrbit();
        thresholder.applyThreshold(ip);

        ip.getProcessor().convertToByte(false);

        BinaryProcessor bp = new BinaryProcessor((ByteProcessor) ip.getProcessor());

        EDM edm = new EDM();
        edm.toWatershed(bp);

        edm.setup("voronoi", ip);
        edm.run(bp);

        bp.threshold(0);

        bp.dilate();
        bp.dilate();
//		bp.dilate();
        logger.debug("voronoi end");

        // make recognitionFrame for segmentation
        TiledImagePainter tip = new TiledImagePainter(PlanarImage.wrapRenderedImage(bp.getBufferedImage()), "vronoiImage");
        List<ClassShape> classShapes = new ArrayList<ClassShape>(2);
        classShapes.add(new ClassShape("Background", Color.black, ClassShape.SHAPETYPE_POLYGONEXT));
        classShapes.add(new ClassShape("Foreground", Color.white, ClassShape.SHAPETYPE_POLYGONEXT));

        TiledImageWriter tiw = new TiledImageWriter(PlanarImage.wrapRenderedImage(bp.convertToRGB().getBufferedImage()));

        RecognitionFrame rf = new RecognitionFrame(tip);
        rf.setClassImage(tiw);
        rf.getClassShapes().clear();
        rf.getClassShapes().addAll(classShapes);
        rf.setRatio(new double[rf.getClassShapes().size()]);
        rf.initializeClassColors();

        ObjectSegmentationWorker seg = new ObjectSegmentationWorker(rf, null, classShapes, null);
        seg.setDontClassify(true);
        seg.setDoWatershed(false);
        seg.setNumThreads(1);
        seg.setWithGUI(false);
        seg.run();
        SegmentationResult segRes = seg.getSegmentationResult();
        logger.debug("cytoplasma segmentation count: " + segRes.getObjectCount());
        //return PlanarImage.wrapRenderedImage(bp.getBufferedImage());
        return segRes;
    }
 
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:56,代码来源:CytoplasmaSegmentation.java

示例10: executeDrawOperation

import javax.media.jai.PlanarImage; //导入方法依赖的package包/类
/** {@inheritDoc}. */
@Override
public PlanarImage executeDrawOperation() {
    log("\tCreating Rectangle w=" + width + " h=" + height + " arcw="
        + arcwidth + " arch=" + archeight);
    BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR_PRE);

    Graphics2D graphics = bi.createGraphics();

    if (!"transparent".equalsIgnoreCase(stroke)) {
        BasicStroke bStroke = new BasicStroke(stroke_width);
        graphics.setColor(ColorMapper.getColorByName(stroke));
        graphics.setStroke(bStroke);

        if (arcwidth == 0 && archeight == 0) {
            graphics.drawRect(0, 0, width, height);
        } else {
            graphics.drawRoundRect(0, 0, width, height, arcwidth, archeight);
        }
    }

    if (!"transparent".equalsIgnoreCase(fill)) {
        graphics.setColor(ColorMapper.getColorByName(fill));
        if (arcwidth == 0 && archeight == 0) {
            graphics.fillRect(stroke_width, stroke_width,
                width - (stroke_width * 2), height - (stroke_width * 2));
        } else {
            graphics.fillRoundRect(stroke_width, stroke_width,
                width - (stroke_width * 2), height - (stroke_width * 2),
                arcwidth, archeight);
        }
    }

    for (ImageOperation instr : instructions) {
        if (instr instanceof DrawOperation) {
            PlanarImage img = ((DrawOperation) instr).executeDrawOperation();
            graphics.drawImage(img.getAsBufferedImage(), null, 0, 0);
        } else if (instr instanceof TransformOperation) {
            graphics = (Graphics2D) bi.getGraphics();
            PlanarImage image
                = ((TransformOperation) instr)
                .executeTransformOperation(PlanarImage.wrapRenderedImage(bi));
            bi = image.getAsBufferedImage();
        }
    }
    return PlanarImage.wrapRenderedImage(bi);
}
 
开发者ID:apache,项目名称:ant,代码行数:48,代码来源:Rectangle.java

示例11: convertTiff

import javax.media.jai.PlanarImage; //导入方法依赖的package包/类
private void convertTiff(ByteArrayOutputStream outputStream, ByteArrayInputStream inStream) throws IOException, DocumentException, BadElementException, MalformedURLException 
{
	TIFFDecodeParam param = null;
	ImageDecoder decoder = ImageCodec.createImageDecoder("tiff", inStream, param);	
	System.out.println("Convert TIFF file: Found " + decoder.getNumPages() + " pages");
	
	ArrayList<ByteArrayOutputStream> imagesStream = new ArrayList<ByteArrayOutputStream>();
	
	int pages = decoder.getNumPages();
	for (int i = 0; i < pages; i++) 
	{
		RenderedImage render = decoder.decodeAsRenderedImage(i);
		PlanarImage op = new NullOpImage(render, null, null, OpImage.OP_IO_BOUND);
		BufferedImage imageBuffer = op.getAsBufferedImage();
		
		ByteArrayOutputStream os = new ByteArrayOutputStream();
		ImageIO.write(imageBuffer, "jpg", os);
		
		imagesStream.add(os);
	}
	
	if (imagesStream.size() > 0)
	{						
		Document document = new Document(PageSize.A4.rotate());
		PdfWriter writer = PdfWriter.getInstance(document, outputStream);
		
		document.open();
		
		Iterator<ByteArrayOutputStream> iterator = imagesStream.iterator();
		while (iterator.hasNext()) 
	    {
			document.newPage();
			Image jpg = Image.getInstance(iterator.next().toByteArray());
			jpg.scaleAbsolute(document.getPageSize().getWidth(), document.getPageSize().getHeight());
			document.add(jpg);
			
		}
		
		document.close();
		writer.flush();
		writer.close();
	}
}
 
开发者ID:IMS-MAXIMS,项目名称:openMAXIMS,代码行数:44,代码来源:ConversionHelper.java


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