001/******************************************************************************* 002 * This software is provided as a supplement to the authors' textbooks on digital 003 * image processing published by Springer-Verlag in various languages and editions. 004 * Permission to use and distribute this software is granted under the BSD 2-Clause 005 * "Simplified" License (see http://opensource.org/licenses/BSD-2-Clause). 006 * Copyright (c) 2006-2016 Wilhelm Burger, Mark J. Burge. All rights reserved. 007 * Visit http://imagingbook.com for additional details. 008 *******************************************************************************/ 009 010package imagingbook.lib.interpolation; 011import imagingbook.lib.image.ImageAccessor; 012 013 014public class NearestNeighborInterpolator extends PixelInterpolator { 015 016 public NearestNeighborInterpolator() { 017 } 018 019 @Override 020 public float getInterpolatedValue(ImageAccessor.Scalar ia, double x, double y) { 021 final int u = (int) Math.rint(x); 022 final int v = (int) Math.rint(y); 023 return ia.getVal(u, v); 024 } 025 026}