• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java RasterFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: BandCombineOpImage

import javax.media.jai.RasterFactory; //导入依赖的package包/类
/**
 * Constructor.
 *
 * @param source       The source image.
 * @param layout       The destination image layout.
 * @param matrix       The matrix of values used to perform the
 *                     linear combination.
 */
public BandCombineOpImage(RenderedImage source,
                          Map config,
                          ImageLayout layout,
                          double[][] matrix) {
    super(source, layout, config, true);

    this.matrix = matrix;

    int numBands = matrix.length;  // matrix height is dst numBands
    if (getSampleModel().getNumBands() != numBands) {
        sampleModel = RasterFactory.createComponentSampleModel(sampleModel,
                              sampleModel.getDataType(),
                              tileWidth, tileHeight, numBands);

        if(colorModel != null &&
           !JDKWorkarounds.areCompatibleDataModels(sampleModel,
                                                   colorModel)) {
            colorModel = ImageUtil.getCompatibleColorModel(sampleModel,
                                                           config);
        }
    }
}
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:31,代码来源:BandCombineOpImage.java


示例2: sampleModelHelper

import javax.media.jai.RasterFactory; //导入依赖的package包/类
private static SampleModel sampleModelHelper(int numBands,
                                             ImageLayout layout) {
    SampleModel sampleModel;
    if (layout!= null && layout.isValid(ImageLayout.SAMPLE_MODEL_MASK)) {
        sampleModel = layout.getSampleModel(null);

        if (sampleModel.getNumBands() != numBands) {
            throw new RuntimeException(JaiI18N.getString("ImageFunctionRIF0"));
        }
    } else { // Create a SampleModel.
        // Use a dummy width and height, OpImage will fix them
        sampleModel = RasterFactory.createBandedSampleModel(
                                                      DataBuffer.TYPE_FLOAT,
                                                      1, 1,
                                                      numBands);
    }

    return sampleModel;
}
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:20,代码来源:ImageFunctionOpImage.java


示例3: jiffleProcessExecution

import javax.media.jai.RasterFactory; //导入依赖的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


示例4: createEdgesRaster

import javax.media.jai.RasterFactory; //导入依赖的package包/类
private WritableRaster createEdgesRaster( int width, int height, int[] pixels ) {
    int dataType = DataBuffer.TYPE_DOUBLE;
    ComponentSampleModel sampleModel = new ComponentSampleModel(dataType, width, height, 1,
            width, new int[]{0});

    WritableRaster raster = RasterFactory.createWritableRaster(sampleModel, null);
    int index = 0;
    for( int y = 0; y < height; y++ ) {
        for( int x = 0; x < width; x++ ) {
            double value = (double) pixels[index];
            if (value != -1) {
                value = HMConstants.doubleNovalue;
            } else {
                value = 1.0;
            }
            raster.setSample(x, y, 0, value);
            index++;
        }
    }
    return raster;
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:22,代码来源:Canny.java


示例5: createRasterTypeDouble

import javax.media.jai.RasterFactory; //导入依赖的package包/类
public static WritableRaster createRasterTypeDouble(
		final int numBands,
		final int tileSize ) {
	final WritableRaster raster = RasterFactory.createBandedRaster(
			DataBuffer.TYPE_DOUBLE,
			tileSize,
			tileSize,
			numBands,
			null);
	final double[] defaultValues = new double[tileSize * tileSize * numBands];
	Arrays.fill(
			defaultValues,
			Double.NaN);
	raster.setDataElements(
			0,
			0,
			tileSize,
			tileSize,
			defaultValues);
	return raster;
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:22,代码来源:RasterUtils.java


示例6: computeRect

import javax.media.jai.RasterFactory; //导入依赖的package包/类
@Override
        protected void computeRect(PlanarImage[] sourceImages, WritableRaster tile, Rectangle destRect) {
            final BufferedImage image = new BufferedImage(colorModel,
                    RasterFactory.createWritableRaster(tile.getSampleModel(),
                            tile.getDataBuffer(),
                            new Point(0, 0)), false, null);
            final Graphics2D graphics2D = image.createGraphics();
            graphics2D.translate(-(tile.getMinX() + 0.5), -(tile.getMinY() + 0.5));
            graphics2D.setColor(Color.WHITE);

            FeatureIterator<SimpleFeature> featureIterator = featureCollection.features();
            try {
                AffineTransform transform = AffineTransform.getScaleInstance(1.0 / getScale(), 1.0 / getScale());
//                transform.concatenate(m2iTransform);
                AffineTransform2D transform2D = new AffineTransform2D(transform);

                while (featureIterator.hasNext()) {
                    SimpleFeature feature = featureIterator.next();
                    Object value = feature.getDefaultGeometry();
                    if (value instanceof Geometry) {
                        try {
                            renderGeometry((Geometry) value, graphics2D, transform2D);
                        } catch (Exception ignored) {
                            // ignore
                        }
                    }
                }
            } finally {
                featureIterator.close();
            }

            graphics2D.dispose();

            final byte[] data = ((DataBufferByte) tile.getDataBuffer()).getData();
            for (int i = 0; i < data.length; i++) {
                data[i] = (data[i] != 0) ? TRUE : FALSE;
            }
        }
 
开发者ID:senbox-org,项目名称:s2tbx,代码行数:39,代码来源:PathRasterizer.java


示例7: makeSampleModel

import javax.media.jai.RasterFactory; //导入依赖的package包/类
private static SampleModel makeSampleModel(int width, int height,
                                           Number[] bandValues) {
    int numBands = bandValues.length;
    int dataType;

    if (bandValues instanceof Byte[]) {
        dataType = DataBuffer.TYPE_BYTE;
    } else if (bandValues instanceof Short[]) {
        /* If all band values are positive, use UShort, else use Short. */
        dataType = DataBuffer.TYPE_USHORT;

        Short[] shortValues = (Short[])bandValues;
        for (int i = 0; i < numBands; i++) {
            if (shortValues[i].shortValue() < 0) {
                dataType = DataBuffer.TYPE_SHORT;
                break;
            }
        }
    } else if (bandValues instanceof Integer[]) {
        dataType = DataBuffer.TYPE_INT;
    } else if (bandValues instanceof Float[]) {
        dataType = DataBuffer.TYPE_FLOAT;
    } else if (bandValues instanceof Double[]) {
        dataType = DataBuffer.TYPE_DOUBLE;
    } else {
        dataType = DataBuffer.TYPE_UNDEFINED;
    }

    return RasterFactory.createPixelInterleavedSampleModel(
                         dataType, width, height, numBands);
    
}
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:33,代码来源:ConstantOpImage.java


示例8: layoutHelper

import javax.media.jai.RasterFactory; //导入依赖的package包/类
/**
    * Force the destination image to be single-banded.
    */
   private static ImageLayout layoutHelper(ImageLayout layout,
                                           RenderedImage source) {
       // Create or clone the layout.
       ImageLayout il = layout == null ?
    new ImageLayout() : (ImageLayout)layout.clone();

       // Force the destination and source origins and dimensions to coincide.
       il.setMinX(source.getMinX());
       il.setMinY(source.getMinY());
       il.setWidth(source.getWidth());
       il.setHeight(source.getHeight());

       // Get the SampleModel.
       SampleModel sm = il.getSampleModel(source);

       // Make sure that this OpImage is single-banded.
       if (sm.getNumBands() != 1) {
           sm =
               RasterFactory.createComponentSampleModel(sm,
                                                        sm.getTransferType(),
                                                        sm.getWidth(),
                                                        sm.getHeight(),
                                                        1);
    il.setSampleModel(sm);
       }

       il.setColorModel(null);

return il;
   }
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:34,代码来源:ColorQuantizerOpImage.java


示例9: createDoubleWritableRaster

import javax.media.jai.RasterFactory; //导入依赖的package包/类
private WritableRaster createDoubleWritableRaster( int width, int height, int[] pixels ) {
    int dataType = DataBuffer.TYPE_DOUBLE;
    ComponentSampleModel sampleModel = new ComponentSampleModel(dataType, width, height, 1,
            width, new int[]{0});

    WritableRaster raster = RasterFactory.createWritableRaster(sampleModel, null);
    int index = 0;
    for( int y = 0; y < height; y++ ) {
        for( int x = 0; x < width; x++ ) {
            raster.setSample(x, y, 0, (double) pixels[index]);
            index++;
        }
    }
    return raster;
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:16,代码来源:Canny.java


示例10: createCoverageFromTemplate

import javax.media.jai.RasterFactory; //导入依赖的package包/类
/**
 * Creates a new {@link GridCoverage2D} using an existing as template.
 * 
 * @param template the template to use.
 * @param value the value to set the new raster to, if not <code>null</code>.
 * @param writableRasterHolder an array of length 1 to place the writable raster in, that 
 *                  was can be used to populate the coverage. If <code>null</code>, it is ignored.
 * @return the new coverage.
 */
public static GridCoverage2D createCoverageFromTemplate( GridCoverage2D template, Double value,
        WritableRaster[] writableRasterHolder ) {
    RegionMap regionMap = getRegionParamsFromGridCoverage(template);

    double west = regionMap.getWest();
    double south = regionMap.getSouth();
    double east = regionMap.getEast();
    double north = regionMap.getNorth();
    int cols = regionMap.getCols();
    int rows = regionMap.getRows();
    ComponentSampleModel sampleModel = new ComponentSampleModel(DataBuffer.TYPE_DOUBLE, cols, rows, 1, cols, new int[]{0});

    WritableRaster raster = RasterFactory.createWritableRaster(sampleModel, null);
    if (value != null) {
        // autobox only once
        double v = value;
        for( int y = 0; y < rows; y++ ) {
            for( int x = 0; x < cols; x++ ) {
                raster.setSample(x, y, 0, v);
            }
        }
    }
    if (writableRasterHolder != null) {
        writableRasterHolder[0] = raster;
    }

    Envelope2D writeEnvelope = new Envelope2D(template.getCoordinateReferenceSystem(), west, south, east - west,
            north - south);
    GridCoverageFactory factory = CoverageFactoryFinder.getGridCoverageFactory(null);
    GridCoverage2D coverage2D = factory.create("newraster", raster, writeEnvelope);
    return coverage2D;
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:42,代码来源:CoverageUtilities.java


示例11: createSubCoverageFromTemplate

import javax.media.jai.RasterFactory; //导入依赖的package包/类
/**
 * Create a subcoverage given a template coverage and an envelope.
 * 
 * @param template the template coverage used for the resolution.
 * @param subregion the envelope to extract to the new coverage. This should
 *                  be snapped on the resolution of the coverage, in order to avoid 
 *                  shifts.
 * @param value the value to set the new raster to, if not <code>null</code>. 
 * @param writableRasterHolder an array of length 1 to place the writable raster in, that 
 *                  was can be used to populate the coverage. If <code>null</code>, it is ignored.
 * @return the new coverage.
 */
public static GridCoverage2D createSubCoverageFromTemplate( GridCoverage2D template, Envelope2D subregion, Double value,
        WritableRaster[] writableRasterHolder ) {
    RegionMap regionMap = getRegionParamsFromGridCoverage(template);
    double xRes = regionMap.getXres();
    double yRes = regionMap.getYres();

    double west = subregion.getMinX();
    double south = subregion.getMinY();
    double east = subregion.getMaxX();
    double north = subregion.getMaxY();

    int cols = (int) ((east - west) / xRes);
    int rows = (int) ((north - south) / yRes);
    ComponentSampleModel sampleModel = new ComponentSampleModel(DataBuffer.TYPE_DOUBLE, cols, rows, 1, cols, new int[]{0});

    WritableRaster writableRaster = RasterFactory.createWritableRaster(sampleModel, null);
    if (value != null) {
        // autobox only once
        double v = value;
        for( int y = 0; y < rows; y++ ) {
            for( int x = 0; x < cols; x++ ) {
                writableRaster.setSample(x, y, 0, v);
            }
        }
    }
    if (writableRasterHolder != null)
        writableRasterHolder[0] = writableRaster;
    Envelope2D writeEnvelope = new Envelope2D(template.getCoordinateReferenceSystem(), west, south, east - west,
            north - south);
    GridCoverageFactory factory = CoverageFactoryFinder.getGridCoverageFactory(null);
    GridCoverage2D coverage2D = factory.create("newraster", writableRaster, writeEnvelope);
    return coverage2D;
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:46,代码来源:CoverageUtilities.java


示例12: normalVector

import javax.media.jai.RasterFactory; //导入依赖的package包/类
protected WritableRaster normalVector( WritableRaster pitWR, double res ) {
    int minX = pitWR.getMinX();
    int minY = pitWR.getMinY();
    int rows = pitWR.getHeight();
    int cols = pitWR.getWidth();

    RandomIter pitIter = RandomIterFactory.create(pitWR, null);
    /*
     * Initialize the Image of the normal vector in the central point of the
     * cells, which have 3 components so the Image have 3 bands..
     */
    SampleModel sm = RasterFactory.createBandedSampleModel(5, cols, rows, 3);
    WritableRaster tmpNormalVectorWR = CoverageUtilities.createWritableRaster(cols, rows, null, sm, 0.0);
    WritableRandomIter tmpNormaIter = RandomIterFactory.createWritable(tmpNormalVectorWR, null);
    /*
     * apply the corripio's formula (is the formula (3) in the article)
     */
    for( int j = minY; j < minX + rows - 1; j++ ) {
        for( int i = minX; i < minX + cols - 1; i++ ) {
            double zij = pitIter.getSampleDouble(i, j, 0);
            double zidxj = pitIter.getSampleDouble(i + 1, j, 0);
            double zijdy = pitIter.getSampleDouble(i, j + 1, 0);
            double zidxjdy = pitIter.getSampleDouble(i + 1, j + 1, 0);
            double firstComponent = 0.5 * res * (zij - zidxj + zijdy - zidxjdy);
            double secondComponent = 0.5 * res * (zij + zidxj - zijdy - zidxjdy);
            double thirthComponent = (res * res);
            double den = Math.sqrt(firstComponent * firstComponent + secondComponent * secondComponent + thirthComponent
                    * thirthComponent);
            tmpNormaIter.setPixel(i, j, new double[]{firstComponent / den, secondComponent / den, thirthComponent / den});

        }
    }
    pitIter.done();

    return tmpNormalVectorWR;

}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:38,代码来源:OmsHillshade.java


示例13: normalVector

import javax.media.jai.RasterFactory; //导入依赖的package包/类
protected WritableRaster normalVector( WritableRaster pitWR, double res ) {

        int minX = pitWR.getMinX();
        int minY = pitWR.getMinY();
        int rows = pitWR.getHeight();
        int cols = pitWR.getWidth();

        RandomIter pitIter = RandomIterFactory.create(pitWR, null);
        /*
         * Initializa the Image of the normal vector in the central point of the
         * cells, which have 3 components so the Image have 3 bands..
         */
        SampleModel sm = RasterFactory.createBandedSampleModel(5, cols, rows, 3);
        WritableRaster tmpNormalVectorWR = CoverageUtilities.createWritableRaster(cols, rows, null, sm, 0.0);
        WritableRandomIter tmpNormalIter = RandomIterFactory.createWritable(tmpNormalVectorWR, null);
        /*
         * apply the corripio's formula (is the formula (3) in the article)
         */
        for( int j = minY; j < minX + rows - 1; j++ ) {
            for( int i = minX; i < minX + cols - 1; i++ ) {
                double zij = pitIter.getSampleDouble(i, j, 0);
                double zidxj = pitIter.getSampleDouble(i + 1, j, 0);
                double zijdy = pitIter.getSampleDouble(i, j + 1, 0);
                double zidxjdy = pitIter.getSampleDouble(i + 1, j + 1, 0);
                double firstComponent = res * (zij - zidxj + zijdy - zidxjdy);
                double secondComponent = res * (zij + zidxj - zijdy - zidxjdy);
                double thirthComponent = 2 * (res * res);
                double den = Math.sqrt(firstComponent * firstComponent + secondComponent * secondComponent + thirthComponent
                        * thirthComponent);
                tmpNormalIter.setPixel(i, j, new double[]{firstComponent / den, secondComponent / den, thirthComponent / den});

            }
        }
        pitIter.done();

        return tmpNormalVectorWR;

    }
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:39,代码来源:OmsInsolation.java


示例14: PolarToComplexOpImage

import javax.media.jai.RasterFactory; //导入依赖的package包/类
/**
 * Constructs a <code>PolarToComplexOpImage</code> object.
 *
 * <p>The tile grid layout, SampleModel, and ColorModel may optionally
 * be specified by an ImageLayout object.
 *
 * @param magnitude A RenderedImage representing magnitude.
 * @param phase A RenderedImage representing phase.
 * @param layout An ImageLayout optionally containing the tile grid layout,
 * SampleModel, and ColorModel, or null.
 */
public PolarToComplexOpImage(RenderedImage magnitude,
                             RenderedImage phase,
                             Map config,
                             ImageLayout layout) {
    super(magnitude, phase, layout, config, true);

    // Force the number of bands to be twice the minimum source band count.
    int numBands =
        2*Math.min(magnitude.getSampleModel().getNumBands(),
                   phase.getSampleModel().getNumBands());
    if(sampleModel.getNumBands() != numBands) {
        // Create a new SampleModel for the destination.
        sampleModel =
            RasterFactory.createComponentSampleModel(sampleModel,
                                             sampleModel.getTransferType(),
                                             sampleModel.getWidth(),
                                             sampleModel.getHeight(),
                                             numBands);

        if(colorModel != null &&
           !JDKWorkarounds.areCompatibleDataModels(sampleModel,
                                                   colorModel)) {
            colorModel = ImageUtil.getCompatibleColorModel(sampleModel,
                                                           config);
        }
    }

    // Set phase gain and bias as a function of the phase image data type.
    switch(phase.getSampleModel().getTransferType()) {
    case DataBuffer.TYPE_BYTE:
        phaseGain = (2.0*Math.PI)/255.0;
        phaseBias = -Math.PI;
        break;
    case DataBuffer.TYPE_SHORT:
        phaseGain = (2.0*Math.PI)/Short.MAX_VALUE;
        phaseBias = -Math.PI;
        break;
    case DataBuffer.TYPE_USHORT:
        phaseGain = (2.0*Math.PI)/(Short.MAX_VALUE - Short.MIN_VALUE);
        phaseBias = -Math.PI;
        break;
    case DataBuffer.TYPE_INT:
        phaseGain = (2.0*Math.PI)/Integer.MAX_VALUE;
        phaseBias = -Math.PI;
        break;
    default:
        // A floating point type: do nothing - use class defaults.
    }

    // TODO: Set "complex" property.
}
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:63,代码来源:PolarToComplexOpImage.java


示例15: makePattern

import javax.media.jai.RasterFactory; //导入依赖的package包/类
/** Creates a Raster defining tile (0, 0) of the master pattern. */
private static Raster makePattern(SampleModel sampleModel,
                                  Number[] bandValues) {
    WritableRaster pattern = RasterFactory.createWritableRaster(
                             sampleModel, new Point(0, 0));

    int width = sampleModel.getWidth();
    int height = sampleModel.getHeight();
    int dataType = sampleModel.getTransferType();
    int numBands = sampleModel.getNumBands();
	
    switch (dataType) {
    case DataBuffer.TYPE_BYTE:
        int[] bvalues = new int[numBands];
        for (int i = 0; i < numBands; i++) {
            bvalues[i] = bandValues[i].intValue() & ImageUtil.BYTE_MASK;
        }

        /* Put the first scanline in with setPixels. */
        for (int x = 0; x < width; x++) {
            pattern.setPixel(x, 0, bvalues);
        }
        break;

    case DataBuffer.TYPE_USHORT:	// USHORT is less than 127
    case DataBuffer.TYPE_SHORT:
    case DataBuffer.TYPE_INT:
        int[] ivalues = new int[numBands];
        for (int i = 0; i < numBands; i++) {
            ivalues[i] = bandValues[i].intValue();
        }

        /* Put the first scanline in with setPixels. */
        for (int x = 0; x < width; x++) {
            pattern.setPixel(x, 0, ivalues);
        }
        break;

    case DataBuffer.TYPE_FLOAT:
        float[] fvalues = new float[numBands];
        for (int i = 0; i < numBands; i++) {
            fvalues[i] = bandValues[i].floatValue();
        }

        /* Put the first scanline in with setPixels. */
        for (int x = 0; x < width; x++) {
            pattern.setPixel(x, 0, fvalues);
        }
        break;

    case DataBuffer.TYPE_DOUBLE:
        double[] dvalues = new double[numBands];
        for (int i = 0; i < numBands; i++) {
            dvalues[i] = bandValues[i].doubleValue();
        }

        /* Put the first scanline in with setPixels. */
        for (int x = 0; x < width; x++) {
            pattern.setPixel(x, 0, dvalues);
        }
        break;
    }

    /* Copy the first line out. */
    Object odata = pattern.getDataElements(0, 0, width, 1, null);

    /* Use the first line to copy other rows. */
    for (int y = 1; y < height; y++) {
        pattern.setDataElements(0, y, width, 1, odata);
    }

    return pattern;
}
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:74,代码来源:ConstantOpImage.java


示例16: createTempWritableRaster

import javax.media.jai.RasterFactory; //导入依赖的package包/类
private WritableRaster createTempWritableRaster(Raster src) {
Point origin = new Point(src.getMinX(), src.getMinY());
return RasterFactory.createWritableRaster(src.getSampleModel(), 
					  origin);
   }
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:6,代码来源:ColorConvertOpImage.java


示例17: layoutHelper

import javax.media.jai.RasterFactory; //导入依赖的package包/类
/**
 * Override the dimension specification for the destination such that it
 * has width and height which are equal to non-negative powers of 2.
 */
private static ImageLayout layoutHelper(ImageLayout layout,
                                        RenderedImage source) {
    // Create an ImageLayout or clone the one passed in.
    ImageLayout il = layout == null ?
        new ImageLayout() : (ImageLayout)layout.clone();

    // Force the origin to coincide with that of the source.
    il.setMinX(source.getMinX());
    il.setMinY(source.getMinY());

    // Recalculate the non-unity dimensions to be a positive power of 2.
    // XXX This calculation should not be effected if an implementation
    // of the FCT which supports arbitrary dimensions is used.
    boolean createNewSampleModel = false;
    int w = il.getWidth(source);
    if(w > 1) {
        int newWidth = MathJAI.nextPositivePowerOf2(w);
        if(newWidth != w) {
            il.setWidth(w = newWidth);
            createNewSampleModel = true;
        }
    }
    int h = il.getHeight(source);
    if(h > 1) {
        int newHeight = MathJAI.nextPositivePowerOf2(h);
        if(newHeight != h) {
            il.setHeight(h = newHeight);
            createNewSampleModel = true;
        }
    }

    // Force the image to contain floating point data.
    SampleModel sm = il.getSampleModel(source);
    int dataType = sm.getTransferType();
    if(dataType != DataBuffer.TYPE_FLOAT &&
       dataType != DataBuffer.TYPE_DOUBLE) {
        dataType = DataBuffer.TYPE_FLOAT;
        createNewSampleModel = true;
    }

    // Create a new SampleModel for the destination.
    if(createNewSampleModel) {
        sm = RasterFactory.createComponentSampleModel(sm, dataType, w, h,
                                                      sm.getNumBands());
        il.setSampleModel(sm);

        // Clear the ColorModel mask if needed.
        ColorModel cm = il.getColorModel(null);
        if(cm != null &&
           !JDKWorkarounds.areCompatibleDataModels(sm, cm)) {
            // Clear the mask bit if incompatible.
            il.unsetValid(ImageLayout.COLOR_MODEL_MASK);
        }
    }

    return il;
}
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:62,代码来源:DCTOpImage.java


示例18: layoutHelper

import javax.media.jai.RasterFactory; //导入依赖的package包/类
private static ImageLayout layoutHelper(Vector sources,
                                        ImageLayout il) {

    ImageLayout layout = (il == null) ? new ImageLayout() : (ImageLayout)il.clone();

    int numSources = sources.size();

    // dest data type is the maximum of transfertype of source image
    // utilizing the monotonicity of data types.

    // dest number of bands = sum of source bands
    int destNumBands = totalNumBands(sources);

    int destDataType = DataBuffer.TYPE_BYTE;  // initialize
    RenderedImage srci = (RenderedImage)sources.get(0);
    Rectangle destBounds = new Rectangle(srci.getMinX(),  srci.getMinY(),
                                         srci.getWidth(), srci.getHeight());                                             
    for ( int i = 0; i < numSources; i++ ) {
        srci = (RenderedImage)sources.get(i);
        destBounds = destBounds.intersection(new Rectangle(srci.getMinX(), srci.getMinY(),
                                             srci.getWidth(), srci.getHeight()));

        int typei = srci.getSampleModel().getTransferType();

        // NOTE: this depends on JDK ordering
        destDataType = typei > destDataType ? typei : destDataType;
    }

    SampleModel sm = layout.getSampleModel((RenderedImage)sources.get(0));

    if ( sm.getNumBands() < destNumBands ) {
        int[] destOffsets = new int[destNumBands];

        for(int i=0; i < destNumBands; i++) {
            destOffsets[i] = i;
        }

        // determine the proper width and height to use
        int destTileWidth = sm.getWidth();
        int destTileHeight = sm.getHeight();
        if(layout.isValid(ImageLayout.TILE_WIDTH_MASK))
        {
            destTileWidth =
                layout.getTileWidth((RenderedImage)sources.get(0));
        }
        if(layout.isValid(ImageLayout.TILE_HEIGHT_MASK))
        {
            destTileHeight =
                layout.getTileHeight((RenderedImage)sources.get(0));
        }
        
        sm = RasterFactory.createComponentSampleModel(sm,
                                                      destDataType,
                                                      destTileWidth,
                                                      destTileHeight,
                                                      destNumBands);


        layout.setSampleModel(sm);
    }

    ColorModel cm = layout.getColorModel(null);

    if ( cm != null &&
         !JDKWorkarounds.areCompatibleDataModels(sm, cm)) {
        // Clear the mask bit if incompatible.
        layout.unsetValid(ImageLayout.COLOR_MODEL_MASK);
    }

    return layout;
}
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:72,代码来源:BandMergeOpImage.java


示例19: AddOpImage

import javax.media.jai.RasterFactory; //导入依赖的package包/类
/**
 * Constructs an <code>AddOpImage</code>.
 *
 * <p>The <code>layout</code> parameter may optionally contains the
 * tile grid layout, sample model, and/or color model. The image
 * dimension is determined by the intersection of the bounding boxes
 * of the two source images.
 *
 * <p>The image layout of the first source image, <code>source1</code>,
 * is used as the fall-back for the image layout of the destination
 * image. Any layout parameters not specified in the <code>layout</code>
 * argument are set to the same value as that of <code>source1</code>.
 *
 * @param source1  The first source image.
 * @param source2  The second source image.
 * @param layout   The destination image layout.
 */
public AddOpImage(RenderedImage source1,
                  RenderedImage source2, 
                  Map config,
    ImageLayout layout) {
    super(source1, source2, layout, config, true);

    if(ImageUtil.isBinary(getSampleModel()) &&
       ImageUtil.isBinary(source1.getSampleModel()) &&
       ImageUtil.isBinary(source2.getSampleModel())) {
        // Binary processing case: RasterAccessor
        areBinarySampleModels = true;
    } else {
        // Get the source band counts.
        int numBands1 = source1.getSampleModel().getNumBands();
        int numBands2 = source2.getSampleModel().getNumBands();

        // Handle the special case of adding a single band image to
        // each band of a multi-band image.
        int numBandsDst;
        if(layout != null && layout.isValid(ImageLayout.SAMPLE_MODEL_MASK)) {
            SampleModel sm = layout.getSampleModel(null);
            numBandsDst = sm.getNumBands();

            // One of the sources must be single-banded and the other must
            // have at most the number of bands in the SampleModel hint.
            if(numBandsDst > 1 &&
               ((numBands1 == 1 && numBands2 > 1) ||
                (numBands2 == 1 && numBands1 > 1))) {
                // Clamp the destination band count to the number of
                // bands in the multi-band source.
                numBandsDst = Math.min(Math.max(numBands1, numBands2),
                                       numBandsDst);

                // Create a new SampleModel if necessary.
                if(numBandsDst != sampleModel.getNumBands()) {
                    sampleModel =
                        RasterFactory.createComponentSampleModel(
                            sm,
                            sampleModel.getTransferType(),
                            sampleModel.getWidth(),
                            sampleModel.getHeight(),
                            numBandsDst);

                    if(colorModel != null &&
                       !JDKWorkarounds.areCompatibleDataModels(sampleModel,
                                                               colorModel)) {
                        colorModel =
                            ImageUtil.getCompatibleColorModel(sampleModel,
                                                              config);
                    }
                }

                // Set the source band increments.
                s1bd = numBands1 == 1 ? 0 : 1;
                s2bd = numBands2 == 1 ? 0 : 1;
            }
        }
    }

    // Set flag to permit in-place operation.
    permitInPlaceOperation();
}
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:80,代码来源:AddOpImage.java


示例20: SubtractOpImage

import javax.media.jai.RasterFactory; //导入依赖的package包/类
/**
 * Constructs an <code>SubtractOpImage</code>.
 *
 * <p>The <code>layout</code> parameter may optionally contains the
 * tile grid layout, sample model, and/or color model. The image
 * dimension is determined by the intersection of the bounding boxes
 * of the two source images.
 *
 * <p>The image layout of the first source image, <code>source1</code>,
 * is used as the fall-back for the image layout of the destination
 * image. Any layout parameters not specified in the <code>layout</code>
 * argument are set to the same value as that of <code>source1</code>.
 *
 * @param source1  The first source image.
 * @param source2  The second source image.
 * @param layout   The destination image layout.
 */
public SubtractOpImage(RenderedImage source1,
                       RenderedImage source2, 
                       Map config,
         ImageLayout layout) {
    super(source1, source2, layout, config, true);
    // Get the source band counts.
    int numBands1 = source1.getSampleModel().getNumBands();
    int numBands2 = source2.getSampleModel().getNumBands();

    // Handle the special case of subtracting from each band of an N-band
    // image a single-band image.
    int numBandsDst;
    if(layout != null && layout.isValid(ImageLayout.SAMPLE_MODEL_MASK)) {
        SampleModel sm = layout.getSampleModel(null);
        numBandsDst = sm.getNumBands();

        // The second source must be single-banded and the first must
        // be multi-banded.
        if(numBandsDst > 1 &&
           ((numBands1 > 1 && numBands2 == 1) ||
            (numBands1 == 1 && numBands2 > 1))) {
            // Clamp the destination band count to the number of
            // bands in the multi-band source.
            numBandsDst = Math.min(Math.max(numBands1, numBands2),
                                   numBandsDst);

            // Create a new SampleModel if necessary.
            if(numBandsDst != sampleModel.getNumBands()) {
                sampleModel =
                    RasterFactory.createComponentSampleModel(
                        sm,
                        sampleModel.getTransferType(),
                        sampleModel.getWidth(),
                        sampleModel.getHeight(),
                        numBandsDst);

                if(colorModel != null &&
                   !JDKWorkarounds.areCompatibleDataModels(sampleModel,
                                                           colorModel)) {
                    colorModel =
                        ImageUtil.getCompatibleColorModel(sampleModel,
                                                          config);
                }
            }

            // Set the source band increments.
            s1bd = numBands1 == 1 ? 0 : 1;
            s2bd = numBands2 == 1 ? 0 : 1;
        }
    }

    // Set flag to permit in-place operation.
    permitInPlaceOperation();
}
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:72,代码来源:SubtractOpImage.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ActiveEditorDrop类代码示例发布时间:2022-05-22
下一篇:
Java NodeIndicesStats类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap