ImageFiltering.jl icon indicating copy to clipboard operation
ImageFiltering.jl copied to clipboard

2D Tophat (Disk) Kernel

Open mileslucas opened this issue 5 years ago • 3 comments

This adds a 2D "tophat" kernel. This is geometrically just a disk. I'm not an images guy, per se, so if there is a more apt name than tophat, please inform me!

The two functions added to Kernel are

  • tophat(r) - default size is 2r rounded up to the nearest odd integer. The cells whose distance from the center is less than or equal to r will be constant and all other will be zero. The constant will be such that the sum is 1.
  • tophat(r, ls) - the same as above, but allos user-input size ls. This will handle even and odd based shapes, and even mixes of both (eg (6, 7). Again, the pixels whose distance from the center is less than or equal to r will be a normalized constant.

I've added a docstring and imported correctly under ImageFiltering.jl. I've added it to the Kernel module docstring, too. Unfortunately I'm not having a great time parsing the test suite, so I don't have any tests. Please let me know where I can test this.

mileslucas avatar Apr 18 '20 09:04 mileslucas

Bumping this

mileslucas avatar May 12 '20 09:05 mileslucas

I think this can be tested in a @testset "tophat" in test/2d.jl. Is this tophat function coming from matlab or somehow standard? There are a lot of variantions on how to turn a circle into pixels. E.g. constant value strictly inside, value proportional to circle area intersected with pixel etc.

jw3126 avatar May 12 '20 10:05 jw3126

This implementation is based off the skimage.draw.disk implementation which is used in the python library which inspired this PR.

mileslucas avatar May 12 '20 11:05 mileslucas