kornia
kornia copied to clipboard
Implement `cv::integral`
🚀 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.
Hello. Some questions regarding this.
- Is the expected output a tensor with all values as sum of left values in its row and top values in its column?
- Which module does it go to?
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