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


Java InterpolationNearest类代码示例

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


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

示例1: interpolationToByte

import javax.media.jai.InterpolationNearest; //导入依赖的package包/类
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;
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:18,代码来源:RasterDataAdapter.java

示例2: rescale

import javax.media.jai.InterpolationNearest; //导入依赖的package包/类
private RenderedImage rescale(RenderedImage i) {
	float scaleW = ((float) baseSize) / i.getWidth();
	float scaleH = ((float) baseSize) / i.getHeight();
	// Scales the original image
	ParameterBlock pb = new ParameterBlock();
	pb.addSource(i);
	pb.add(scaleW);
	pb.add(scaleH);
	pb.add(0.0F);
	pb.add(0.0F);
	pb.add(new InterpolationNearest());
	// Creates a new, scaled image and uses it on the DisplayJAI component
	return JAI.create("scale", pb);
}
 
开发者ID:qmetry,项目名称:qaf,代码行数:15,代码来源:ImageCompareUtil.java

示例3: populateInterpolation

import javax.media.jai.InterpolationNearest; //导入依赖的package包/类
/**
 * Populate interpolation map.
 */
private static synchronized void populateInterpolation() {
    if (interpolationMap == null) {
        interpolationMap = new LinkedHashMap<Class<? extends Interpolation>, String>();
        interpolationMap.put(InterpolationNearest.class, "Nearest Neighbour");
        interpolationMap.put(InterpolationBicubic.class, "Bicubic");
        interpolationMap.put(InterpolationBicubic2.class, "Bicubic2");
        interpolationMap.put(InterpolationBilinear.class, "Bilinear");
    }
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:13,代码来源:InterpolationValues.java

示例4: performRotate

import javax.media.jai.InterpolationNearest; //导入依赖的package包/类
/**
 * Rotate an image.
 * @param image the image to rotate.
 * @return the rotated image.
 */
public PlanarImage performRotate(PlanarImage image) {
    float tAngle = (float) (angle * (Math.PI / HALF_CIRCLE));
    ParameterBlock pb = new ParameterBlock();
    pb.addSource(image);
    pb.add(0.0F);
    pb.add(0.0F);
    pb.add(tAngle);
    pb.add(new InterpolationNearest());
    return JAI.create("Rotate", pb, null);
}
 
开发者ID:apache,项目名称:ant,代码行数:16,代码来源:Rotate.java

示例5: create

import javax.media.jai.InterpolationNearest; //导入依赖的package包/类
/**
 * Creates a new instance of warp operator according to the warp object
 * and interpolation method.
 *
 * @param paramBlock  The warp and interpolation objects.
 */
public RenderedImage create(ParameterBlock paramBlock,
                            RenderingHints renderHints) {
    // Get ImageLayout from renderHints if any.
    ImageLayout layout = RIFUtil.getImageLayoutHint(renderHints);


    // Get BorderExtender from renderHints if any.
    BorderExtender extender = RIFUtil.getBorderExtenderHint(renderHints);

    RenderedImage source = paramBlock.getRenderedSource(0);
    Warp warp = (Warp)paramBlock.getObjectParameter(0);
    Interpolation interp = (Interpolation)paramBlock.getObjectParameter(1);

    double[] backgroundValues = (double[])paramBlock.getObjectParameter(2);

    if (interp instanceof InterpolationNearest) {
        return new WarpNearestOpImage(source,
                                      renderHints,
                                      layout,
                                      warp,
                                      interp,
                                      backgroundValues);
    } else if (interp instanceof InterpolationBilinear) {
        return new WarpBilinearOpImage(source, extender, renderHints,
                                       layout, warp, interp,
                                       backgroundValues);
    } else {
        return new WarpGeneralOpImage(source, extender, renderHints,
                                      layout, warp, interp,
                                      backgroundValues);
    }
}
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:39,代码来源:WarpRIF.java

示例6: create

import javax.media.jai.InterpolationNearest; //导入依赖的package包/类
/**
    * <p> Creates a new instance of SubsampleOpImage in the rendered layer.
    * This method satisfies the implementation of RIF.
    *
    * @param paramBlock  The source image, the X and Y scale factors.
    * @param renderHints RenderingHints.
    */
   public RenderedImage create(ParameterBlock paramBlock,
                               RenderingHints renderHints) {
       RenderedImage source = paramBlock.getRenderedSource(0);

       BorderExtender extender = renderHints == null ? null :
           (BorderExtender)renderHints.get(JAI.KEY_BORDER_EXTENDER);
       ImageLayout layout = renderHints == null ? null :
           (ImageLayout)renderHints.get(JAI.KEY_IMAGE_LAYOUT);

       int scaleX = paramBlock.getIntParameter(0);
       int scaleY = paramBlock.getIntParameter(1);
       float [] qsFilter = (float [])paramBlock.getObjectParameter(2);
       Interpolation interp = (Interpolation)paramBlock.getObjectParameter(3);

       // check if binary and interpolation type allowed
SampleModel sm = source.getSampleModel();
       int dataType = sm.getDataType();

       // Determine the interpolation type, if not supported throw exception
boolean validInterp = (interp instanceof InterpolationNearest)  ||
                             (interp instanceof InterpolationBilinear) ||
                             (interp instanceof InterpolationBicubic)  ||
                             (interp instanceof InterpolationBicubic2);

       if (!validInterp)
           throw new IllegalArgumentException(
        JaiI18N.getString("FilteredSubsample3"));

       return new FilteredSubsampleOpImage(source, extender, (Map)renderHints, layout,
                                   scaleX, scaleY, qsFilter, interp);
   }
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:39,代码来源:FilteredSubsampleRIF.java

示例7: pointArr2Rect

import javax.media.jai.InterpolationNearest; //导入依赖的package包/类
private Rectangle pointArr2Rect(float[] points) {
    float f_sx0 = Float.MAX_VALUE;
    float f_sy0 = Float.MAX_VALUE;
    float f_sx1 = -Float.MAX_VALUE;
    float f_sy1 = -Float.MAX_VALUE;
    for (int i = 0; i < 4; i++) {
        float px = points[i * 2];
        float py = points[i * 2 + 1];

        f_sx0 = Math.min(f_sx0, px);
        f_sy0 = Math.min(f_sy0, py);
        f_sx1 = Math.max(f_sx1, px);
        f_sy1 = Math.max(f_sy1, py);
    }

    int s_x0 = 0, s_y0 = 0, s_x1 = 0, s_y1 = 0;

    // Find the bounding box of the source rectangle
    if (interp instanceof InterpolationNearest) {
        s_x0 = (int) Math.floor(f_sx0);
        s_y0 = (int) Math.floor(f_sy0);

        // Fix for bug 4485920 was to add " + 0.05" to the following
        // two lines. It should be noted that the fix was made based
        // on empirical evidence and tested thoroughly, but it is not
        // known whether this is the root cause.
        s_x1 = (int) Math.ceil(f_sx1 + 0.5);
        s_y1 = (int) Math.ceil(f_sy1 + 0.5);
    } else {
        s_x0 = (int) Math.floor(f_sx0 - 0.5);
        s_y0 = (int) Math.floor(f_sy0 - 0.5);
        s_x1 = (int) Math.ceil(f_sx1);
        s_y1 = (int) Math.ceil(f_sy1);
    }

    //
    // Return the new rectangle
    //
    return new Rectangle(s_x0, s_y0, s_x1 - s_x0, s_y1 - s_y0);
}
 
开发者ID:geosolutions-it,项目名称:soil_sealing,代码行数:41,代码来源:GridCoverage2DRIA.java

示例8: reportInternal

import javax.media.jai.InterpolationNearest; //导入依赖的package包/类
public Object reportInternal (Argument args[], Context context)
        throws ExtensionException, LogoException {
    Interpolation interp = getDataset(args[0]).getInterpolation();
    if (interp instanceof InterpolationNearest) {
        return "NEAREST_NEIGHBOR";
    } else if (interp instanceof InterpolationBilinear) {
        return "BILINEAR";
    } else if (interp instanceof InterpolationBicubic) {
        return "BICUBIC";
    } else if (interp instanceof InterpolationBicubic2) {
        return "BICUBIC_2";
    } else {
        throw new ExtensionException("Unknown interpolation type: " + Dump.logoObject(interp));
    }
}
 
开发者ID:reuven,项目名称:modelingcommons,代码行数:16,代码来源:RasterDataset.java

示例9: zoom

import javax.media.jai.InterpolationNearest; //导入依赖的package包/类
public static RenderedImage zoom(RenderedImage image, float amount) {
	AffineTransform tr = new AffineTransform(amount, 
			0, 
			0, 
			amount, 
			0.0, 
			0.0); 
	//Specify the type of interpolation. 
	Interpolation interp = new InterpolationNearest(); 
	//Create the affine operation. 
	PlanarImage im2 = (PlanarImage)JAI.create("affine", image, tr, 
			interp); 
	return im2;
}
 
开发者ID:NCIP,项目名称:cagrid-general,代码行数:15,代码来源:ImageUtils.java

示例10: TestImage3

import javax.media.jai.InterpolationNearest; //导入依赖的package包/类
/**
 * Creates a new TestImage3 object.
 */
public TestImage3 ()
{
    JFrame frame = new JFrame(getClass().getName());
    Container pane = frame.getContentPane();
    pane.setLayout(new BorderLayout());

    pane.add(this);

    image = decodeImage(
            new String[]{
                "#-###############", "-----------------", "#################", "-----------------",
                "#################", "-----------------", "#################", "-----------------",
                "#################", "-----------------", "#################", "-----------------",
                "-----------------", "-----------------", "---####----------", "-------##--------",
                "---------####----", "-------------#---", "-------------#---", "-----------------",
                "--#############--", "--#############--", "--#############--", "--#############--",
                "--#############--", "--#############--", "--#############--", "--#############--",
                "--#############--", "--#############--", "--#############--", "-----------------",
                "-----------------", "---####----------", "-------##--------", "---------####----",
                "-------------#---", "-------------#---", "-----------------", "--#############--",
                "--#############--", "-----------------", "-----------------"
            });

    //        checkImageFormat();
    ImageInfo.print(image);

    // Scaling
    final float scale = 1f;
    ParameterBlock pb = new ParameterBlock().addSource(image).add(scale).add(scale).add(0f)
            .add(0f).add(new InterpolationNearest());
    image = JAI.create("scale", pb);
    dumpPixels(0, 0, 5, 7);

    if (false) {
        System.out.println("\nBand Selection");
        image = JAI.create("bandselect", image, new int[]{0, 1, 2});
        ImageInfo.print(image);
        dumpPixels(0, 0, 5, 7);
    }

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLocation(100, 100);
    frame.pack();
    frame.setSize(100, 250);
    frame.setVisible(true);
}
 
开发者ID:Audiveris,项目名称:audiveris,代码行数:50,代码来源:TestImage3.java

示例11: scale

import javax.media.jai.InterpolationNearest; //导入依赖的package包/类
public static RenderedOp scale(final RenderedImage renderedImage, final float xFactor, final float yFactor) {
  return ScaleDescriptor.create(renderedImage, xFactor, yFactor, 0.0f, 0.0f, new InterpolationNearest(), null);
}
 
开发者ID:AndreasWBartels,项目名称:libraries,代码行数:4,代码来源:ImageContainerUtilities.java

示例12: contains

import javax.media.jai.InterpolationNearest; //导入依赖的package包/类
public boolean contains(String reference, String template, Point start) throws Exception {
	RenderedImage ref = (ImageIO.read(new File(reference)));

	// Calculate the signature vector for the reference.
	// Now we need a component to store X images in a stack, where X is the
	// number of images in the same directory as the original one.
	// For each image, calculate its signature and its distance from the
	// reference signature.
	RenderedImage other = ImageIO.read(new File(template));

	int x, y, h, w, th, tw;
	double distance = Double.MAX_VALUE;
	h = ref.getHeight();
	w = ref.getWidth();
	System.out.println("px width: " + ref.getData().getWidth() + "px height: " + ref.getData().getHeight());
	System.out.println("width: " + ref.getWidth() + "height: " + ref.getHeight());
	System.out.println("min x: " + ref.getData().getMinX() + " y: " + ref.getData().getMinY());

	th = other.getHeight();
	tw = other.getWidth();

	for (int r = 0; r <= (h - th); r += 5) {
		for (int c = 0; c <= (w - tw); c += 5) {
			ParameterBlock pb = new ParameterBlock();
			pb.addSource(ref);
			pb.add((float) c);
			pb.add((float) r);
			pb.add((float) tw);
			pb.add((float) th);
			pb.add(new InterpolationNearest());
			// Creates a new, scaled image and uses it on the DisplayJAI
			// component

			try {
				double tdistance = calcDistance(rescale(JAI.create("crop", pb)), rescale(other));
				if ((tdistance < distance)) {
					distance = tdistance;
				}

				if (distance == 0) {
					break;
				}
				System.out.println("distance" + distance + " x: " + r + " y: " + c);
			} catch (Exception e) {
				System.out.print("Error: " + e.toString());
				e.printStackTrace();
			}
		}

		if (distance == 0) {
			break;
		}
	}
	return distance < maxDiff;
}
 
开发者ID:qmetry,项目名称:qaf,代码行数:56,代码来源:ImageCompareUtil.java

示例13: backwardMapRect

import javax.media.jai.InterpolationNearest; //导入依赖的package包/类
/**
 * Backward map the destination Rectangle.
 */
protected Rectangle backwardMapRect(Rectangle destRect,
                                    int sourceIndex) {
    //
    // Backward map the destination to get the corresponding
    // source Rectangle
    //
    float dx0 = (float) destRect.x;
    float dy0 = (float) destRect.y;
    float dw = (float) (destRect.width);
    float dh = (float) (destRect.height);

    Point2D[] pts = new Point2D[4];
    pts[0] = new Point2D.Float(dx0, dy0);
    pts[1] = new Point2D.Float((dx0 + dw), dy0);
    pts[2] = new Point2D.Float((dx0 + dw), (dy0 + dh));
    pts[3] = new Point2D.Float(dx0, (dy0 + dh));

    i_transform.transform(pts, 0, pts, 0, 4);

    float f_sx0 =  Float.MAX_VALUE;
    float f_sy0 =  Float.MAX_VALUE;
    float f_sx1 = -Float.MAX_VALUE;
    float f_sy1 = -Float.MAX_VALUE;
    for (int i = 0; i < 4; i++) {
        float px = (float)pts[i].getX();
        float py = (float)pts[i].getY();

        f_sx0 = Math.min(f_sx0, px);
        f_sy0 = Math.min(f_sy0, py);
        f_sx1 = Math.max(f_sx1, px);
        f_sy1 = Math.max(f_sy1, py);
    }

    int s_x0 = 0, s_y0 = 0, s_x1 = 0, s_y1 = 0;

    // Find the bounding box of the source rectangle
    if (interp instanceof InterpolationNearest) {
        s_x0 = (int) Math.floor(f_sx0);
        s_y0 = (int) Math.floor(f_sy0);

        // Fix for bug 4485920 was to add " + 0.05" to the following
        // two lines.  It should be noted that the fix was made based
        // on empirical evidence and tested thoroughly, but it is not
        // known whether this is the root cause.
        s_x1 = (int) Math.ceil(f_sx1 + 0.5);
        s_y1 = (int) Math.ceil(f_sy1 + 0.5);
    } else {
        s_x0 = (int) Math.floor(f_sx0 - 0.5);
        s_y0 = (int) Math.floor(f_sy0 - 0.5);
        s_x1 = (int) Math.ceil(f_sx1);
        s_y1 = (int) Math.ceil(f_sy1);
    }

    //
    // Return the new rectangle
    //
    return new Rectangle(s_x0,
                         s_y0,
                         s_x1 - s_x0,
                         s_y1 - s_y0);
}
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:65,代码来源:AffineOpImage.java

示例14: FilteredSubsampleOpImage

import javax.media.jai.InterpolationNearest; //导入依赖的package包/类
/** <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;


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

示例15: validateParameters

import javax.media.jai.InterpolationNearest; //导入依赖的package包/类
/**
    * Validates the input parameters.
    *
    * <p> In addition to the standard checks performed by the
    * superclass method, this method checks that "scaleX" and "scaleY"
    * are both greater than 0 and that the interpolation type
    * is one of 4 standard types: <br>
    * <p> <code>
    *    javax.media.jai.InterpolationNearest <br>
    *    javax.media.jai.InterpolationBilinear <br>
    *    javax.media.jai.InterpolationBicubic <br>
    *    javax.media.jai.InterpolationBicubic2
    * </code>
    */
   protected boolean validateParameters(String modeName,
				 ParameterBlock args,
                                        StringBuffer msg) {
if (!super.validateParameters(modeName, args, msg))
    return false;

       int scaleX = args.getIntParameter(0);
       int scaleY = args.getIntParameter(1);
       if (scaleX < 1 || scaleY < 1) {
           msg.append(getName() + " " +
                      JaiI18N.getString("FilteredSubsampleDescriptor1"));
           return false;
       }

float[] filter = (float[])args.getObjectParameter(2);

// if this parameter is null, generate the kernel based on the
// procedure described above.
if (filter == null) {
    int m = scaleX > scaleY ? scaleX: scaleY;
    if ((m & 1) == 0)
	m++;

    double sigma = (m - 1) / 6.0;

    // when m is 1, sigma is 0; will generate NaN.  Give any number
    // to sigma will generate the correct kernel {1.0}
    if (m == 1)
	sigma = 1.0;

    filter = new float[m/2 + 1];
    float sum = 0;

    for (int i = 0; i < filter.length; i++) {
	filter[i] = (float)gaussian((double)i, sigma);
	if (i == 0)
	    sum += filter[i];
	else
	    sum += filter[i] * 2;
    }

    for (int i = 0; i < filter.length; i++) {
	filter[i] /= sum;
    }

    args.set(filter, 2);
}

       Interpolation interp = (Interpolation)args.getObjectParameter(3);

       // Determine the interpolation type, if not supported throw exception
       if (!((interp instanceof InterpolationNearest)  ||
           (interp instanceof InterpolationBilinear) ||
           (interp instanceof InterpolationBicubic)  ||
           (interp instanceof InterpolationBicubic2))) {
          msg.append(getName() + " " +
                      JaiI18N.getString("FilteredSubsampleDescriptor2"));
          return false;
       }
       return true;

   }
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:77,代码来源:FilteredSubsampleDescriptor.java


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