kornia icon indicating copy to clipboard operation
kornia copied to clipboard

Implement `cv::integral`

Open edgarriba opened this issue 2 years ago • 2 comments

🚀 Feature

Implement the pytorch version of cv::integral

https://docs.opencv.org/4.6.0/d7/d1b/group__imgproc__misc.html#ga97b87bec26908237e8ba0f6e96d23e28

Some reference:

  • https://github.com/scikit-image/scikit-image/blob/main/skimage/transform/integral.py
  • https://discuss.pytorch.org/t/is-there-an-elegant-way-to-calculate-integral-image-using-pytorch-api/22669/5

Consider also to contribute to Kornia universe projects :)

  • Tutorials: our repository containing the tutorials.

edgarriba avatar Jun 30 '22 13:06 edgarriba

Hello. Some questions regarding this.

  1. Is the expected output a tensor with all values as sum of left values in its row and top values in its column?
  2. Which module does it go to?

AnimeshMaheshwari22 avatar Jul 02 '22 12:07 AnimeshMaheshwari22

well check the scikit implementation -- it can be easily implemented with cumsum /cc @ducha-aiki

def integral_image(image: Tensor) -> Tensor:
    S: Tensor = image
    S = S.cumsum(dim=-1)  # along columns
    S = S.cumsum(dim=-2)  # along rows
    return S

edgarriba avatar Jul 04 '22 11:07 edgarriba