Posted by
Stephan Saalfeld on
URL: http://imagej.273.s1.nabble.com/Computing-a-neighborhood-window-efficiently-tp3685960p3685970.html
Hi,
getting the sum or mean of arbitrarily large rectangles can be
accelerated by preprocessing the image into an integral image:
http://en.wikipedia.org/wiki/Summed_area_tableThat way, accessing the sum is constant in time, namely 4 add
operations:
I(x_max,y_max) + I(x_min,y_min) - I(x_min,y_max) - I(x_max,y_min)
Note that you have to make sure that this will get you quite large
numbers which requires storing them in a larger type (e.g. summing up
bytes into byte wouldn't work, you would have to go for short, int or
long). No insertion or replacement required, that is you can use []
instead of Collections which, in Java, is almost always faster and
allows you to not use Objects but basic types that do not acquire space
in the heap.
Do that first and later check how to optimize the code.
Good luck,
Stephan
On Sun, 2011-01-16 at 03:36 -0800, Serafino wrote: