當前位置: 首頁>>代碼示例>>Java>>正文


Java JAI.create方法代碼示例

本文整理匯總了Java中javax.media.jai.JAI.create方法的典型用法代碼示例。如果您正苦於以下問題:Java JAI.create方法的具體用法?Java JAI.create怎麽用?Java JAI.create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.media.jai.JAI的用法示例。


在下文中一共展示了JAI.create方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: grayToGray256

import javax.media.jai.JAI; //導入方法依賴的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: writeRaster

import javax.media.jai.JAI; //導入方法依賴的package包/類
public void writeRaster(String file){
	if(file == null) return;
	// Encode data into buffered image
	int width = getCols();
	int height = getRows();
	float[] data_ = new float[width * height];
	for(int i = 0; i < data_.length; i++){
		data_[i] = data[i / width][i % width];
	}
	// Using greyscale to store floating point values.
	// Currently JAI doesn't support writing double precision (64-bit) samples to tiffs
	// so we have to settle for standard 32-bit floating point values, which is crap
	// ... so watch this space!
	ImageTypeSpecifier spec = ImageTypeSpecifier.createInterleaved(ColorSpace.getInstance(ColorSpace.CS_GRAY), new int[]{0}, DataBuffer.TYPE_FLOAT, false, false);
	BufferedImage img = spec.createBufferedImage(width, height);
	img.getRaster().setPixels(0, 0, width, height, data_);		
	// Use JAI to write tiff file
	JAI.create("filestore", img, file, "TIFF", null);
}
 
開發者ID:Cride5,項目名稱:jablus,代碼行數:20,代碼來源:MatrixData.java

示例3: graphicFillLineString

import javax.media.jai.JAI; //導入方法依賴的package包/類
private static void graphicFillLineString(final LineSymbolizer symbolizer, final Shape shape, final Image image, final float size, final double opacity) {
    Double width = new Double(Math.max(1, shape.getBounds2D().getWidth()));
    Double height = new Double(Math.max(1, shape.getBounds2D().getHeight()));
    Double shapeHeight = new Double(size);
    double factor = shapeHeight.doubleValue() / image.getHeight(null);
    Double shapeWidth = new Double(image.getWidth(null) * factor);
    AffineTransform transform = AffineTransform.getTranslateInstance(shape.getBounds2D().getMinX(), shape.getBounds2D().getMinY());
    Image scaledImage = image.getScaledInstance(shapeWidth.intValue(), shapeHeight.intValue(), Image.SCALE_FAST);
    BufferedImage buff = new BufferedImage(shapeWidth.intValue(), shapeHeight.intValue(), BufferedImage.TYPE_INT_ARGB);
    buff.getGraphics().drawImage(scaledImage, 0, 0, null);
    ParameterBlock p = new ParameterBlock();
    p.addSource(buff);
    p.add(width.intValue());
    p.add(height.intValue());
    RenderedOp im = JAI.create("pattern", p);//$NON-NLS-1$
    BufferedImage bufferedImage = im.getAsBufferedImage();
    glDrawImage(bufferedImage, transform, null);
    bufferedImage.flush();
    im.dispose();
    scaledImage.flush();
    buff.flush();
}
 
開發者ID:IGNF,項目名稱:geoxygene,代碼行數:23,代碼來源:RenderGL11Util.java

示例4: drawGraphicFillPolygon

import javax.media.jai.JAI; //導入方法依賴的package包/類
private static void drawGraphicFillPolygon(Image image, float size, Graphics2D graphics, double opacity, double widthSymbol, double heightSymbol, double offsetYSymbol, double offsetXSymbol) {
    Double shapeHeight = new Double(size);
    double factor = shapeHeight / image.getHeight(null);
    Double shapeWidth = new Double(Math.max(image.getWidth(null) * factor, 1));
    AffineTransform transform = AffineTransform.getTranslateInstance(offsetXSymbol, offsetYSymbol);
    Image scaledImage = image.getScaledInstance(shapeWidth.intValue(), shapeHeight.intValue(), Image.SCALE_FAST);
    BufferedImage buff = new BufferedImage(shapeWidth.intValue(), shapeHeight.intValue(), BufferedImage.TYPE_INT_ARGB);
    buff.getGraphics().drawImage(scaledImage, 0, 0, null);
    ParameterBlock p = new ParameterBlock();
    p.addSource(buff);
    p.add((int) widthSymbol);
    p.add((int) heightSymbol);
    RenderedOp im = JAI.create("pattern", p);//$NON-NLS-1$
    BufferedImage bufferedImage = im.getAsBufferedImage();
    graphics.drawImage(bufferedImage, transform, null);
    bufferedImage.flush();
    im.dispose();
    scaledImage.flush();
    buff.flush();
}
 
開發者ID:IGNF,項目名稱:geoxygene,代碼行數:21,代碼來源:LayerStylesPanel.java

示例5: computeEdgeDensityClutter

import javax.media.jai.JAI; //導入方法依賴的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

示例6: readRaster

import javax.media.jai.JAI; //導入方法依賴的package包/類
public void readRaster(String file){
		if(file == null || !new File(file).exists()){ 
// For recreating RevenueGrid
loaded = false;
//System.out.println("MatrixData.readRaster: not loaded " + id + ", " + file );
			return;
		}
		loaded = true;
		// Use JAI to read tiff file format
		RenderedImage img = (RenderedImage)JAI.create("fileload", file);
		// Extract data from image
		int width = img.getWidth();
		int height = img.getHeight();
		float[] data_ = new float[width * height];
		data_ = img.getData().getPixels(0, 0, width, height, data_);
		data = new float[height][width];
		for(int i = 0; i < data_.length; i++){
			data[i / width][i % width] = data_[i];
		}
//			System.out.println(Utils.arrayString(data));	
	}
 
開發者ID:Cride5,項目名稱:jablus,代碼行數:22,代碼來源:MatrixData.java

示例7: resizeImage

import javax.media.jai.JAI; //導入方法依賴的package包/類
public static RenderedImage resizeImage(RenderedImage image, int width, int height)
      throws InconsistentImageScale
{
   RenderedImage resizedImage=image;
   // Computes ratio and scale
   float scale=getScale(image.getWidth(),image.getHeight(),width,height);
   
   // Processing resize process
   ParameterBlock pb = new ParameterBlock();
   // The source image
   pb.addSource(resizedImage);
   // The xScale
   pb.add(scale);
   // The yScale
   pb.add(scale);
   // The x translation
   pb.add(0.0F);
   // The y translation
   pb.add(0.0F);
   // The interpolation
   pb.add(Interpolation.getInstance(Interpolation.INTERP_BICUBIC));
   resizedImage = JAI.create("scale", pb, null);
   
   LOGGER.debug("Image resized to : " + resizedImage.getWidth() + "x"
      + resizedImage.getHeight());
   
   return resizedImage;
}
 
開發者ID:SentinelDataHub,項目名稱:dhus-core,代碼行數:29,代碼來源:ProcessingUtils.java

示例8: resizeImageAsJPG

import javax.media.jai.JAI; //導入方法依賴的package包/類
/**
 * This method takes in an image as a byte array (currently supports GIF, JPG, PNG and
 * possibly other formats) and
 * resizes it to have a width no greater than the pMaxWidth parameter in pixels.
 * It converts the image to a standard
 * quality JPG and returns the byte array of that JPG image.
 *
 * @param pImageData
 *                the image data.
 * @param pMaxWidth
 *                the max width in pixels, 0 means do not scale.
 * @return the resized JPG image.
 * @throws IOException
 *                 if the image could not be manipulated correctly.
 */
public byte[] resizeImageAsJPG(byte[] pImageData, int pMaxWidth) throws IOException {
    InputStream imageInputStream = new ByteArrayInputStream(pImageData);
    // read in the original image from an input stream
    SeekableStream seekableImageStream = SeekableStream.wrapInputStream(imageInputStream, true);
    RenderedOp originalImage = JAI.create(JAI_STREAM_ACTION, seekableImageStream);
    ((OpImage) originalImage.getRendering()).setTileCache(null);
    int origImageWidth = originalImage.getWidth();
    // now resize the image
    double scale = 1.0;
    if (pMaxWidth > 0 && origImageWidth > pMaxWidth) {
        scale = (double) pMaxWidth / originalImage.getWidth();
    }
    ParameterBlock paramBlock = new ParameterBlock();
    paramBlock.addSource(originalImage); // The source image
    paramBlock.add(scale); // The xScale
    paramBlock.add(scale); // The yScale
    paramBlock.add(0.0); // The x translation
    paramBlock.add(0.0); // The y translation

    RenderingHints qualityHints = new RenderingHints(RenderingHints.KEY_RENDERING,
            RenderingHints.VALUE_RENDER_QUALITY);

    RenderedOp resizedImage = JAI.create(JAI_SUBSAMPLE_AVERAGE_ACTION, paramBlock, qualityHints);

    // lastly, write the newly-resized image to an output stream, in a specific encoding
    ByteArrayOutputStream encoderOutputStream = new ByteArrayOutputStream();
    JAI.create(JAI_ENCODE_ACTION, resizedImage, encoderOutputStream, JAI_ENCODE_FORMAT_JPEG, null);
    // Export to Byte Array
    byte[] resizedImageByteArray = encoderOutputStream.toByteArray();
    return resizedImageByteArray;
}
 
開發者ID:aysenurbilgin,項目名稱:cww_framework,代碼行數:47,代碼來源:ImageResize.java

示例9: TestWarp

import javax.media.jai.JAI; //導入方法依賴的package包/類
/**
 * Creates a new TestWarp object.
 */
public TestWarp (String path)
{
    srcImage = JAI.create("fileload", new ParameterBlock().add(path), null);
    //        srcImage = PictureLoader.loadImages(new File(path), null)
    //                                .get(1);
    //        srcImage = buildPattern(20, 10, 50, 50);
    dimension = new Dimension(srcImage.getWidth(), srcImage.getHeight());
    setPreferredSize(dimension);

    //        float[]        xCoeffs = new float[] { 0f, 1.25f, 0.04f };
    //        float[]        yCoeffs = new float[] { 0f, -0.02f, 1.5f };
    //        Warp           warp = new WarpAffine(xCoeffs, yCoeffs);
    //
    int xStep = 500;
    int xNumCells = 2;
    int yStep = 500;
    int yNumCells = 1;
    float[] warpPositions = new float[]{
        -100f, 0f, 500f, 100f, 1000f, 0f, // top line
        0f, 500f, 500f, 500f, 1000f, 500f
    }; // bot line
    Warp warp = new WarpGrid(0, xStep, xNumCells, 0, yStep, yNumCells, warpPositions);
    ParameterBlock pb = new ParameterBlock();
    pb.addSource(invert(srcImage));
    pb.add(warp);
    pb.add(new InterpolationBilinear());
    dstImage = invert(JAI.create("warp", pb));
    ((PlanarImage) dstImage).getTiles();
}
 
開發者ID:Audiveris,項目名稱:audiveris,代碼行數:33,代碼來源:TestWarp.java

示例10: invert

import javax.media.jai.JAI; //導入方法依賴的package包/類
private static RenderedImage invert (RenderedImage image)
{
    return JAI.create(
            "Invert",
            new ParameterBlock().addSource(image).add(null).add(null).add(null).add(null).add(null),
            null);
}
 
開發者ID:Audiveris,項目名稱:audiveris,代碼行數:8,代碼來源:TestWarp.java

示例11: colorToGray

import javax.media.jai.JAI; //導入方法依賴的package包/類
private static PlanarImage colorToGray (PlanarImage image)
{
    System.out.println("Converting color image to gray ...");

    double[][] matrix = {
        {0.114d, 0.587d, 0.299d, 0.0d}
    };

    return JAI.create("bandcombine", new ParameterBlock().addSource(image).add(matrix), null);
}
 
開發者ID:Audiveris,項目名稱:audiveris,代碼行數:11,代碼來源:TestImage3.java

示例12: invert

import javax.media.jai.JAI; //導入方法依賴的package包/類
private static PlanarImage invert (PlanarImage image)
{
    return JAI.create(
            "Invert",
            new ParameterBlock().addSource(image).add(null).add(null).add(null).add(null).add(null),
            null);
}
 
開發者ID:Audiveris,項目名稱:audiveris,代碼行數:8,代碼來源:TestImage3.java

示例13: crop

import javax.media.jai.JAI; //導入方法依賴的package包/類
public static RenderedOp crop(
    final RenderedImage renderedImage,
    final float x,
    final float y,
    final float width,
    final float height) {
  final ParameterBlock pb = new ParameterBlock();
  pb.addSource(renderedImage); // The source image
  pb.add(x);
  pb.add(y);
  pb.add(width);
  pb.add(height);
  return JAI.create("Crop", pb); //$NON-NLS-1$
}
 
開發者ID:AndreasWBartels,項目名稱:libraries,代碼行數:15,代碼來源:ImageContainerUtilities.java

示例14: translate

import javax.media.jai.JAI; //導入方法依賴的package包/類
public static RenderedOp translate(final RenderedImage renderedImage, final float x, final float y) {
  final ParameterBlock params = new ParameterBlock();
  params.addSource(renderedImage);
  params.add(x);
  params.add(y);
  return JAI.create("Translate", params); //$NON-NLS-1$
}
 
開發者ID:AndreasWBartels,項目名稱:libraries,代碼行數:8,代碼來源:ImageContainerUtilities.java

示例15: process

import javax.media.jai.JAI; //導入方法依賴的package包/類
public PlanarImage process() {
    if (!parameterSet) throw new IllegalStateException("parameters not set");
    PlanarImage pi = source;
    //   for (int i=0; i<numIter; i++) {
    ParameterBlock pb = new ParameterBlock();
    pb.addSource(pi);
    pb.add(MedianFilterDescriptor.MEDIAN_MASK_SQUARE);
    pb.add(radius);
    pi = JAI.create("MedianFilter", pb);
    //  }
    return pi;

}
 
開發者ID:mstritt,項目名稱:orbit-image-analysis,代碼行數:14,代碼來源:MedianFilter.java


注:本文中的javax.media.jai.JAI.create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。