本文整理汇总了Java中javax.media.jai.Interpolation.INTERP_NEAREST属性的典型用法代码示例。如果您正苦于以下问题:Java Interpolation.INTERP_NEAREST属性的具体用法?Java Interpolation.INTERP_NEAREST怎么用?Java Interpolation.INTERP_NEAREST使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.media.jai.Interpolation
的用法示例。
在下文中一共展示了Interpolation.INTERP_NEAREST属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: RasterDataAdapter
public RasterDataAdapter(
final String coverageName,
final SampleModel sampleModel,
final ColorModel colorModel,
final Map<String, String> metadata,
final int tileSize,
final double[][] noDataValuesPerBand,
final double[] backgroundValuesPerBand,
final boolean buildPyramid ) {
this(
coverageName,
sampleModel,
colorModel,
metadata,
tileSize,
noDataValuesPerBand,
backgroundValuesPerBand,
new HistogramConfig(
sampleModel),
true,
Interpolation.INTERP_NEAREST,
buildPyramid,
new NoDataMergeStrategy());
}
示例2: interpolationToByte
protected static byte interpolationToByte(
final Interpolation interpolation ) {
// this is silly because it seems like a translation JAI should provide,
// but it seems its not provided and its the most efficient approach
// (rather than serializing class names)
if (interpolation instanceof InterpolationNearest) {
return Interpolation.INTERP_NEAREST;
}
if (interpolation instanceof InterpolationBilinear) {
return Interpolation.INTERP_BILINEAR;
}
if (interpolation instanceof InterpolationBicubic2) {
return Interpolation.INTERP_BICUBIC_2;
}
return Interpolation.INTERP_BICUBIC;
}
示例3: getResampling
private Interpolation getResampling(Band band) {
int resampleType = getResampleType();
if (!ProductData.isFloatingPointType(band.getDataType())) {
resampleType = Interpolation.INTERP_NEAREST;
}
return Interpolation.getInstance(resampleType);
}
示例4: getResampleType
private int getResampleType() {
final int resamplingType;
if ("Nearest".equalsIgnoreCase(resamplingName)) {
resamplingType = Interpolation.INTERP_NEAREST;
} else if ("Bilinear".equalsIgnoreCase(resamplingName)) {
resamplingType = Interpolation.INTERP_BILINEAR;
} else if ("Bicubic".equalsIgnoreCase(resamplingName)) {
resamplingType = Interpolation.INTERP_BICUBIC;
} else {
resamplingType = -1;
}
return resamplingType;
}
示例5: getInterpolationType
private static int getInterpolationType(String interpolationString) {
final int interpolationType;
if ("Nearest".equalsIgnoreCase(interpolationString)) {
interpolationType = Interpolation.INTERP_NEAREST;
} else if ("Bilinear".equalsIgnoreCase(interpolationString)) {
interpolationType = Interpolation.INTERP_BILINEAR;
} else if ("Bicubic".equalsIgnoreCase(interpolationString)) {
interpolationType = Interpolation.INTERP_BICUBIC;
} else {
interpolationType = -1;
}
return interpolationType;
}
示例6: combineFilters
/** <p> <code>combineFilters</code> based on <code>resampleType</code> and
* input partial <code>qsFilter</code> (see above for details on qsFilter format).
* Input <code>qsFilter</code> is restricted to have odd parity
* (<code>qsFilter[0]</code> is at the center of the kernel).
*
* @param scaleFactor positive int representing the downsample factor.
* @param resampleType int representing the interpolation type.
* @param qsFilter floating partial kernel array (antialias filter).
* @return floating partial kernel representing combined resample and qsFilter.
*/
private static float [] combineFilters(int scaleFactor,
int resampleType,
float [] qsFilter) {
// Odd scale factors imply no resample filter is required
// return pointer to the qsFilter
if ((scaleFactor%2) == 1) return (float [])qsFilter.clone();
int qsParity = 1;
int resampParity = 0; // Unless nearest neighbor case is selected (ignored)
switch (resampleType) {
case Interpolation.INTERP_NEAREST: // Return a copy of the qsFilter
return (float [])qsFilter.clone();
case Interpolation.INTERP_BILINEAR: // 2 by 2 resample filter
float [] bilinearKernel = { 1.0F/2.0F };
return convolveSymmetricKernels(
qsParity, resampParity, qsFilter, bilinearKernel);
case Interpolation.INTERP_BICUBIC: // 4 by 4 resample filter
float [] bicubicKernel = { 9.0F/16.0F, -1.0F/16.0F };
return convolveSymmetricKernels(
qsParity, resampParity, qsFilter, bicubicKernel);
case Interpolation.INTERP_BICUBIC_2: // alternate 4 by 4 resample filter
float [] bicubic2Kernel = { 5.0F/8.0F, -1.0F/8.0F };
return convolveSymmetricKernels(
qsParity, resampParity, qsFilter, bicubic2Kernel);
default:
throw new IllegalArgumentException(
JaiI18N.getString("FilteredSubsample0"));
}
}
示例7: filterParity
/** <p> <code>filterParity</code> -- Returns combined filter/resample parity.
* This is odd only when we have an odd scale factor or we have nearest neighbor
* filtering (no resample kernel needed). <code>scaleFactor</code> was validated
* by the constructor. Possible return values are 0 or 1.
*
* @param scaleFactor positive int representing the downsample factor.
* @param resampleType int representing the interpolation type.
* @return int representing combined filter parity (0 or 1).
*/
private static int filterParity(int scaleFactor, int resampleType) {
// Test scale factor for oddness or nearest neighbor resampling
if ((scaleFactor%2 == 1) ||
(resampleType == Interpolation.INTERP_NEAREST)) return 1;
// for all other cases we will be convolving an odd filter with an even
// filter, thus producing an even filter
return 0;
}
示例8: FilteredSubsampleOpImage
/** <p> <code>FilteredSubsampleOpImage</code> constructs an OpImage representing
* filtered integral subsampling. The scale factors represent the ratio of
* source to destination dimensions.
*
* @param source a RenderedImage.
* @param extender a BorderExtender, or null.
* @param config a Map object possibly holding tile cache information
* @param layout an ImageLayout optionally containing the tile grid layout,
* SampleModel, and ColorModel, or null.
* @param interp a Interpolation object to use for resampling.
* @param scaleX downsample factor along x axis.
* @param scaleY downsample factor along y axis.
* @param qsFilter symmetric filter coefficients (partial kernel).
* @throws IllegalArgumentException if the interp type is not one of:
* INTERP_NEAREST, INTERP_BILINEAR, INTERP_BICUBIC, or INTERP_BICUBIC_2
*/
public FilteredSubsampleOpImage(RenderedImage source,
BorderExtender extender,
Map config,
ImageLayout layout,
int scaleX,
int scaleY,
float [] qsFilter,
Interpolation interp) {
// Propagate to GeometricOpImage constructor
super(vectorize(source),
layoutHelper(source, interp, scaleX, scaleY, qsFilter.length, layout),
config, // Map object
true, // cobbleSources,
extender, // extender
interp, // Interpolation object
null);
int resampleType;
// Determine the interpolation type, if not supported throw exception
if (interp instanceof InterpolationNearest) {
resampleType = Interpolation.INTERP_NEAREST;
} else if (interp instanceof InterpolationBilinear) {
resampleType = Interpolation.INTERP_BILINEAR;
} else if (interp instanceof InterpolationBicubic) {
resampleType = Interpolation.INTERP_BICUBIC;
} else if (interp instanceof InterpolationBicubic2) {
resampleType = Interpolation.INTERP_BICUBIC_2;
} else {
throw new IllegalArgumentException(
JaiI18N.getString("FilteredSubsample3"));
}
// Construct combined anti-alias and resample kernels.
this.hParity = filterParity(scaleX,resampleType);
this.vParity = filterParity(scaleY,resampleType);
this.hKernel = combineFilters(scaleX,resampleType,qsFilter);
this.vKernel = combineFilters(scaleY,resampleType,qsFilter);
this.scaleX = scaleX;
this.scaleY = scaleY;
}
示例9: createDataAdapterTypeDouble
public static RasterDataAdapter createDataAdapterTypeDouble(
final String coverageName,
final int numBands,
final int tileSize,
final double[] minsPerBand,
final double[] maxesPerBand,
final String[] namesPerBand,
final RasterTileMergeStrategy<?> mergeStrategy ) {
final double[][] noDataValuesPerBand = new double[numBands][];
final double[] backgroundValuesPerBand = new double[numBands];
final int[] bitsPerSample = new int[numBands];
for (int i = 0; i < numBands; i++) {
noDataValuesPerBand[i] = new double[] {
Double.valueOf(Double.NaN)
};
backgroundValuesPerBand[i] = Double.valueOf(Double.NaN);
bitsPerSample[i] = DataBuffer.getDataTypeSize(DataBuffer.TYPE_DOUBLE);
}
final SampleModel sampleModel = createRasterTypeDouble(
numBands,
tileSize).getSampleModel();
return new RasterDataAdapter(
coverageName,
sampleModel,
new ComponentColorModel(
new BogusColorSpace(
numBands),
bitsPerSample,
false,
false,
Transparency.OPAQUE,
DataBuffer.TYPE_DOUBLE),
new HashMap<String, String>(),
tileSize,
minsPerBand,
maxesPerBand,
namesPerBand,
noDataValuesPerBand,
backgroundValuesPerBand,
null,
false,
Interpolation.INTERP_NEAREST,
false,
mergeStrategy);
}