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

Added Edge Detection module #168

Merged
merged 8 commits into from
Feb 16, 2018
Merged

Added Edge Detection module #168

merged 8 commits into from
Feb 16, 2018

Conversation

tech4GT
Copy link
Member

@tech4GT tech4GT commented Feb 9, 2018

image1_0

image1_1

@jywarren please have a look , right now exporting the edge detected image, will create a separate issue for adding support for json output, what say?

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>
@jywarren
Copy link
Member

jywarren commented Feb 9, 2018

Oh, this is cool! Could you try running it on the image here and writing back in that thread? I'd like to get some input from these folks:

https://publiclab.org/questions/jlev/02-01-2018/how-can-i-identify-bits-of-plastic-from-the-beach-in-an-image

This is so cool! @ccpandhare what do you think?

@tech4GT
Copy link
Member Author

tech4GT commented Feb 9, 2018

image1_1
@jywarren there is one limitation though, this only works with png images right now, but i will add support

@tech4GT
Copy link
Member Author

tech4GT commented Feb 9, 2018

@jywarren right now this is basic edge detection we can use algorithms like hysteresis to improve the quality of edge detection😁

@tech4GT
Copy link
Member Author

tech4GT commented Feb 9, 2018

@jywarren since jpg does not support transparency , can i convert an input jpg file to png and convert the output back to jpeg, will that be an acceptable solution?

@ccpandhare
Copy link
Collaborator

ccpandhare commented Feb 10, 2018 via email

@ccpandhare
Copy link
Collaborator

ccpandhare commented Feb 10, 2018 via email

@jywarren
Copy link
Member

jywarren commented Feb 10, 2018 via email

@tech4GT
Copy link
Member Author

tech4GT commented Feb 10, 2018

@jywarren @ccpandhare actually jpegs do not support transparency values and edge detection requires that
a values are 255 for each pixel in jpeg
I apologize for late reply

@tech4GT
Copy link
Member Author

tech4GT commented Feb 10, 2018

@jywarren should i post the complete code on the plastics question?

@jywarren
Copy link
Member

jywarren commented Feb 10, 2018 via email

@tech4GT
Copy link
Member Author

tech4GT commented Feb 10, 2018

@jywarren done😁

Copy link
Member

@jywarren jywarren left a comment

Choose a reason for hiding this comment

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

Ok, maybe we need to specify exactly what the output of the module is. It's a greyscale image?I guess I'm more accustomed to seeing edges as black pixels surrounding white regions but this is cool.

@tech4GT
Copy link
Member Author

tech4GT commented Feb 10, 2018

@jywarren right now i have just implemented Gaussian blur with sobel filter on the image after conversion to greyscale hence basic edge detection, i will implement remaining steps for canny edge detection in future which will finally output image with black edges surrounding white regions

@tech4GT
Copy link
Member Author

tech4GT commented Feb 10, 2018

@jywarren right now this outputs a greyscale image you are right😁

@jywarren
Copy link
Member

jywarren commented Feb 10, 2018 via email

@tech4GT
Copy link
Member Author

tech4GT commented Feb 10, 2018

@jywarren sure no problem but right now I don't have access to a computer I'll do it a bit later if that's fine?😅

@jywarren
Copy link
Member

jywarren commented Feb 10, 2018 via email

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>
@tech4GT
Copy link
Member Author

tech4GT commented Feb 10, 2018

@jywarren please have a look if anything else needs to be added, rest assured this is ready to be merged and i will surely open issues for enhancing this module and adding tests, thanks a lot😁

@tech4GT
Copy link
Member Author

tech4GT commented Feb 11, 2018

@jywarren is there anything else i can do in this😅

Copy link
Collaborator

@ccpandhare ccpandhare left a comment

Choose a reason for hiding this comment

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

Apart from this small thing, this looks fine to me!
What do you say, @jywarren?

@@ -0,0 +1,11 @@
{
"name": "Detect Edges",
"description": "Detects the edges in an image and outputs a a greyscale image with the canny method",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please fix the double "a" in the description field's value

Copy link
Collaborator

Choose a reason for hiding this comment

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

Again, I apologize for being that picky!

Copy link
Member Author

Choose a reason for hiding this comment

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

@ccpandhare no apologies needed in fact thank you for being so observant😁

@ccpandhare ccpandhare mentioned this pull request Feb 11, 2018
2 tasks
@ccpandhare
Copy link
Collaborator

Also, how would the edges thing work? Would it be like thresholding the greyscale output image of this module or would it have an entirely different approach?

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>
@tech4GT
Copy link
Member Author

tech4GT commented Feb 11, 2018

@ccpandhare i was thinking once i implement complete canny edge detection we can get the edge pixels and output the positions, what say?

@jywarren
Copy link
Member

Hi, this is looking really good; i wasn't previously familiar with how edge detection works, so I had to do some research to understand fully.

With that in mind, I think we might add this to the description just for clarity:

Edge detection: this module detects edges using the Canny method, which first Gaussian blurs the image to reduce noise (amount of blur configurable in settings as `options.blur`), then applies a number of steps to highlight edges, resulting in a greyscale image where the brighter the pixel, the stronger the detected edge. Read more at: https://en.wikipedia.org/wiki/Canny_edge_detector

Do we also allow setting the threshold? https://en.wikipedia.org/wiki/Canny_edge_detector#Parameters

Finally, the Wikipedia page shows a black background instead of alpha. Would it be possible to do this too? Then it'd work in JPG too.

This is really impressive work! Potentially we could base a Blur module off of components of this too!

@tech4GT
Copy link
Member Author

tech4GT commented Feb 15, 2018

@jywarren thanks a lot and yes we already have everything for the Gaussian blur so we can create a module for that.
secondly i am yet to implement all the steps of canny edge detection and hysteresis is one of them which takes the threshold values, hence i called this basic edge detection and i will create separate issue for adding the rest of the steps and i will shortly add them all
Thirdly the black background thing can be implemented after the rest of the steps are implemented which i am already working on and i will submit the PR in a week or so, i hope that's fine.

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>
@tech4GT
Copy link
Member Author

tech4GT commented Feb 15, 2018

@jywarren i have also taken care of the changes that @ccpandhare mentioned😁

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>
Signed-off-by: tech4GT <varun.gupta1798@gmail.com>
@tech4GT
Copy link
Member Author

tech4GT commented Feb 16, 2018

@jywarren finally done with this, this was a tough one😅. Full canny edge detection🎉

@tech4GT
Copy link
Member Author

tech4GT commented Feb 16, 2018

image1_1

@tech4GT
Copy link
Member Author

tech4GT commented Feb 16, 2018

@jywarren now this also takes low and high threshold and we also have a edge pixel positions array which can be exported as json as well

Signed-off-by: tech4GT <varun.gupta1798@gmail.com>
@jywarren
Copy link
Member

Hi, this sounds great and looks great. If you can make a follow-up issue to make the background black, and for any other follow-up issues, then this sounds good and I'm merging it in! Thanks!

@jywarren jywarren merged commit bbef4bc into publiclab:master Feb 16, 2018
@jywarren
Copy link
Member

I just wanted to say that this was a very impressive project! 🎉 🚀 👍

@tech4GT
Copy link
Member Author

tech4GT commented Feb 16, 2018

@jywarren thanks a lot😁

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.

3 participants