Commit 92293bc4 authored by mey's avatar mey
Browse files

ConvolveOp.java: added another filter method for convenience

    updated test
    improved doc
parent 639d412d
......@@ -56,7 +56,8 @@ public class ConvolveOp implements Serializable {
/**
* Performs a convolution on a DoubleGrid2D. Each cell of the source grid
* will be convolved. The results are written into a copy of {@code src}.
* will be convolved. The results are written into a copy of {@code src} and
* returned .
*
* @param src
* the source grid
......@@ -68,8 +69,8 @@ public class ConvolveOp implements Serializable {
/**
* Performs a convolution on a DoubleGrid2D. Each cell of the source grid
* will be convolved. If the destination grid is <code>null</code> a copy of
* {@code src} will be created and used as destination.
* will be convolved. The results are written into a copy of {@code src} and
* returned.
*
* @param src
* the source grid
......@@ -81,6 +82,22 @@ public class ConvolveOp implements Serializable {
return filter(src, dest, null);
}
/**
* Performs a convolution only on the cells that are marked with a flag. If
* the destination grid is <code>null</code> a copy of {@code src} will be
* created and used as destination.
*
* @param src
* the source grid
* @param include
* the include grid containing a flag for every cell if it is to
* be included in the convolution
* @return the resulting grid {@code dest}
*/
public DoubleGrid2D filter(DoubleGrid2D src, BooleanGrid include) {
return filter(src, null, include);
}
/**
* Performs a convolution only on the cells that are marked with a flag. If
* the destination grid is <code>null</code> a copy of {@code src} will be
......
......@@ -76,17 +76,17 @@ public class ConvolveOpTest {
@Test
public void filterHorizontal() {
assertThat(new ConvolveOp(KERNEL_HORIZONTAL).filter(SINGLE_DOT_GRID, null).field, is(RESULT_HORIZONTAL));
assertThat(new ConvolveOp(KERNEL_HORIZONTAL).filter(SINGLE_DOT_GRID).field, is(RESULT_HORIZONTAL));
}
@Test
public void filterVertical() {
assertThat(new ConvolveOp(KERNEL_VERTICAL).filter(SINGLE_DOT_GRID, null).field, is(RESULT_VERTICAL));
assertThat(new ConvolveOp(KERNEL_VERTICAL).filter(SINGLE_DOT_GRID).field, is(RESULT_VERTICAL));
}
@Test
public void filterBox() {
assertThat(new ConvolveOp(KERNEL_BOX).filter(ISLAND_GRID, null).field, is(equalTo(RESULT_BOX)));
assertThat(new ConvolveOp(KERNEL_BOX).filter(ISLAND_GRID).field, is(equalTo(RESULT_BOX)));
}
@Test
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment