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


Java RasterFactory.createComponentSampleModel方法代码示例

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


在下文中一共展示了RasterFactory.createComponentSampleModel方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: MagnitudePhaseOpImage

import javax.media.jai.RasterFactory; //导入方法依赖的package包/类
/**
 * Constructs a <code>MagnitudePhaseOpImage</code> object.
 *
 * <p>The tile grid layout, SampleModel, and ColorModel may optionally
 * be specified by an ImageLayout object.
 *
 * @param source A RenderedImage.
 * @param layout An ImageLayout optionally containing the tile grid layout,
 * SampleModel, and ColorModel, or null.
 * @param operationType One of the static final flag values defined in
 * this class which indicates the type of operation to perform.
 */
public MagnitudePhaseOpImage(RenderedImage source,
                             Map config,
                             ImageLayout layout,
                             int operationType) {
    super(source, layout, config, true);

    // Cache the parameter.
    this.operationType = operationType;

    // Initialize the SampleModel flag.
    boolean needNewSampleModel = false;

    // Reset the data type to that specified by the layout if it
    // has been modified within the superclass constructor chain.
    int dataType = sampleModel.getTransferType();
    if(layout != null &&
       dataType != layout.getSampleModel(source).getTransferType()) {
        dataType = layout.getSampleModel(source).getTransferType();
        needNewSampleModel = true;
    }

    // Force the band count to be at most half that of the source image.
    int numBands = sampleModel.getNumBands();
    if(numBands > source.getSampleModel().getNumBands()/2) {
        numBands = source.getSampleModel().getNumBands()/2;
        needNewSampleModel = true;
    }

    // Create a new SampleModel for the destination.
    if(needNewSampleModel) {
        sampleModel =
            RasterFactory.createComponentSampleModel(sampleModel, dataType,
                                                     sampleModel.getWidth(),
                                                     sampleModel.getHeight(),
                                                     numBands);

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

    if(operationType == PHASE) {
        // Set phase gain and bias as a function of destination data type.
        switch(dataType) {
        case DataBuffer.TYPE_BYTE:
            phaseGain = 255.0/(2.0*Math.PI);
            phaseBias = Math.PI;
            break;
        case DataBuffer.TYPE_SHORT:
            phaseGain = Short.MAX_VALUE/(2.0*Math.PI);
            phaseBias = Math.PI;
            break;
        case DataBuffer.TYPE_USHORT:
            phaseGain = (Short.MAX_VALUE - Short.MIN_VALUE)/(2.0*Math.PI);
            phaseBias = Math.PI;
            break;
        case DataBuffer.TYPE_INT:
            phaseGain = Integer.MAX_VALUE/(2.0*Math.PI);
            phaseBias = Math.PI;
            break;
        default:
            // A floating point type: do nothing.
        }
    }
}
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:81,代码来源:MagnitudePhaseOpImage.java

示例9: layoutHelper

import javax.media.jai.RasterFactory; //导入方法依赖的package包/类
/**
 * Force the destination image to have a signed data type.
 */
private static ImageLayout layoutHelper(ImageLayout layout,
                                        RenderedImage source) {
    // Create or clone the layout.
    ImageLayout il = layout == null ?
        new ImageLayout() : (ImageLayout)layout.clone();

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

    // Get the data type.
    int dataType = sm.getTransferType();

    // Determine whether the destination requires a different data type
    // and set it if so.
    boolean createNewSampleModel = false;
    if(dataType == DataBuffer.TYPE_BYTE) {
        dataType = DataBuffer.TYPE_SHORT;
        createNewSampleModel = true;
    } else if(dataType == DataBuffer.TYPE_USHORT) {
        dataType = DataBuffer.TYPE_INT;
        createNewSampleModel = true;
    }

    // Create a new SampleModel for the destination if necessary.
    if(createNewSampleModel) {
        sm = RasterFactory.createComponentSampleModel(sm, dataType,
                                                      sm.getWidth(),
                                                      sm.getHeight(),
                                                      sm.getNumBands());

        il.setSampleModel(sm);

        // Check ColorModel.
        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,代码行数:47,代码来源:ConjugateOpImage.java


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