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

how to apply a convolution to 2D array #2

Open
jobo322 opened this issue Jul 15, 2020 · 1 comment
Open

how to apply a convolution to 2D array #2

jobo322 opened this issue Jul 15, 2020 · 1 comment

Comments

@jobo322
Copy link
Member

jobo322 commented Jul 15, 2020

May be the answer is obvious but I did not get the same result between ml-matrix-convolution and ml-convolution packages, so It need your help please.

I want to use this kernel

const smallFilter = [
  [0, 0, 1, 2, 2, 2, 1, 0, 0],
  [0, 1, 4, 7, 7, 7, 4, 1, 0],
  [1, 4, 5, 3, 0, 3, 5, 4, 1],
  [2, 7, 3, -12, -23, -12, 3, 7, 2],
  [2, 7, 0, -23, -40, -23, 0, 7, 2],
  [2, 7, 3, -12, -23, -12, 3, 7, 2],
  [1, 4, 5, 3, 0, 3, 5, 4, 1],
  [0, 1, 3, 7, 7, 7, 3, 1, 0],
  [0, 0, 1, 2, 2, 2, 1, 0, 0]
];

I understand that ml-convolution only accept 1D array so I flatten all. Is it the correct procedure?

note: would be great to be able to pass directly the 2D arrays for input data and kernel

@targos
Copy link
Member

targos commented Jul 15, 2020

This package is for 1D convolution and doesn't support 2D arrays. It is possible to use it as an optimization for 2D if the kernel is separable, like we do here for images, but I'm not aware of a general way that could be implemented here directly.

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

No branches or pull requests

2 participants