Package java.awt.image

Examples of java.awt.image.Kernel


  public void testRaster2(TestHarness harness)
  {
    harness.checkPoint("testRaster2()");
    Raster src = createRasterA();
    WritableRaster dest = src.createCompatibleWritableRaster();
    Kernel k1 = new Kernel(3, 3, new float[] {0,0,0,
                                              0,1,0,
                                              0,0,0});
    ConvolveOp op = new ConvolveOp(k1, ConvolveOp.EDGE_ZERO_FILL, null);
    dest = op.filter(src, dest);
    harness.check(dest.getSample(0, 0, 0), 0);
View Full Code Here


  public void testRaster3(TestHarness harness)
  {
    harness.checkPoint("testRaster3()");
    Raster src = createRasterA();
    WritableRaster dest = src.createCompatibleWritableRaster();
    Kernel k1 = new Kernel(3, 3, new float[] {0.1f,0.2f,0.3f,
                                              0.4f,0.5f,0.6f,
                                              0.7f,0.8f,0.9f});
    ConvolveOp op = new ConvolveOp(k1, ConvolveOp.EDGE_NO_OP, null);
    dest = op.filter(src, dest);
    harness.check(dest.getSample(0, 0, 0), 1);
View Full Code Here

public class check implements Testlet
{
  public void test(TestHarness h)
  {
    float[] data = new float[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, };
    Kernel k = new Kernel(3, 4, data);
    h.check(k != null);
    h.check(k.getWidth() == 3);
    h.check(k.getHeight() == 4);
    h.check(k.getXOrigin() == 1);
    h.check(k.getYOrigin() == 1);

    float[] data1;
    try
      {
  data1 = k.getKernelData(null);
      }
    catch (IllegalArgumentException e)
      {
  data1 = new float[0];
  h.fail("Kernel.getKernelData");
      }

    h.checkPoint("Check kernel data");
    boolean ok = true;
    h.check(data1.length == data.length);
    for (int i=0; i < data1.length; i++)
      if (data[i] != data1[i])
  {
    ok = false;
    break;
  }
    h.check(ok == true);

    data1 = new float[12];
    try
      {
  data1 = k.getKernelData(data1);
      }
    catch (IllegalArgumentException e)
      {
  h.fail("Kernel.getKernelData");
      }

    ok = true;
    h.check(data1.length == data.length);
    for (int i=0; i < data1.length; i++)
      if (data[i] != data1[i])
  {
    ok = false;
    break;
  }
    h.check(ok == true);
   
    // Check failure modes
    h.checkPoint("Failure modes");
    ok = false;
    try
      {
  k.getKernelData(new float[1]);
      }
    catch (IllegalArgumentException e)
      {
  ok = true;
      }
    h.check(ok == true);

    ok = false;
    try
      {
  k = new Kernel(10, 10, data);
      }
    catch (IllegalArgumentException e)
      {
  ok = true;
      }
    h.check(ok == true);

    // Check that only the specified data gets copied
    data = new float[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14};
    k = new Kernel(3, 4, data);
    data1 = k.getKernelData(null);
    h.check(data1.length == 12);
    ok = true;
    for (int i=0; i < data1.length; i++)
      if (data[i] != data1[i])
  {
View Full Code Here

   *
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)     
  {
    Kernel k1 = new Kernel(1, 2, new float[] {1f, 2f});
    harness.check(k1.getWidth(), 1);
  }
View Full Code Here

   */
  public void test(TestHarness harness)      
  {
    float[] d1 = new float[] {1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f,
            9f, 10f, 11f, 12f, 13f, 14f, 15f};
    Kernel k1 = new Kernel(3, 5, d1);
    float[] d2 = k1.getKernelData(null);
    harness.check(d1 != d2);
    harness.check(Arrays.equals(d1, d2));
 
    // try argument length too short
    boolean pass = false;
    try
    {
      d2 = new float[14];
      d2 = k1.getKernelData(d2);
    }
    catch (IllegalArgumentException e)
    {
      pass = true;  
    }
View Full Code Here

   *
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)      
  {
    Kernel k1 = new Kernel(3, 4, new float[] {1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f,
            9f, 10f, 11f, 12f});
    harness.check(k1.getYOrigin(), 1);
    Kernel k2 = new Kernel(4, 3, new float[] {1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f,
            9f, 10f, 11f, 12f});
    harness.check(k2.getYOrigin(), 1);
    Kernel k3 = new Kernel(5, 2, new float[] {1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f,
            9f, 10f});
    harness.check(k3.getYOrigin(), 0);
  }
View Full Code Here

   */
  public void test(TestHarness harness)     
  {
    float[] d1 = new float[] {1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f,
            9f, 10f, 11f, 12f, 13f, 14f, 15f};
    Kernel k1 = new Kernel(3, 5, d1);
    harness.check(k1.getWidth(), 3);
    harness.check(k1.getHeight(), 5);
    harness.check(k1.getXOrigin(), 1);
    harness.check(k1.getYOrigin(), 2);
   
    // changing source data array shouldn't change the kernel
    d1[0] = Float.NaN;
    float[] d2 = k1.getKernelData(null);
    harness.check(!Float.isNaN(d2[0]));
   
    // try negative width - the required behaviour is not specified, the
    // reference implementation throws a NegativeArraySizeException, but that
    // seems like an implementation detail so this test is going to allow an
    // IllegalArgumentException as well (which is what GNU Classpath does).
    boolean pass = false;
    try
    {
      k1 = new Kernel(-1, 2, new float[] {1f, 2f});
    }
    catch (NegativeArraySizeException e)
    {
      pass = true;  
    }
    catch (IllegalArgumentException e)
    {
      pass = true;
    }
    harness.check(pass);
   
    // try negative height - the required behaviour is not specified, the
    // reference implementation throws a NegativeArraySizeException, but that
    // seems like an implementation detail so this test is going to allow an
    // IllegalArgumentException as well (which is what GNU Classpath does).
    pass = false;
    try
    {
      k1 = new Kernel(1, -2, new float[] {1f, 2f});
    }
    catch (NegativeArraySizeException e)
    {
      pass = true;  
    }
    catch (IllegalArgumentException e)
    {
      pass = true;
    }
    harness.check(pass);
   
    // try null array
    pass = false;
    try
    {
      k1 = new Kernel(1, 2, null);
    }
    catch (NullPointerException e)
    {
      pass = true;  
    }
View Full Code Here

   *
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)      
  {
    Kernel k1 = new Kernel(3, 4, new float[] {1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f,
            9f, 10f, 11f, 12f});
    harness.check(k1.getXOrigin(), 1);
    Kernel k2 = new Kernel(4, 3, new float[] {1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f,
            9f, 10f, 11f, 12f});
    harness.check(k2.getXOrigin(), 1);
    Kernel k3 = new Kernel(5, 2, new float[] {1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f,
            9f, 10f});
    harness.check(k3.getXOrigin(), 2);
  }
View Full Code Here

public class getEdgeCondition implements Testlet
{
  public void test(TestHarness harness)
  {
    Kernel k1 = new Kernel(3, 3, new float[] {1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f,
            9f});
    ConvolveOp op = new ConvolveOp(k1, ConvolveOp.EDGE_NO_OP, null);
    harness.check(op.getEdgeCondition(), ConvolveOp.EDGE_NO_OP);
    op = new ConvolveOp(k1, ConvolveOp.EDGE_ZERO_FILL, null);
    harness.check(op.getEdgeCondition(), ConvolveOp.EDGE_ZERO_FILL);
View Full Code Here

   *
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)     
  {
    Kernel k1 = new Kernel(1, 2, new float[] {1f, 2f});
    harness.check(k1.getHeight(), 2);
  }
View Full Code Here

TOP

Related Classes of java.awt.image.Kernel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.