JuliaImages / ImageFiltering.jl

Julia implementations of multidimensional array convolution and nonlinear stencil operations
Other
99 stars 51 forks source link

demo: maxmin filter examples #189

Closed johnnychen94 closed 3 years ago

johnnychen94 commented 3 years ago

Took a quick look at [1] and I feel this is worth a demonstration card.

References:

[1] Verbeek, P. W., Vrooman, H. A., & Van Vliet, L. J. (1988). Low-level image processing by max-min filters. Signal Processing, 15(3), 249-258.

timholy commented 3 years ago

Pretty cool. And mapwindow is really efficient thanks to the Lemire filters.

Dsantra92 commented 3 years ago

Can I work on this ?

johnnychen94 commented 3 years ago

Yes, of course!

We are plan to host hacktoberfest locally in JuliaCN during Oct 17-18, so if you're going to work on this, please submit an early PR to notify other potential participants.

Dsantra92 commented 3 years ago

@johnnychen94 is a pr within this week is okay?

Dsantra92 commented 3 years ago

@johnnychen94 @timholy just a few set of questions.

  1. Firstly I found 2 ways to find minmax, one was to use extrema and other was to use maximum on top of minimum.Both using mapwindow.I found extrema to be very efficient but I had to go with minimum+maximum because extracting min or max filtered images of extrema also incurrs some cost, or am I missing an easy way to do so ?

  2. I have done the maxmin, minmax, min and max filters.Are there any more implementations you would like to add ?

johnnychen94 commented 3 years ago

I'm surprised that extrema even works. The performance difference might be explained because extrema is written in a more efficient way while maximum is actually implemented as mapreduce(identity, max, img). You could use @which maximum(patch) to check where it's defined.

I suggest still using minimum and maximum in the demo because this performance difference, if needed, should be fixed upstream.

FYI, mapwindow! can be used to reduce additional memory allocation when you have successive filters.

I have done the maxmin, minmax, min and max filters.Are there any more implementations you would like to add ?

I don't have specific ideas in mind, if you have good ideas, feel free to add them.

I haven't check it yet, https://github.com/sairus7/MaxMinFilters.jl sounds like a promising functionality to be added into ImageFiltering.

johnnychen94 commented 3 years ago

Added in #190

timholy commented 3 years ago

In this case extrema is just being used for dispatch---it's not really running extrema per se. The point is that the Lemire algorithm requires that both the min and max be extracted---it's integral to the computation itself.

You can easily "extract" one or the other this way:

minmax = mapwindow(extrema, img, window)
imgmin = map(first, minmax)
imgmax = map(last, minmax)

You could alternatively use MappedArrays and do the latter "lazily" (which would be especially nice for big data).

johnnychen94 commented 3 years ago

So obviously a fact that I did not realize! I thought without a second concluded that two map(first, ) is more expensive than mapwindow(maximum, ) :joy: I should really benchmark things.