use of mpicbg.util.Timer in project TrakEM2 by trakem2.
the class DownsamplerTest method main.
/**
* @param args
*/
public static void main(final String[] args) {
new ImageJ();
final Timer timer = new Timer();
final ImagePlus imp = new ImagePlus("/home/saalfeld/tmp/fetter-example.tif");
// final ImagePlus imp = new ImagePlus( "/home/albert/Desktop/t2/fetter-example.tif" );
// final ImagePlus imp = new ImagePlus( "/home/saalfeld/Desktop/norway.jpg" );
imp.show();
final ImageProcessor ip = imp.getProcessor().duplicate();
System.out.println("short");
final ShortProcessor ipShort = (ShortProcessor) ip.convertToShort(false);
for (int i = 0; i < n; ++i) {
timer.start();
testShort(ipShort);
final long t = timer.stop();
System.out.println(i + ": " + t + "ms");
}
System.out.println("downsampleShort() + downsampleByteProcessor() (independent short with byte mapping + alpha)");
for (int i = 0; i < n; ++i) {
final Pair<ShortProcessor, byte[]> ba = new Pair<ShortProcessor, byte[]>(ipShort, (byte[]) ipShort.convertToByte(true).getPixels());
final ByteProcessor alpha = new ByteProcessor(ipShort.getWidth(), ipShort.getHeight(), (byte[]) ipShort.convertToByte(true).getPixels(), null);
timer.start();
testShortAlphaIndependently(ba, alpha);
final long t = timer.stop();
System.out.println(i + ": " + t + "ms");
}
System.out.println("downsampleShortProcessor() + convertToByte() + downsampleByteProcessor() (independent short + byte mapping + alpha)");
for (int i = 0; i < n; ++i) {
final ByteProcessor alpha = new ByteProcessor(ipShort.getWidth(), ipShort.getHeight(), (byte[]) ipShort.convertToByte(true).getPixels(), null);
timer.start();
testShortAlphaByteMappingIndependently(ipShort, alpha);
final long t = timer.stop();
System.out.println(i + ": " + t + "ms");
}
System.out.println("float");
final FloatProcessor ipFloat = (FloatProcessor) ip.convertToFloat();
for (int i = 0; i < n; ++i) {
timer.start();
testFloat(ipFloat);
final long t = timer.stop();
System.out.println(i + ": " + t + "ms");
}
System.out.println("independent float with byte mapping + alpha");
for (int i = 0; i < n; ++i) {
final Pair<FloatProcessor, byte[]> ba = new Pair<FloatProcessor, byte[]>(ipFloat, (byte[]) ipShort.convertToByte(true).getPixels());
final ByteProcessor alpha = new ByteProcessor(ipShort.getWidth(), ipShort.getHeight(), (byte[]) ipShort.convertToByte(true).getPixels(), null);
timer.start();
testFloatAlphaIndependently(ba, alpha);
final long t = timer.stop();
System.out.println(i + ": " + t + "ms");
}
System.out.println("byte");
final ByteProcessor ipByte = (ByteProcessor) ip.convertToByte(true);
for (int i = 0; i < n; ++i) {
timer.start();
testByte(ipByte);
final long t = timer.stop();
System.out.println(i + ": " + t + "ms");
}
System.out.println("2 x byte");
final ByteProcessor ipByte2 = (ByteProcessor) ipByte.duplicate();
for (int i = 0; i < n; ++i) {
timer.start();
testByte(ipByte);
testByte(ipByte2);
final long t = timer.stop();
System.out.println(i + ": " + t + "ms");
}
System.out.println("color");
final ColorProcessor ipColor = (ColorProcessor) ip.convertToRGB();
for (int i = 0; i < n; ++i) {
timer.start();
testColor(ipColor);
final long t = timer.stop();
System.out.println(i + ": " + t + "ms");
}
System.out.println("independent color with byte mapping + alpha");
for (int i = 0; i < n; ++i) {
final byte[][] rgb = new byte[4][ipColor.getWidth() * ipColor.getHeight()];
ipColor.getRGB(rgb[0], rgb[1], rgb[2]);
final Pair<ColorProcessor, byte[][]> ba = new Pair<ColorProcessor, byte[][]>(ipColor, rgb);
final ByteProcessor alpha = new ByteProcessor(ipShort.getWidth(), ipShort.getHeight(), (byte[]) ipShort.convertToByte(true).getPixels(), null);
timer.start();
testColorAlphaIndependently(ba, alpha);
final long t = timer.stop();
System.out.println(i + ": " + t + "ms");
}
System.out.println("alpha + outside");
for (int i = 0; i < n; ++i) {
ByteProcessor outside = new ByteProcessor(ipByte.getWidth(), ipByte.getHeight());
outside.setRoi(new OvalRoi(100, 100, ipByte.getWidth() - 200, ipByte.getHeight() - 200));
outside.setValue(255);
outside.fill(outside.getMask());
final Pair<ByteProcessor, ByteProcessor> ba = new Pair<ByteProcessor, ByteProcessor>(ipByte, outside);
timer.start();
testAlphaOutside(ba);
final long t = timer.stop();
System.out.println(i + ": " + t + "ms");
}
System.out.println("outside");
for (int i = 0; i < n; ++i) {
ByteProcessor outside = new ByteProcessor(ipByte.getWidth(), ipByte.getHeight());
outside.setRoi(new OvalRoi(100, 100, ipByte.getWidth() - 200, ipByte.getHeight() - 200));
outside.setValue(255);
outside.fill(outside.getMask());
timer.start();
testOutside(outside);
final long t = timer.stop();
System.out.println(i + ": " + t + "ms");
}
// System.out.println( "byte integral" );
// final ByteProcessor ipByteI = ( ByteProcessor )ipShort.convertToByte( true );
//
// for ( int i = 0; i < 10; ++i )
// {
// timer.start();
// testByteIntegral( ipByteI );
// final long t = timer.stop();
// System.out.println( i + ": " + t + "ms" );
// }
}
Aggregations