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

Feature request: adding EDGE option to filter() for edge detection #2747

Closed
BenjaminHabert opened this Issue Mar 28, 2018 · 4 comments

Comments

Projects
None yet
3 participants
@BenjaminHabert
Copy link
Contributor

BenjaminHabert commented Mar 28, 2018

Edge detection could be interesting to create interactive experiments with the webcam. This would provide an easy way to locate stuff in the webcam feet.

This could be added to the list of options of the filter() function.

I am not sure about implementation details though. I can start investigate.

Nature of issue?

  • Found a bug
  • Existing feature enhancement
  • New feature request

Most appropriate sub-area of p5.js?

  • Color
  • Core
  • Data
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • Other (specify if possible)

New feature details:

TODO

Resources

Some infos and implementations of edge detection

@BenjaminHabert BenjaminHabert changed the title Feature request: adding EDGE option to filter for edge detection Feature request: adding EDGE option to filter() for edge detection Mar 28, 2018

@aatishb

This comment has been minimized.

Copy link
Contributor

aatishb commented Mar 30, 2018

In case it's helpful, this is a nice set of p5 computer vision demos as well (mostly using other computer vision libraries).

@BenjaminHabert

This comment has been minimized.

Copy link
Contributor

BenjaminHabert commented Mar 31, 2018

Thanks! In this case I think it is better to keep a simple implementation to stay consistent with the rest of the filters.

Here is the standard method of edge detection:

  1. Apply a gaussian smoothing (already implemented by img.filter(BLUR))
  2. Compute the intensity gradient using a convolution with a 3x3 kernel (Sobel / Prewitt)
  3. Perform edge thinning. I am not sure but I think this is similar to what img.filter(ERODE) does
  4. Apply threshold to have only white edges on black background (img.filter(THRESHOLD))

Consequently most of the process is already implemented as filters. I propose to do the following:

  • implement an img.filter(SOBEL) filter (step 2)
  • (maybe): implement an img.filter(EDGES) filter that would only be a combination of other existing filters.

This way a user would have the option to use EDGES for a quick result but could also customize the different steps of edge detection using the combination of BLUR, SOBEL, ERODE and THRESHOLD mentioned above

What do you think ? Also: what are the requirements in term of performance? I fear that applying 4 filters in succession will be quite demanding cpu-wise.

@BenjaminHabert

This comment has been minimized.

Copy link
Contributor

BenjaminHabert commented Mar 31, 2018

I created a toy example implementing the proposed method of chaining filters. Please try it out and let me know what you think.

I could also try to use the POSTERIZE filter..

edge_detection

Also I found interesting that filter(BLUR, 0) still does some heavy computation although radius=0 should mean that no blurring is done. I disabled this computation in the example for r=0.

@lmccart

This comment has been minimized.

Copy link
Member

lmccart commented Apr 22, 2018

I'd prefer to leave this one for an addon library, or offload to some of the great cv libraries already out there that you've linked to.

@lmccart lmccart closed this Aug 13, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment