Skip to content

Conversation

@greg-kennedy
Copy link
Contributor

@greg-kennedy greg-kennedy commented Aug 30, 2022

There are two errors with this example.

  • First, the kernel is incorrect. The center pixel should be weighted at 8, not 9.
  • Second, Laplacian output should be centered about the medium-brightness pixel value (0.5), and clamped to the 0 to 1.0 range. The previous version began sum at 0, leading to negative values in the output... Another way of presenting this would be to keep sum at 0, but add a sum = abs(sum); at line 48.

Fixed the errors and added a few more comments at the top.

EDIT: I should add that the previous version wasn't necessarily "wrong" - it was definitely a "high-pass filter" i.e. finding changes of intensity, as it says in the description - but that is a bit different than what people commonly call "edge detection".

There are two errors with this example. * First, the kernel is incorrect. The center pixel should be weighted at 8, not 9. * Second, Laplacian output should be centered about the medium-brightness pixel value (0.5), and clamped to the 0 to 1.0 range. The previous version began `sum` at 0, leading to negative values in the output... Another way of presenting this would be to keep `sum` at 0, but add a `sum = abs(sum);` at line 48. Fixed the errors and added a few more comments at the top.
@greg-kennedy
Copy link
Contributor Author

Someone should check the Javascript output and compare it to Java, it may actually be accurate now (and the comment about it being wrong could be removed)

@greg-kennedy
Copy link
Contributor Author

On second thought, closing this for now and will open an issue to discuss.

@SableRaf
Copy link
Collaborator

SableRaf commented Aug 30, 2022

From the original comment, it looks like the initial intention may have been to show how to sharpen an image rather than do literal Edge Detection.

This program analyzes every pixel in an image in relation to the neighboring pixels to sharpen the image.

For reference, here is the output for the original example:
image

And here is the output of the Laplacian Edge Detector as proposed by @greg-kennedy
image

I'm guessing the term "Edge Detection" may have been used loosely in the original example. How about changing the title of this example and making another pull request for a separate Edge Detection example?

@greg-kennedy
Copy link
Contributor Author

Continuing the discussion at issue #11 and if the proposal seems OK, I'll submit a new PR with changes soon :)

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

Labels

None yet

2 participants