From 9a14555b66ca3441bd80cb7c2ac5d64386950f1e Mon Sep 17 00:00:00 2001 From: Cristian Goina Date: Tue, 13 Feb 2024 11:02:32 -0500 Subject: [PATCH] measure maxfilter processing time --- .../imageprocessing/ImageOperationsTest.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/colormipsearch-api/src/test/java/org/janelia/colormipsearch/imageprocessing/ImageOperationsTest.java b/colormipsearch-api/src/test/java/org/janelia/colormipsearch/imageprocessing/ImageOperationsTest.java index c6bfb6a9..dc4355d8 100644 --- a/colormipsearch-api/src/test/java/org/janelia/colormipsearch/imageprocessing/ImageOperationsTest.java +++ b/colormipsearch-api/src/test/java/org/janelia/colormipsearch/imageprocessing/ImageOperationsTest.java @@ -62,16 +62,19 @@ public void unsafeMaxFilterForRGBImage() { final int border = 0; ImageProcessing maxFilterProcessing = ImageProcessing.create() .unsafeMaxFilter(radius); + RankFilters maxFilter = new RankFilters(); for (int i = 0; i < 5; i++) { String testImageName = "src/test/resources/colormipsearch/api/imageprocessing/minmaxTest" + (i % 2 + 1) + ".tif"; ImagePlus testImage = new Opener().openTiff(testImageName, 1); ImageArray testMIP = ImageArrayUtils.fromImagePlus(testImage); + long startTime = System.currentTimeMillis(); ImageArray maxFilteredImage = maxFilterProcessing .applyTo(testMIP, border, border, border, border) .toImageArray(); - RankFilters maxFilter = new RankFilters(); + long endMaxFilterTime = System.currentTimeMillis(); maxFilter.rank(testImage.getProcessor(), radius, RankFilters.MAX); + long endIJ1MaxFilterTime = System.currentTimeMillis(); for (int r = border; r < testMIP.getHeight() - border; r++) { for (int c = border; c < testMIP.getWidth() - border; c++) { int j = r * testMIP.getWidth() + c; @@ -80,6 +83,8 @@ public void unsafeMaxFilterForRGBImage() { (maxFilteredImage.get(j) & 0x00FFFFFF)); } } + System.out.printf("MaxFilter time %f vs %f - IJ1 maxFilter time\n", + (endMaxFilterTime-startTime)/1000., (endIJ1MaxFilterTime-endMaxFilterTime)/1000.); } } @@ -88,16 +93,19 @@ public void maxFilterForRGBImage() { final int radius = 10; ImageProcessing maxFilterProcessing = ImageProcessing.create() .maxFilter(radius); + RankFilters maxFilter = new RankFilters(); for (int i = 1; i < 5; i++) { String testImageName = "src/test/resources/colormipsearch/api/imageprocessing/minmaxTest" + (i % 2 + 1) + ".tif"; ImagePlus testImage = new Opener().openTiff(testImageName, 1); ImageArray testMIP = ImageArrayUtils.fromImagePlus(testImage); + long startTime = System.currentTimeMillis(); ImageArray maxFilteredImage = maxFilterProcessing .applyTo(testMIP, 0, 0, 0, 0) .toImageArray(); - RankFilters maxFilter = new RankFilters(); + long endMaxFilterTime = System.currentTimeMillis(); maxFilter.rank(testImage.getProcessor(), radius, RankFilters.MAX); + long endIJ1MaxFilterTime = System.currentTimeMillis(); for (int r = 0; r < testMIP.getHeight(); r++) { for (int c = 0; c < testMIP.getWidth(); c++) { @@ -107,6 +115,8 @@ public void maxFilterForRGBImage() { (maxFilteredImage.get(j) & 0x00FFFFFF)); } } + System.out.printf("MaxFilter time %f vs %f - IJ1 maxFilter time\n", + (endMaxFilterTime-startTime)/1000., (endIJ1MaxFilterTime-endMaxFilterTime)/1000.); } }