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 findContours and related functions to the lib #859

Open
fmvin opened this issue Jan 9, 2020 · 15 comments
Open

Add findContours and related functions to the lib #859

fmvin opened this issue Jan 9, 2020 · 15 comments
Labels
enhancement Adds a new feature. help wanted

Comments

@fmvin
Copy link

fmvin commented Jan 9, 2020

Please add to the library similar functions existed in opencv "Structural Analysis and Shape Descriptors" to manipulate with contours:

  • findContours
  • boundingRect
  • contourArea
  • moments
  • etc
@Tokazama
Copy link

Tokazama commented Jan 9, 2020

@fmvin
Copy link
Author

fmvin commented Jan 9, 2020

Take a look at https://juliaimages.org/latest/function_reference/#Morphological-operations-1.

Thanks a lot. Could you please give any clue how to find contours and calculate each area in this question.

@Tokazama
Copy link

Tokazama commented Jan 9, 2020

I'm not really a CV expert so there may be a more optimized way of doing things, but until someone else jumps in here I'd suggest using https://juliaimages.org/latest/imagesegmentation/#ImageSegmentation.jl-1. The best (fastest/accurate) segmentation algorithm will depend on characteristics of the image you have. Once you have the segmented image you only need to count the number of pixels identified in the segmented region.

You can find a lot of this just by searching the docs (search box is in the top left corner).

@fmvin
Copy link
Author

fmvin commented Jan 10, 2020

Approaches you mentioned above are not "just from box" as it is in opencv. In opencv I take a color image and just call:

  1. cvtColor with cv::COLOR_BGR2GRAY
  2. findContours

And to analyse contour's shape:

  1. contourArea
  2. arcLength
  3. approxPolyDP
  4. boundingRect

This is all what I'm expecting from this lib.

@johnnychen94
Copy link
Member

johnnychen94 commented Jan 10, 2020

That might not be supported in the near future if there aren't any other people contributing to it. Images.jl has some functionalities to enable users to process images if they know how to achieve it, however, there's still a lot of work to do to provide a toolbox of all out-of-box algorithms for end-users; finetuning those algorithms isn't an easy task.

Tasks of higher priority at present as far as I understand are: polishing the core package ImageCore.jl, update the documentation and stabilize the core API for v1.0.

By saying this, we'd love to accept any PRs to https://github.com/JuliaImages/ImageFeatures.jl and https://github.com/JuliaImages/ImageSegmentation.jl

@johnnychen94 johnnychen94 added enhancement Adds a new feature. help wanted labels Jan 10, 2020
@timholy
Copy link
Member

timholy commented Jan 10, 2020

This is all what I'm expecting from this lib.

I'd urge you to distinguish "want" and "expect." I can understand why you want it, but why do you expect it? In open source, the availability of a feature comes down to some person who wants something deciding to donate their time and contribute it. If no one has done that yet for the features you need, your choices are to do it yourself or wait patiently until some kind soul does so. There should be no expectations that others will do your work for you for free.

@zygmuntszpak
Copy link
Member

zygmuntszpak commented Jan 10, 2020

I'm working on precisely this type of functionality over at ImageComponentAnalysis.jl

The current registered version supports the following:

Basic Measurements

  1. Area
  2. Perimeter

Basic Topology

  1. Euler number (4 connectivity)
  2. Euler number (8 connectivity)
  3. Bit Quad Patterns

Bounding Box

  1. Minimum Enclosing Rectangle
  2. Oriented Minimum Enclosing Rectangle

In the src/TODO folder you will find two implementations of contour tracing algorithms: costa_outer.jl and moore_inner.jl. There is also an implementation of a moment-based ellipse fit in region_ellipse.jl. I haven't yet integrated these functions properly into the package API, and I still have to decide on the convention for reporting the ellipse orientation. I am currently working on implementing a contour tracing algorithm that can determine its surrounding topological relation with other contours.

I intend to move the package to the JuliaImages repository once I have finished crafting the basic version.

@fmvin
Copy link
Author

fmvin commented Jan 10, 2020

@timholy

I'd urge you to distinguish "want" and "expect."

I apologise if I used inappropriate verb in this community ;) English is not my native language.

@Tokazama
Copy link

@fmvin I don't quite understand what you mean by "just from box". If you mean there is a single function that does what you want for each of those you already have some available. Like any toolbox or language (coding or spoken) there will be things that don't translate exactly. So I tried pointing you towards functions that do similar things. If you read the documentation you will find that most of those functionalities aren't difficult to perform on one's own with a couple lines of code. So if you are really familiar with OpenCV you might just have to think a little bit about what you're doing the first time you do it in Julia.

I apologise if I used inappropriate verb in this community ;) English is not my native language.

If the problem is that you need the docs in another language you can make a separate issue for that (even better make a PR helping solve the issue for others). Translation may even be a good way of getter better at both subjects at once if you're a student.

@fmvin
Copy link
Author

fmvin commented Jan 10, 2020

@Tokazama

If you read the documentation you will find that most of those functionalities aren't difficult to perform on one's own with a couple lines of code.

If this is so easy to do in 2 lines of code please tell then why @zygmuntszpak is working on this functionality right now. And you wrote 2 long post instead of 2 lines of code as example which helps at least 2 people to move forward in his tasks. Also it will be grateful to include your example to official docs ;)

@zygmuntszpak I'm waiting for your package with patience. Thanks a lot for your contribution.

@tomasBjornfot
Copy link

@aditi-dey29
Copy link

Has this issue been dealt with? If not I’ll like to work on implementing these functions. Should I start working?

@ashwani-rathee
Copy link
Member

Hey @aditi-dey29 , Thank you for showing interest in the issue. You can sure start working on it. I would suggest you to read the discussion above and join image processing channel in Julia slack to clear your doubts.

@aditi-dey29
Copy link

@ashwani-rathee thanks! just joined the channel.

@RiTomasBjornfot
Copy link

There is an very nice implementation of finding contours in images here: https://github.com/JuliaGeometry/Contour.jl
I have used it in several projects and it works excellent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Adds a new feature. help wanted
Projects
None yet
Development

No branches or pull requests

9 participants