/* JAI-Ext - OpenSource Java Advanced Image Extensions Library
* http://www.geo-solutions.it/
* Copyright 2014 GeoSolutions
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package it.geosolutions.jaiext.scale;
import static org.junit.Assert.*;
import java.awt.RenderingHints;
import java.awt.image.ComponentSampleModel;
import java.awt.image.DataBuffer;
import java.awt.image.MultiPixelPackedSampleModel;
import java.awt.image.Raster;
import java.awt.image.RenderedImage;
import java.awt.image.SampleModel;
import javax.media.jai.BorderExtender;
import javax.media.jai.Interpolation;
import javax.media.jai.JAI;
import javax.media.jai.PlanarImage;
import javax.media.jai.TiledImage;
import org.hamcrest.CoreMatchers;
import org.junit.Test;
import it.geosolutions.jaiext.range.RangeFactory;
/**
* This test-class extends the TestScale class and is used for testing the bilinear interpolation inside the Scale operation.
* The first method tests the scale operation without the presence of a ROI or a No Data Range. The 2nd method introduces a
* ROI object calculated using a ROI RasterAccessor while the 3rd method uses an Iterator on the ROI Object. The 4th method
* performs the scale operation with all the components. The last method is similar to the 4th method but executes its operations
* on binary images.
*/
public class BilinearScaleTest extends TestScale{
@Test
public void testImageScaling() {
boolean roiPresent=false;
boolean noDataRangeUsed=false;
boolean isBinary=false;
boolean bicubic2DIsabled= true;
boolean useROIAccessor=false;
testGlobal(useROIAccessor,isBinary,bicubic2DIsabled,noDataRangeUsed
,roiPresent,InterpolationType.BILINEAR_INTERP, TestSelection.NO_ROI_ONLY_DATA,ScaleType.MAGNIFY);
testGlobal(useROIAccessor,isBinary,bicubic2DIsabled,noDataRangeUsed
,roiPresent,InterpolationType.BILINEAR_INTERP, TestSelection.NO_ROI_ONLY_DATA,ScaleType.REDUCTION);
}
@Test
public void testImageScalingROIAccessor() {
boolean roiPresent=true;
boolean noDataRangeUsed=false;
boolean isBinary=false;
boolean bicubic2DIsabled= true;
boolean useROIAccessor=true;
testGlobal(useROIAccessor,isBinary,bicubic2DIsabled,noDataRangeUsed
,roiPresent,InterpolationType.BILINEAR_INTERP,TestSelection.ROI_ACCESSOR_ONLY_DATA,ScaleType.MAGNIFY);
testGlobal(useROIAccessor,isBinary,bicubic2DIsabled,noDataRangeUsed
,roiPresent,InterpolationType.BILINEAR_INTERP,TestSelection.ROI_ACCESSOR_ONLY_DATA,ScaleType.REDUCTION);
}
@Test
public void testImageScalingROIBounds() {
boolean roiPresent=true;
boolean noDataRangeUsed=false;
boolean isBinary=false;
boolean bicubic2DIsabled= true;
boolean useROIAccessor=false;
testGlobal(useROIAccessor,isBinary,bicubic2DIsabled,noDataRangeUsed
,roiPresent,InterpolationType.BILINEAR_INTERP,TestSelection.ROI_ONLY_DATA,ScaleType.MAGNIFY);
testGlobal(useROIAccessor,isBinary,bicubic2DIsabled,noDataRangeUsed
,roiPresent,InterpolationType.BILINEAR_INTERP,TestSelection.ROI_ONLY_DATA,ScaleType.REDUCTION);
}
@Test
public void testImageScalingTotal() {
boolean roiPresent=true;
boolean noDataRangeUsed=true;
boolean isBinary=false;
boolean bicubic2DIsabled= true;
boolean useROIAccessor=true;
testGlobal(useROIAccessor,isBinary,bicubic2DIsabled,noDataRangeUsed
,roiPresent,InterpolationType.BILINEAR_INTERP,TestSelection.ROI_ACCESSOR_NO_DATA,ScaleType.MAGNIFY);
testGlobal(useROIAccessor,isBinary,bicubic2DIsabled,noDataRangeUsed
,roiPresent,InterpolationType.BILINEAR_INTERP,TestSelection.ROI_ACCESSOR_NO_DATA,ScaleType.REDUCTION);
}
@Test
public void testImageScalingBinary() {
boolean roiPresent=true;
boolean noDataRangeUsed=true;
boolean isBinary=true;
boolean bicubic2DIsabled= true;
boolean useROIAccessor=true;
testGlobal(useROIAccessor,isBinary,bicubic2DIsabled,noDataRangeUsed
,roiPresent,InterpolationType.BILINEAR_INTERP,TestSelection.BINARY_ROI_ACCESSOR_NO_DATA,ScaleType.MAGNIFY);
testGlobal(useROIAccessor,isBinary,bicubic2DIsabled,noDataRangeUsed
,roiPresent,InterpolationType.BILINEAR_INTERP,TestSelection.BINARY_ROI_ACCESSOR_NO_DATA,ScaleType.REDUCTION);
}
@Test
public void testInterpolationNoDataBleedByte() {
assertNoDataBleedByte(Interpolation.getInstance(Interpolation.INTERP_BILINEAR));
}
@Test
public void testInterpolationNoDataBleedShort() {
assertNoDataBleedShort(Interpolation.getInstance(Interpolation.INTERP_BILINEAR));
}
@Test
public void testInterpolationNoDataBleedFloat() {
assertNoDataBleedFloat(Interpolation.getInstance(Interpolation.INTERP_BILINEAR));
}
@Test
public void testInterpolationNoDataBleedDouble() {
assertNoDataBleedDouble(Interpolation.getInstance(Interpolation.INTERP_BILINEAR));
}
@Test
public void testInterpolateInHole() {
assertInterpolateInHole(Interpolation.getInstance(Interpolation.INTERP_BILINEAR));
}
}