Skip to content
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

add imfill function #9

Merged
merged 10 commits into from
May 30, 2019
Merged

add imfill function #9

merged 10 commits into from
May 30, 2019

Conversation

aquatiko
Copy link
Contributor

This function can be used to fill objects of a certain size with some specified value.
@juliohm Also I am thinking of adding a parameter descriptors, which when true will give some stats of the connected components like: their sizes, their centeroid etc. What's your opinion on this?

Copy link
Member

@juliohm juliohm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a first round of comments. Please take a look and let me know what you think.

src/imfill.jl Outdated Show resolved Hide resolved
src/imfill.jl Outdated Show resolved Hide resolved
src/imfill.jl Outdated Show resolved Hide resolved
src/ImageMorphology.jl Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Dec 30, 2018

Codecov Report

Merging #9 into master will increase coverage by 1.11%.
The diff coverage is 90%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master       #9      +/-   ##
==========================================
+ Coverage   91.76%   92.88%   +1.11%     
==========================================
  Files           5        6       +1     
  Lines         243      253      +10     
==========================================
+ Hits          223      235      +12     
+ Misses         20       18       -2
Impacted Files Coverage Δ
src/ImageMorphology.jl 100% <ø> (ø) ⬆️
src/imfill.jl 90% <90%> (ø)
src/connected.jl 88.54% <0%> (+2.29%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e07632e...e31ce6a. Read the comment docs.

@codecov
Copy link

codecov bot commented Dec 30, 2018

Codecov Report

Merging #9 into master will decrease coverage by 44.3%.
The diff coverage is 0%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master       #9       +/-   ##
===========================================
- Coverage     100%   55.69%   -44.31%     
===========================================
  Files           2        3        +1     
  Lines          44       79       +35     
===========================================
  Hits           44       44               
- Misses          0       35       +35
Impacted Files Coverage Δ
src/imfill.jl 0% <0%> (ø)
src/thinning.jl 57.57% <0%> (-42.43%) ⬇️
src/dilation_and_erosion.jl 83.33% <0%> (-16.67%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 43b3d0e...fbc0e1d. Read the comment docs.

src/imfill.jl Outdated Show resolved Hide resolved
src/imfill.jl Outdated Show resolved Hide resolved
src/imfill.jl Outdated Show resolved Hide resolved
@aquatiko aquatiko force-pushed the imfill branch 2 times, most recently from a387b33 to 976089b Compare January 3, 2019 14:38
Copy link
Member

@juliohm juliohm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More comments to improve code readability and performance.

src/imfill.jl Outdated Show resolved Hide resolved
src/imfill.jl Outdated Show resolved Hide resolved
Copy link
Member

@timholy timholy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

src/imfill.jl Outdated Show resolved Hide resolved
src/imfill.jl Outdated Show resolved Hide resolved
src/imfill.jl Outdated Show resolved Hide resolved
@aquatiko
Copy link
Contributor Author

aquatiko commented Jan 4, 2019

@timholy @juliohm I noticed in JuliaImages doc that the function find_boundaries is not listed for Julia. I would like to implement it(If not already implemented in Julia). Also, for it's purpose I would like to implement something similar to generate_binary_structures from scipy and numpy.indices.
So, I am not sure if this functions exists somewhere in Julia and if not, then under which repo each of them should be implemented?

@juliohm
Copy link
Member

juliohm commented Jan 4, 2019

I think the code is ready 👌 We only need to clarify in the docstring the 1s vs. 0s convention we are adopting. @timholy do you have additional suggestions?

@aquatiko regarding the other contributions you have in mind, I suggest opening a new issue on Images.jl pointing to the references and/or similar software that implements the functions you mentioned. Feel free to ping me there as well. :)

@juliohm
Copy link
Member

juliohm commented Jan 4, 2019

@aquatiko after you fix the docstring as suggested, could you also add a few tests for this new function?

@aquatiko
Copy link
Contributor Author

aquatiko commented Jan 6, 2019

@juliohm I have made the asked changes and added some tests. But the tests seems to fail, although they are working fine locally.

Copy link
Member

@juliohm juliohm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aquatiko thank you for incorporating the suggestions. For some reason, GitHub is telling me that the commit you made with tests is not part of the PR. Could you please double check that you are following the standard process of PR updates?

Also, if you can add a test for corner cases with images that are full of 1s and full of 0s, it is always good to have these tested.

src/imfill.jl Outdated
function imfill(img::AbstractArray{Bool}, interval::Tuple{Real,Real}, connectivity::Union{Dims, AbstractVector{Int}, BitArray}=1:ndims(img))

if interval[1] > interval[2] || interval[1] < 0 || interval[2] < 0
print("Invalid Interval")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is idiomatic to throw an error instead. Could you please use @assert or a more specific error type in Julia? https://docs.julialang.org/en/v1.0/manual/control-flow/#Exception-Handling-1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@juliohm I have added some more tests. But they seem to be failing as: imfill uses label_components from package Images and it is not included during testing.

ERROR: LoadError: ArgumentError: Package Images not found in current path:
- Run `Pkg.add("Images")` to install the Images package.

Can u guide me how to fix this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question @aquatiko. In cases like this, we would either migrate label_components to somewhere else in the Images.jl project, or migrate imfill. I personally like to think of Images.jl as a metapackage that loads the actual submodules of image processing and analysis. In that case, I defend the point that we should migrate label_components to somewhere else. What is your opinion on this @timholy? Do you have a suggestion on where we could migrate things so that the project is better structured?

@aquatiko every now and then this happens, and we move things around to achieve a better separation of concepts across packages.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timholy did you have a chance to look into this? Can we migrate label_components to somewhere else? Maybe here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyone has an opinion on this? What should be the reorganization here? I vote to move label_components to some sub-package of Images.jl, not sure where it should go though, if here or some new package like ImageGraphs.jl

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Julio,

I am working on bringing the entire Images ecosystem into a new unified API. For an example see: https://github.com/zygmuntszpak/ImageContrastAdjustment.jl.

I'm also currently working on an ImageComponentAnalysis package in collaboration with some great undergraduate students (https://github.com/zygmuntszpak/ImageComponentAnalysis.jl). The current label_components would be a natural fit for that package. However, its API would change slightly. It would be associated with the algorithm Generic(), that is, label_components(Generic(), ...). This is to differentiate it from other component labelling algorithms such as contour tracking, i.e. label_components(ContourTracking(),...) which are 2D only and assume 8-connectivity.

The ImageComponentAnalysis is under active development, so not yet ready to be tagged.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lovely @zygmuntszpak ! I am looking forward to see the results. ❤️ Do you have the unified API documented somewhere already? I may have missed the recent discussions on the issue tracker.

You mean that the entire Images.jl project is under a major reorganization of concepts?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We started a discussion here: JuliaImages/Images.jl#772 but I haven't updated my latest thought there yet. Because some things in Images are so intertwined, and because the API means breaking changes etc. I decided that I would just quietly work on trying to get everything into one cohesive hole and once there is something tangible but unified, let people make recommendations for changes to details such as function names, argument order etc.

@aquatiko
Copy link
Contributor Author

@juliohm Should we fix the tests by adding Pkg.add("Images") to the CI files for now?

@juliohm
Copy link
Member

juliohm commented Feb 11, 2019 via email

@tlnagy
Copy link
Contributor

tlnagy commented May 16, 2019

It would be great to have this feature as it one of the few in the comparison table that has no Julia equivalent: https://juliaimages.org/latest/api_comparison/

@johnnychen94
Copy link
Member

johnnychen94 commented May 22, 2019

Since label_components is ported to ImageMorphology, we can continue this PR.

Future devs on label_components can be here as well.

test/runtests.jl Outdated Show resolved Hide resolved
@aquatiko
Copy link
Contributor Author

@juliohm Is it good for merging now?

@johnnychen94 johnnychen94 merged commit 32427ca into JuliaImages:master May 30, 2019
@johnnychen94
Copy link
Member

johnnychen94 commented May 30, 2019

Previous comments are already resolved; merge it since the test is passed without introducing Images.jl dependency.

P.S. I made some edits on indentation and typos such as True => true.

johnnychen94 added a commit to JuliaImages/juliaimages.github.io that referenced this pull request May 30, 2019
@juliohm
Copy link
Member

juliohm commented May 31, 2019 via email

@aquatiko aquatiko deleted the imfill branch June 2, 2019 02:57
johnnychen94 pushed a commit that referenced this pull request May 21, 2022
This function can be used to fill objects of a certain size with some specified value.
johnnychen94 pushed a commit that referenced this pull request May 21, 2022
This function can be used to fill objects of a certain size with some specified value.
johnnychen94 pushed a commit that referenced this pull request May 21, 2022
This function can be used to fill objects of a certain size with some specified value.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants