-
Notifications
You must be signed in to change notification settings - Fork 150
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
grayscale morphology operators support #581
grayscale morphology operators support #581
Conversation
i have completed the documentation for all the user-facing functions, just have the testing left |
i have a question regarding what happens when a mask intersected with the image is empty.
but in my opinion it isn't necessary, and some users might want a mask that doesn't include the center. |
different behaviors could be :
|
after thinking about it, i realized the answer to "what happens when the intersection of a mask with the image is empty" is obvious. (u8, min) and (u8, max) are both groups, therefore min({}) and max({}) are well defined, and they are the neutral elements of min and max respectively. therefore i'm going to fix this and add tests concerning this aspect |
Co-authored-by: theotherphil <[email protected]>
…440/imageproc into greyscale_morphology_operators
i sometime struggle between returning a result and panicking. other than that, i feel like, after it is fully reviewed, it would make sense to push this PR as it is, and make another on the subject of optimisation. what's your opinion ? |
Why do you need a Mask in a public API? |
So It's actually an |
If the mask were a LumaA Image, the user would have more freedom and we would have less code I think |
i understand the idea, but the Mask is not just an giving the users a |
i will try to think more on a Maskless implementation though |
but the reasons i made the struct at the start are also because (1) it felt reasonable to have a distinct struct because mask aren't the same as images, and more importantly (2) that way we could have control on how the mask is laid out in memory, for optimization later on. the first argument is very subjective i will admit, but the second one feel like it makes sense to me. to be clear, from my (admittedly limited) experience working with mathematical morphology, it should be very rare for users to make masks from images, and almost unthinkable to make masks bigger than 20 by 20. so when the user writes let eroded = grayscale_erode(&image, &Mask::diamond(3)); it doesn't really matter to them what kind of struct Mask is. what is affected user-side from the existence or not of the
pub fn grayscale_dilate(image: &GrayImage, mask: &Mask) -> GrayImage feels cleaner to me than pub fn grayscale_dilate(image: &GrayImage, mask: &GrayImage) -> GrayImage but that's subjective and not a big deal.
dev-side, removing the struct would remove the i think that's roughly a good view of the subject. i will admit i'm probably a bit biased toward wanting to keep the struct, but ultimately i'd understand if you feel it's best to remove it. |
3 masks makers can be functions that return an alpha image, for example |
Maybe you can keep |
that is what i meant by "the 3 mask makers would still be needed if we removed the struct" the functions would still be there, just not in an impl block |
that is definitely part of my thinking |
…isation-focused PR)
would it be good to merge as-is ? |
The docs need a bit of work but that can happen before the next release of this crate. The behaviour looks correct. Thanks! |
this PR has been made following the issue #576 : support grayscale morphology operators
this PR seeks to add new function to the
morphology
module that complement the current ones.the current function only support
binary morphology
, and the new functions will add support forgrayscale morphology
.to do so, i have added a new struct
Mask
, that can representations masks of arbitrary shape.at original time of making this PR, i have 1 commit, that implements the
Mask
struct and all the functions i originally thought of making. on the other hand, i have written very little documentation, and no tests, which is what i'm going to be working on next. i would really appreciate any feedback on the code i've written so far