|
11 | 11 | * %%
|
12 | 12 | * Redistribution and use in source and binary forms, with or without
|
13 | 13 | * modification, are permitted provided that the following conditions are met:
|
14 |
| - * |
| 14 | + * |
15 | 15 | * 1. Redistributions of source code must retain the above copyright notice,
|
16 | 16 | * this list of conditions and the following disclaimer.
|
17 | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice,
|
18 | 18 | * this list of conditions and the following disclaimer in the documentation
|
19 | 19 | * and/or other materials provided with the distribution.
|
20 |
| - * |
| 20 | + * |
21 | 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
22 | 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
23 | 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
33 | 33 | */
|
34 | 34 | package net.imglib2.algorithm.blocks.downsample;
|
35 | 35 |
|
36 |
| -import bdv.export.DownsampleBlock; |
37 |
| -import java.util.Arrays; |
38 | 36 | import java.util.concurrent.TimeUnit;
|
39 | 37 | import java.util.concurrent.atomic.AtomicLong;
|
40 | 38 | import java.util.stream.Collectors;
|
41 | 39 | import java.util.stream.IntStream;
|
42 |
| -import net.imglib2.Cursor; |
43 |
| -import net.imglib2.IterableInterval; |
44 |
| -import net.imglib2.RandomAccess; |
45 |
| -import net.imglib2.RandomAccessible; |
46 |
| -import net.imglib2.RandomAccessibleInterval; |
47 |
| -import net.imglib2.algorithm.blocks.BlockSupplier; |
48 |
| -import net.imglib2.algorithm.blocks.ComputationType; |
49 |
| -import net.imglib2.algorithm.blocks.downsample.Downsample.Offset; |
50 |
| -import net.imglib2.algorithm.blocks.BlockAlgoUtils; |
51 |
| -import net.imglib2.cache.img.CachedCellImg; |
52 |
| -import net.imglib2.cache.img.CellLoader; |
53 |
| -import net.imglib2.cache.img.ReadOnlyCachedCellImgFactory; |
54 |
| -import net.imglib2.cache.img.ReadOnlyCachedCellImgOptions; |
55 |
| -import net.imglib2.img.array.ArrayImgs; |
56 |
| -import net.imglib2.img.cell.AbstractCellImg; |
57 |
| -import net.imglib2.parallel.Parallelization; |
58 |
| -import net.imglib2.parallel.TaskExecutor; |
59 |
| -import net.imglib2.type.numeric.integer.UnsignedByteType; |
60 |
| -import net.imglib2.view.Views; |
| 40 | + |
61 | 41 | import org.openjdk.jmh.annotations.Benchmark;
|
62 | 42 | import org.openjdk.jmh.annotations.BenchmarkMode;
|
63 | 43 | import org.openjdk.jmh.annotations.Fork;
|
|
72 | 52 | import org.openjdk.jmh.runner.options.Options;
|
73 | 53 | import org.openjdk.jmh.runner.options.OptionsBuilder;
|
74 | 54 |
|
| 55 | +import net.imglib2.Cursor; |
| 56 | +import net.imglib2.IterableInterval; |
| 57 | +import net.imglib2.RandomAccessibleInterval; |
| 58 | +import net.imglib2.algorithm.blocks.BlockAlgoUtils; |
| 59 | +import net.imglib2.algorithm.blocks.BlockSupplier; |
| 60 | +import net.imglib2.algorithm.blocks.ComputationType; |
| 61 | +import net.imglib2.algorithm.blocks.downsample.Downsample.Offset; |
| 62 | +import net.imglib2.cache.img.CachedCellImg; |
| 63 | +import net.imglib2.img.array.ArrayImgs; |
| 64 | +import net.imglib2.img.cell.AbstractCellImg; |
| 65 | +import net.imglib2.parallel.Parallelization; |
| 66 | +import net.imglib2.parallel.TaskExecutor; |
| 67 | +import net.imglib2.type.numeric.integer.UnsignedByteType; |
| 68 | +import net.imglib2.view.Views; |
| 69 | + |
75 | 70 | @State( Scope.Benchmark )
|
76 | 71 | @Warmup( iterations = 3, time = 100, timeUnit = TimeUnit.MILLISECONDS )
|
77 | 72 | @Measurement( iterations = 10, time = 100, timeUnit = TimeUnit.MILLISECONDS )
|
@@ -101,32 +96,6 @@ public DownsampleBdvBenchmark()
|
101 | 96 | downsampledDimensions = Downsample.getDownsampledDimensions( raw.dimensionsAsLongArray(), downsampleInDim );
|
102 | 97 | }
|
103 | 98 |
|
104 |
| - @Benchmark |
105 |
| - public void benchmarkBdv() |
106 |
| - { |
107 |
| - RandomAccessible< UnsignedByteType > extended = Views.extendBorder( raw ); |
108 |
| - int[] downsamplingFactors = new int[ 3 ]; |
109 |
| - Arrays.setAll(downsamplingFactors, d -> downsampleInDim[ d ] ? 2 : 1 ); |
110 |
| - final DownsampleBlock< UnsignedByteType > downsampleBlock = DownsampleBlock.create( cellDimensions, downsamplingFactors, UnsignedByteType.class, RandomAccess.class ); |
111 |
| - final RandomAccess< UnsignedByteType > in = extended.randomAccess(); |
112 |
| - final long[] currentCellMin = new long[ 3 ]; |
113 |
| - final int[] currentCellDim = new int[ 3 ]; |
114 |
| - CellLoader< UnsignedByteType > downsampleBlockLoader = cell -> { |
115 |
| - Arrays.setAll( currentCellMin, d -> cell.min( d ) * downsamplingFactors[ d ] ); |
116 |
| - Arrays.setAll( currentCellDim, d -> ( int ) cell.dimension( d ) ); |
117 |
| - in.setPosition( currentCellMin ); |
118 |
| - downsampleBlock.downsampleBlock( in, cell.cursor(), currentCellDim ); |
119 |
| - }; |
120 |
| - final CachedCellImg< UnsignedByteType, ? > downsampled = new ReadOnlyCachedCellImgFactory().create( |
121 |
| - downsampledDimensions, |
122 |
| - new UnsignedByteType(), |
123 |
| - downsampleBlockLoader, |
124 |
| - ReadOnlyCachedCellImgOptions.options().cellDimensions( cellDimensions) ); |
125 |
| - |
126 |
| - touchAllCellsSingleThreaded( downsampled ); |
127 |
| - downsampled.getCache().invalidateAll(); |
128 |
| - } |
129 |
| - |
130 | 99 | @Benchmark
|
131 | 100 | public void benchmarkDownsampleDouble()
|
132 | 101 | {
|
|
0 commit comments