-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2D Tophat (Disk) Kernel #165
base: master
Are you sure you want to change the base?
Conversation
Bumping this |
I think this can be tested in a |
This implementation is based off the skimage.draw.disk implementation which is used in the python library which inspired this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, see my above remarks and some tests would be good.
@@ -416,6 +417,34 @@ moffat(α::Real, β::Real) = moffat(α, β, ceil(Int, (α*2*sqrt | |||
sum(x.^2) | |||
end | |||
|
|||
""" | |||
tophat(r) -> k | |||
tophat(r, ls) -> k |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename ls
to size
and explain it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also some doctests would be nice.
kern[idx] = amplitude | ||
end | ||
end | ||
return kern ./ sum(kern) # renormalize |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you compute amplitude above, if you normalize it away here anyway?
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
aretophat(r)
- default size is2r
rounded up to the nearest odd integer. The cells whose distance from the center is less than or equal tor
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 sizels
. 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 tor
will be a normalized constant.I've added a docstring and imported correctly under
ImageFiltering.jl
. I've added it to theKernel
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.