Skip to content

Commit

Permalink
measure maxfilter processing time
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristian Goina committed Feb 13, 2024
1 parent de0d681 commit 9a14555
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.);
}
}

Expand All @@ -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++) {
Expand All @@ -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.);
}
}

Expand Down

0 comments on commit 9a14555

Please sign in to comment.