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


Java TiledImage类代码示例

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


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

示例1: TiledImageWriter

import javax.media.jai.TiledImage; //导入依赖的package包/类
public TiledImageWriter(BufferedImage inputImage) {
        this.width = inputImage.getWidth();
        this.height = inputImage.getHeight();
        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 DiskMemImage(0,0,width,height,0,0,sampleModel,colorModel);
        //image = new TiledImage(0,0,width,height,0,0,sampleModel,colorModel);
        BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
        //Graphics2D g2d = image.createGraphics();
        Graphics2D g2d = bi.createGraphics();
        // try {
        // 03.05.2010 Manuel: DiskMemImage (exception with JRE 1.5, with JRE 1.6 fine)
        // 13.02.2012 Manuel: Therefore use bufferedImage / tiledImage for small inputImages (bufferedImage) which also works with java 1.5
        g2d.drawImage(inputImage, 0, 0, null);
//		 } catch (Throwable e) {
//			 System.out.println("TiledImageWriter Error",e);
//			 e.printStackTrace();
//		 }
        image = new TiledImage(bi, false);
        bi = null;
    }
 
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:26,代码来源:TiledImageWriter.java

示例2: actionPerformed

import javax.media.jai.TiledImage; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
  // get the map as an image
  GeOxygeneApplication application = CartAGenPlugin.getInstance()
      .getApplication();
  LayerViewPanel panel = application.getMainFrame()
      .getSelectedProjectFrame().getLayerViewPanel();
  Color bg = panel.getBackground();
  BufferedImage image = new BufferedImage(panel.getWidth(),
      panel.getHeight(), BufferedImage.TYPE_INT_ARGB);
  Graphics2D graphics = image.createGraphics();
  graphics.setColor(bg);
  graphics.fillRect(0, 0, panel.getWidth(), panel.getHeight());
  ((MultithreadedRenderingManager) panel.getRenderingManager())
      .copyTo(graphics);
  panel.paintOverlays(graphics);
  graphics.dispose();

  TiledImage pImage = new TiledImage(image, true);
  RasterClutterMethod clutterMethod = new RasterClutterMethod(pImage);
  System.out.println(clutterMethod.getEdgeDensityClutter());
}
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:23,代码来源:CartoPlugin.java

示例3: getGridEdgeDensityClutter

import javax.media.jai.TiledImage; //导入依赖的package包/类
/**
 * Compute the edge density clutter in a grid version of the image, where the
 * number of columns of the grid is given (the size of the cells is computed
 * according to the image size).
 * 
 * @param nbColumns
 * @return
 */
public Map<Integer, Map<Integer, Double>> getGridEdgeDensityClutter(
    int nbColumns) {
  // first compute the number of pixels in a grid cell
  int cellSize = image.getWidth() / nbColumns;
  int nbRows = Math.round(image.getHeight() / cellSize);
  Map<Integer, Map<Integer, Double>> clutters = new HashMap<Integer, Map<Integer, Double>>();
  int y = 0;
  for (int i = 0; i < nbRows; i++) {
    int x = 0;
    Map<Integer, Double> columns = new HashMap<Integer, Double>();
    for (int j = 0; j < nbColumns; j++) {
      // compute the sub-image in the i,j cell
      TiledImage subImage = image.getSubImage(x, y, cellSize, cellSize);
      columns.put(j, computeEdgeDensityClutter(subImage));
      x += cellSize;
    }
    clutters.put(i, columns);
    y += cellSize;
  }

  return clutters;
}
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:31,代码来源:RasterClutterMethod.java

示例4: ceateImageContent

import javax.media.jai.TiledImage; //导入依赖的package包/类
private TiledImage ceateImageContent(float[] data, int columns, int rows) {
  SampleModel sm = new ComponentSampleModel(DataBuffer.TYPE_DOUBLE,
      TILE_SIZE, TILE_SIZE, 1, TILE_SIZE, new int[]{0});

  ColorModel cm = TiledImage.createColorModel(sm);

  TiledImage img = new TiledImage(0, 0, columns, rows, 0, 0, sm, cm);

  int i = 0;
  int halfColumns = (int) ((double) columns / 2.0);
  for (int y = 0; y < rows; y++) {
    for (int x = 0; x < columns; x++) {
      if (x >= halfColumns) {
        img.setSample(x - halfColumns, y, 0, data[i]);
      } else {
        img.setSample(x + halfColumns, y, 0, data[i]);
      }
      i++;
    }
  }
  return img;
}
 
开发者ID:MeteoGroup,项目名称:grib2geotiff,代码行数:23,代码来源:GeoTiffExporter.java

示例5: jiffleProcessExecution

import javax.media.jai.TiledImage; //导入依赖的package包/类
/**
 * Private method used for executing the script operation on an input image with the selected GridGeometry2D.
 * 
 * @param input RenderedImage to process
 * @param jb jiffleBuilder object with the script to execute
 * @param destGridGeometry GridGeometry object associated to the output image
 * @return img output image generated from the script
 * @throws JiffleException
 */
private RenderedImage jiffleProcessExecution(RenderedImage input, JiffleBuilder jb,
        GridGeometry2D destGridGeometry) throws JiffleException {

    // Setting of the source
    jb.source("image", input, null, false);

    // Now we specify the tile dimensions of the final image
    int tileWidth = input.getTileWidth();
    int tileHeight = input.getTileHeight();
    // Creation of a SampleModel associated with the final image
    SampleModel sm = RasterFactory.createPixelInterleavedSampleModel(DataBuffer.TYPE_DOUBLE,
            tileWidth, tileHeight, 1);
    // Selection of the GridEnvelope associated to the input coverage
    final GridEnvelope2D gr2d = destGridGeometry.getGridRange2D();
    // Final image creation
    final WritableRenderedImage img = new TiledImage(gr2d.x, gr2d.y, gr2d.width, gr2d.height,
            0, 0, sm, PlanarImage.createColorModel(sm));
    // Setting of the final image
    jb.dest("dest", img);

    // Finally we run the script and retrieve the resulting image.
    jb.run();

    return img;
}
 
开发者ID:geosolutions-it,项目名称:soil_sealing,代码行数:35,代码来源:JiffleScriptListProcess.java

示例6: setPixel

import javax.media.jai.TiledImage; //导入依赖的package包/类
public void setPixel(int x, int y, int[] RGBA) {
    int tx = TiledImage.XToTileX(x, 0, tileWidth);
    int ty = TiledImage.YToTileY(y, 0, tileHeight);
    WritableRaster writeRaster = getImage().getWritableTile(tx, ty);
    if (writeRaster != null) {
        writeRaster.setPixel(x, y, RGBA);
    }
    getImage().releaseWritableTile(tx, ty);
}
 
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:10,代码来源:TiledImageWriter.java

示例7: generateTestImage

import javax.media.jai.TiledImage; //导入依赖的package包/类
public TiledImage generateTestImage(int width, int height) {
    DiskMemImageOrbit.getCommonTileCache().setMemoryCapacity(OrbitUtils.DISK_IMAGE_CACHE);
    JAI.getDefaultInstance().getTileCache().setMemoryCapacity(OrbitUtils.PLANAR_IMAGE_CACHE);
    int xOffs = 0;
    int yOffs = 0;
    ColorModel colorModel = new ComponentColorModel(
            ColorSpace.getInstance(ColorSpace.CS_sRGB),
            new int[]{8, 8, 8, 8}, true, false,
            Transparency.TRANSLUCENT,
            DataBuffer.TYPE_BYTE);
    SampleModel sampleModel = colorModel.createCompatibleSampleModel(tileWidth, tileHeight);
    DiskMemImageOrbit image = new DiskMemImageOrbit(xOffs, yOffs, width, height, 0, 0, sampleModel, colorModel);
    image.setUseCommonCache(true);
    int tiMaxX = image.XToTileX(width - 1);
    int tiMaxY = image.YToTileY(height - 1);

    int x;
    int y;
    int g = 0;
    for (int tx = 0; tx < tiMaxX; tx++) {
        for (int ty = 0; ty < tiMaxY; ty++) {
            WritableRaster tile = image.getWritableTile(tx, ty);
            for (int rx = tile.getMinX(); rx < tile.getMinX() + tile.getWidth(); rx++) {
                for (int ry = tile.getMinY(); ry < tile.getMinY() + tile.getHeight(); ry++) {
                    x = rx;
                    y = ry;
                    tile.setSample(x, y, 0, (int) ((x / (float) width) * 255f) - g);
                    tile.setSample(x, y, 1, g);
                    tile.setSample(x, y, 2, (int) ((y / (float) height) * 255));
                    tile.setSample(x, y, 3, 255);

                }
            }
            image.releaseWritableTile(tx, ty);
        }
    }

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

示例8: saveToDisk

import javax.media.jai.TiledImage; //导入依赖的package包/类
public void saveToDisk(TiledImage ti, String fn) throws IOException {
    BufferedImage buffImg = new BufferedImage(ti.getWidth(), ti.getHeight(), BufferedImage.TYPE_INT_RGB);
    Graphics g2d = buffImg.getGraphics();
    g2d.drawImage(ti.getAsBufferedImage(), 0, 0, null);
    buffImg.flush();

    JPEGEncodeParam jpgParam = new JPEGEncodeParam();
    jpgParam.setQuality(0.85f);
    JAI.create("filestore", buffImg, fn, "JPEG", jpgParam);
}
 
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:11,代码来源:ClassImageRenderer.java

示例9: createCoverage

import javax.media.jai.TiledImage; //导入依赖的package包/类
/**
 * Creates the
 *
 * @param data
 * @return
 */
public GridCoverage2D createCoverage(float[] data, int columns, int rows) {
  GridCoverageFactory gcf = CoverageFactoryFinder.getGridCoverageFactory(null);
  TiledImage img = ceateImageContent(data, columns, rows);
  ReferencedEnvelope env = createEnvelope();
  return gcf.create("coverage", img, env);
}
 
开发者ID:MeteoGroup,项目名称:grib2geotiff,代码行数:13,代码来源:GeoTiffExporter.java

示例10: createRendering

import javax.media.jai.TiledImage; //导入依赖的package包/类
/** */
static RenderedImage createRendering (RenderedOp op, ColorModel cm) {
    WritableRaster wr = op.copyData();
    TiledImage ti = new TiledImage(wr.getMinX(), wr.getMinY(), 
                                   wr.getWidth(), wr.getHeight(), 
                                   0, 0,
                                   cm.createCompatibleSampleModel(wr.getWidth(), wr.getHeight()),
                                   cm);
    ti.setData(wr);
    return ti;
}
 
开发者ID:reuven,项目名称:modelingcommons,代码行数:12,代码来源:RasterDataset.java

示例11: setImage

import javax.media.jai.TiledImage; //导入依赖的package包/类
public void setImage(TiledImage image) {
    this.image = image;
}
 
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:4,代码来源:TiledImageWriter.java

示例12: getImage

import javax.media.jai.TiledImage; //导入依赖的package包/类
public TiledImage getImage() {
    return image;
}
 
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:4,代码来源:TiledImageWriter.java

示例13: downsample

import javax.media.jai.TiledImage; //导入依赖的package包/类
/**
     * Downsamples classImage to specified size. If pixel value is black (0,0,0) it uses the pixel value of altImage instead if altImage is not null and white (255,255,255) otherwise.
     *
     * @param classImage
     * @param altImage
     * @param width
     * @param height
     * @return
     */
    public BufferedImage downsample(TiledImage classImage, OrbitTiledImage2 altImage, int width, int height) {
//		if (altImage!=null && (altImage.getWidth()!=classImage.getWidth() || altImage.getHeight()!=classImage.getHeight())) {
//			throw new IllegalArgumentException("Classification image and alternative image have different dimensions");
//		}
        double scaleX = classImage.getWidth() / (double) width;
        double scaleY = classImage.getHeight() / (double) height;
        double scaleXAlt = altImage.getWidth() / (double) width;
        double scaleYAlt = altImage.getHeight() / (double) height;

        BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        WritableRaster r = bi.getRaster();
        int ix;
        int iy;
        int tileX;
        int tileY;
        Raster t;
        int ixAlt;
        int iyAlt;
        int tileXAlt;
        int tileYAlt;
        Raster tAlt;
        int c0;
        int c1;
        int c2;
        for (int y = 0; y < height; y++) {
            for (int x = 0; x < width; x++) {
                ix = (int) (x * scaleX);
                iy = (int) (y * scaleY);
                tileX = classImage.XToTileX(ix);
                tileY = classImage.YToTileY(iy);
                t = classImage.getTile(tileX, tileY);
                c0 = t.getSample(ix, iy, 0);
                c1 = t.getSample(ix, iy, 1);
                c2 = t.getSample(ix, iy, 2);
                if (c0 == 0 && c1 == 0 && c2 == 0) {    // not yet assigned, so use altImage or white (instead of black) for better printing
                    if (altImage != null) {
                        ixAlt = (int) (x * scaleXAlt);
                        iyAlt = (int) (y * scaleYAlt);
                        tileXAlt = altImage.XToTileX(ixAlt);
                        tileYAlt = altImage.YToTileY(iyAlt);
                        tAlt = altImage.getTile(tileXAlt, tileYAlt);
                        c0 = tAlt.getSample(ixAlt, iyAlt, 0);
                        c1 = tAlt.getSample(ixAlt, iyAlt, 1);
                        c2 = tAlt.getSample(ixAlt, iyAlt, 2);
                    } else {
                        c0 = 255;
                        c1 = 255;
                        c2 = 255;
                    }
                }
                r.setSample(x, y, 0, c0);
                r.setSample(x, y, 1, c1);
                r.setSample(x, y, 2, c2);
            }
        }
        return bi;
    }
 
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:67,代码来源:ClassImageRenderer.java

示例14: main

import javax.media.jai.TiledImage; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
    ClassImageRenderer renderer = new ClassImageRenderer();
    TiledImage ti = renderer.generateTestImage(width, height);
    BufferedImage bi = renderer.downsample(ti, null, 800, 600);
    renderer.saveToDisk(bi, "d:/test.jpg");
}
 
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:7,代码来源:ClassImageRenderer.java

示例15: saveClassImage

import javax.media.jai.TiledImage; //导入依赖的package包/类
private void saveClassImage() {
    final int width = 3000;
    final ImageFrame iFrame = getIFrame();
    if (iFrame != null) {
        if (iFrame.getRecognitionFrame().getClassImage() != null) {
            final TiledImage classImg = iFrame.getRecognitionFrame().getClassImage().getImage();
            OrbitTiledImage2 mainImgTmp = iFrame.getRecognitionFrame().bimg.getImage();
            if (iFrame.getRecognitionFrame().bimg.hasMipMaps()) {
                for (TiledImagePainter tip : iFrame.getRecognitionFrame().bimg.getMipMaps()) {
                    if (tip.getWidth() > width)
                        mainImgTmp = tip.getImage();
                }
            }
            final OrbitTiledImage2 mainImg = mainImgTmp;
            if (classImg != null) {
                final JFileChooser fc = new JFileChooser();
                FileNameExtensionFilter filter = new FileNameExtensionFilter("*.jpg", "jpg");
                fc.setFileFilter(filter);
                fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
                fc.setDialogType(JFileChooser.SAVE_DIALOG);
                fc.setDialogTitle("Save Classification Image as...");
                String dir = prefs.get("OrbitImageAnalysis.SaveClassificationImageDir", null);
                if (dir != null) {
                    File cd = new File(dir);
                    fc.setCurrentDirectory(cd);
                }
                iFrame.recognitionFrame.setCursor(new Cursor(Cursor.WAIT_CURSOR));
                int returnVal = fc.showSaveDialog(OrbitImageAnalysis.this);
                if (returnVal == JFileChooser.APPROVE_OPTION) {
                    prefs.put("OrbitImageAnalysis.SaveClassificationImageDir", fc.getCurrentDirectory().getAbsolutePath());
                    SwingUtilities.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            try {
                                ClassImageRenderer renderer = new ClassImageRenderer();
                                int height = (int) (classImg.getHeight() * (width / (double) classImg.getWidth()));
                                BufferedImage bi = renderer.downsample(classImg, mainImg, width, height);
                                String fn = fc.getSelectedFile().getAbsolutePath();
                                renderer.saveToDisk(bi, fn);
                                JOptionPane.showMessageDialog(OrbitImageAnalysis.this, "Classification image successfully saved as\n" + fn + ".", "Classification image saved", JOptionPane.INFORMATION_MESSAGE);
                            } catch (IOException e1) {
                                e1.printStackTrace();
                                logger.error("error saving classificaiton image ", e1);
                            } finally {
                                iFrame.recognitionFrame.setCursor(new Cursor((Cursor.DEFAULT_CURSOR)));
                            }
                        }
                    });
                }
            }
        } else
            JOptionPane.showMessageDialog(OrbitImageAnalysis.this, "No classification available. Please classify an image first.", "Cannot save classification image", JOptionPane.ERROR_MESSAGE);
    } else
        JOptionPane.showMessageDialog(OrbitImageAnalysis.this, "No image available. Please open and classify an image first.", "Cannot save classification image", JOptionPane.ERROR_MESSAGE);
}
 
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:56,代码来源:OrbitImageAnalysis.java


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