# Kornia — full reference for language models

> Kornia is a differentiable computer vision library for PyTorch. Classic CV operations (color, filtering, geometric transforms, camera/epipolar geometry, augmentation) are implemented as batched, GPU-ready, autograd-friendly tensor operations. Everything is `torch.Tensor` in, `torch.Tensor` out; OpenCV is not a dependency.

Install: `pip install kornia`. Kornia 0.9.2 requires Python ≥ 3.11 and PyTorch ≥ 2.5.1; its other runtime dependencies are NumPy ≥ 1.21 and `kornia_rs` ≥ 0.2.0 (image I/O). `RANSAC(compile=True)` needs PyTorch ≥ 2.14. What exports to ONNX and compiles in one graph: <https://kornia.readthedocs.io/en/latest/get-started/export-support.html>. Half precision and devices: <https://kornia.readthedocs.io/en/latest/get-started/precision.html>.

## When to use Kornia

Kornia pays off where a hand-written version gets long or fragile, or where the alternatives leave the GPU:

- **Breadth.** 1,200+ public operators, most with no torchvision equivalent: camera models and
  epipolar geometry, minimal solvers and RANSAC, feature detection, description and matching, edge detection,
  morphology, Lab and Bayer color, image losses and metrics. torchvision overlaps mainly on resizing, cropping,
  flipping, color jitter and blur.
- **Per-sample parameters in one batched call.** `gaussian_blur2d(x, (9, 9), sigma)` takes a `(B, 2)` `sigma`;
  `rotate` takes a `(B,)` angle, `warp_affine` / `warp_perspective` take `(B, 2, 3)` / `(B, 3, 3)` matrices and
  `adjust_brightness` a `(B,)` factor. torchvision's functional ops apply one parameter per call. From Kornia 0.9.1,
  a `sigma` tensor and the enhancement value checks (gamma, contrast, solarize) are validated on the device, so a
  CUDA call, or an MPS call on PyTorch ≥ 2.13, needs no host synchronization for them.
- **Batched minimal solvers and robust estimation.** `find_fundamental(x1, x2, method="7POINT")` solves `(B, 7, 2)`
  samples and returns all real solutions in `(B, 3, 3, 3)`, with zero matrices in the unused slots; the 8-point,
  5-point essential (`find_essential`), DLT homography and PnP (`solve_pnp_dlt`) solvers are there too. `RANSAC`
  (homography, fundamental and essential models) samples and scores hypotheses on the device; by default its
  refinement and final selection run on the host in float64, and `compile=True` (PyTorch ≥ 2.14, CPU and CUDA) runs
  the whole estimation as one compiled graph on the device.
- **Differentiable geometry.** Depth to 3D and back (`depth_to_3d_v2`, `unproject_points`, `project_points`),
  `warp_frame_depth`, `remap`, camera models with Brown–Conrady and Kannala–Brandt distortion, and Lie groups (`So3`,
  `Se3`) keep gradients with respect to depth, pose and camera parameters.
- **Annotated augmentation.** `AugmentationSequential` applies one sampled transform to images, masks, boxes and
  keypoints together and can invert it, in 2D; the 3D augmentations transform volumes, without annotations or an
  inverse. On CUDA, augmentations move their sampled parameters to the
  GPU without blocking it, and a sync-guard test keeps every public augmentation free of avoidable host
  synchronizations.
- **Local features on the GPU.** SIFT and HardNet, DISK, ALIKED, XFeat, DeDoDe, LoFTR and LightGlue, with
  mutual-nearest-neighbour and ratio-test matchers. They run at their authors' speed or faster, except eager ALIKED
  on CUDA (compile it) and SIFT on a CPU (OpenCV's is faster); what to use on each device is in the
  [image matching guide](https://kornia.readthedocs.io/en/latest/applications/image_matching.html#feature-speed-by-device).
- **Morphology** with arbitrary structuring elements on batched tensors.
- **Compiles and exports.** Nearly all probed operator configurations run under `torch.compile` and match eager,
  and over 1,000 export to ONNX; the result for every operator is on the
  [export support page](https://kornia.readthedocs.io/en/latest/get-started/export-support.html).
- **Fast where it is designed to be: batched tensors on a GPU.** In the published 0.9.1 and 0.9.2 flagship benchmarks
  (RTX 4090, batch 32), many filters, warps, feature-matching steps and image metrics run about 10× to 70× faster in
  eager mode than per-image OpenCV or scikit-image on the CPU, and `torch.compile` takes several of them past 100×.
  On the small overlap with torchvision on the same GPU, eager Kornia is slower; compiled Kornia is faster for hue,
  color jitter and Gaussian blur and still slower for flips, crops and brightness. OpenCV wins single-image `uint8` CPU
  work. Results vary with hardware and workload; every number, win and loss is published on the
  [performance page](https://kornia.readthedocs.io/en/latest/get-started/performance.html).

These operators run on the input's device with no NumPy round trip, and most are differentiable; robust estimation
(`RANSAC`) and the extraction methods of learned features such as DeDoDe and XFeat run without gradients. For a
single fixed-parameter operation, such as one blur or one resize, a few lines of PyTorch or torchvision are just as
good.

## Tensor and coordinate conventions

These conventions hold library-wide; per-function docs note any exception.

- **Image layout:** float tensors `(B, C, H, W)`, channel order RGB, values in `[0, 1]`. The batched 4D layout is accepted everywhere; some op families (e.g. color conversions) also take `(*, C, H, W)` with arbitrary leading dims. When unsure, use `(B, C, H, W)` — add the batch dim with `img[None]`.
- **Point coordinates:** `(x, y)` order, where x indexes columns and y indexes rows. A point tensor for N points is `(B, N, 2)`.
- **Sizes:** output sizes and `dsize` arguments are `(h, w)` order — the OPPOSITE axis order from points.
- **Angles:** degrees in the 2D image APIs (`rotate`, `get_rotation_matrix2d`, `RandomRotation`); radians in the 3D/conversion APIs (`axis_angle_to_rotation_matrix`, `So3`; convert with `deg2rad`/`rad2deg`). Positive 2D angle = counter-clockwise rotation as displayed, with the origin at the top-left corner (OpenCV convention).
- **Transformation matrices:** batched. Homographies are `(B, 3, 3)`, affine matrices `(B, 2, 3)`. They act on pixel coordinates unless the function name or a flag says `normalized`. To apply a `(3, 3)` matrix, add the batch dim: `M[None]`. Exception: `homography_warp`, `homography_warp3d` and `HomographyWarper` take a destination→source homography, in normalized `[-1, 1]` coordinates by default (`normalized_coordinates=True`); `homography_warp(..., normalized_homography=False)` takes a pixel source→destination homography instead. For a pixel source→destination homography, as `RANSAC` and `find_homography_dlt` return it, use `warp_perspective`, or in 3D `warp_perspective3d`.
- **`align_corners`:** `warp_perspective` and `warp_affine` default to `align_corners=True`; `resize` defaults to `align_corners=None` (PyTorch's native default per interpolation mode). When mixing Kornia warps with `torch.nn.functional.interpolate` or `grid_sample`, pass `align_corners` explicitly everywhere.
- **Devices/dtypes:** ops run on whatever device/dtype the input tensors carry; there is no implicit `.cuda()` or `.float()`.
- **Augmentation probability:** most augmentations apply per sample with probability `p` and default to `p=0.5`: `RandomRotation(degrees=30.0)` leaves about half the batch unrotated. `RandomGrayscale` defaults to 0.1 and `RandomMosaic` to 0.7; every class exported from `kornia.augmentation` with a default below 1 states it on its first docstring line. These default to `p=1.0`: `CenterCrop`, `CenterCrop3D`, `ColorJiggle`, `ColorJitter`, `Denormalize`, `LongestMaxSize`, `Normalize`, `PatchMix`, `RandomAutoContrast`, `RandomBrightness`, `RandomContrast`, `RandomCrop`, `RandomCrop3D`, `RandomCutMixV2`, `RandomGamma`, `RandomHue`, `RandomJPEG`, `RandomMixUpV2`, `RandomResizedCrop`, `RandomSaturation`, `RandomSnow`, `Resize` and `SmallestMaxSize`. The crop, resize and mix classes (`RandomCrop`, `CenterCrop`, `RandomResizedCrop`, `Resize`, `LongestMaxSize`, `SmallestMaxSize`, `RandomCrop3D`, `CenterCrop3D`, `RandomMixUpV2`, `RandomCutMixV2`, `PatchMix`) take their `p` as one draw for the whole batch, `Normalize`, `Denormalize` and `RandomDissolving` share one draw across the batch, and `same_on_batch=True` shares the draw for any class. torchvision's `RandomRotation`, `RandomAffine`, `ElasticTransform`, `GaussianBlur`, `GaussianNoise` and `RandomChannelPermutation` always apply: pass `p=1.0` for that behaviour. The reverse holds for `RandomAutoContrast`, which defaults to `p=1.0` while torchvision's `RandomAutocontrast` defaults to `p=0.5`.
- **Pretrained models:** in `kornia.models` and `kornia.feature` alike, a model built with complete pretrained weights comes back in eval mode, and a randomly initialised or only partly pretrained one in training mode; call `.eval()` before inference on random weights, and after loading your own weights. In `kornia.feature`, `HardNet`, `HardNet8`, `HyNet`, `SOSNet`, `TFeat`, `OriNet`, `LAFAffNetShapeEstimator`, `KeyNet`, `KeyNetDetector` (its `KeyNet` network; the detector itself keeps its mode), `DeFMO`, `SOLD2`, `SOLD2_detector`, `LoFTR` and `LightGlue` load their pretrained weights by default (`pretrained=False`, or `None` for `LoFTR` and `LightGlue`, gives random ones), and `DISK`, `DeDoDe`, `ALIKED` and `XFeat` load them with `from_pretrained`.

Full conventions reference with runnable proofs: <https://kornia.readthedocs.io/en/latest/get-started/conventions.html>
Stability: the core modules (geometry, augmentation, color, filters, enhance, losses, metrics, morphology, io, image) follow a written deprecation policy — public symbols warn for at least one minor release before breaking: <https://kornia.readthedocs.io/en/latest/get-started/stability.html>

## kornia.geometry — warps, homographies, camera geometry

The differentiated core: differentiable, batched geometric transforms with no OpenCV/torchvision equivalent.

Key functions:

- `warp_perspective(src, M, dsize, mode="bilinear", padding_mode="zeros", align_corners=True)` — src `(B, C, H, W)`, M `(B, 3, 3)` pixel-coordinate homography, dsize `(h, w)`.
- `warp_affine(src, M, dsize, ...)` — M `(B, 2, 3)`.
- `get_perspective_transform(points_src, points_dst)` — both `(B, 4, 2)` in `(x, y)` pixel coords; returns `(B, 3, 3)` mapping src → dst.
- `get_rotation_matrix2d(center, angle, scale)` — center `(B, 2)` in `(x, y)`, angle `(B,)` degrees, scale `(B, 2)`; returns `(B, 2, 3)`.
- `rotate(tensor, angle)`, `translate`, `scale`, `resize(input, size, interpolation="bilinear", align_corners=None)`.
- Conversions: `rad2deg`, `deg2rad`, `axis_angle_to_rotation_matrix` (`angle_axis_to_rotation_matrix` is its deprecated alias), `rotation_matrix_to_quaternion`, and the `So3`/`Se3` Lie group classes.
- Epipolar: `find_fundamental`, `find_essential`, `sampson_epipolar_distance`, `triangulate_points`.

Example — warp an image with a 4-point homography:

```python
import torch
import kornia.geometry as KG

img = torch.rand(1, 3, 100, 100)  # (B, C, H, W), values in [0, 1]
# four corners, (x, y) order, pixel coordinates
points_src = torch.tensor([[[0.0, 0.0], [99.0, 0.0], [99.0, 99.0], [0.0, 99.0]]])
points_dst = torch.tensor([[[10.0, 5.0], [90.0, 10.0], [95.0, 95.0], [5.0, 90.0]]])
M = KG.get_perspective_transform(points_src, points_dst)  # (1, 3, 3)
out = KG.warp_perspective(img, M, dsize=(100, 100))  # dsize is (h, w)
```

## kornia.augmentation — batched augmentation with transform tracking

`AugmentationSequential` applies the SAME sampled transform to every registered data type and can invert it. This is the correct way to keep images, masks, boxes, and keypoints consistent.

```python
import torch
import kornia.augmentation as K

aug = K.AugmentationSequential(
    K.RandomAffine(degrees=30.0, p=1.0),
    K.ColorJiggle(0.1, 0.1, 0.1, 0.1, p=1.0),
    data_keys=["input", "mask", "keypoints"],
)
image = torch.rand(1, 3, 64, 64)
mask = (torch.rand(1, 1, 64, 64) > 0.5).float()
keypoints = torch.tensor([[[16.0, 16.0], [48.0, 32.0]]])  # (B, N, 2), (x, y)

img_out, mask_out, kpts_out = aug(image, mask, keypoints)
# geometric part is inverted for all data types; color ops are skipped on masks/keypoints
img_back, mask_back, kpts_back = aug.inverse(img_out, mask_out, kpts_out)
```

Notes:

- `data_keys` order defines the positional argument order.
- Random parameters are sampled per batch element, and most augmentations apply to each sample with probability `p=0.5` by default; `p=1.0` forces application.
- The last applied transform matrices are available via `aug.transform_matrix` after a forward pass.

## kornia.color — color space conversions

`rgb_to_grayscale`, `rgb_to_hsv`, `hsv_to_rgb`, `rgb_to_lab`, `rgb_to_yuv`, `bgr_to_rgb`, etc. All take `(B, C, H, W)` float tensors in `[0, 1]` (except explicitly-ranged spaces like LAB on output).

```python
import torch
import kornia.color as KC

rgb = torch.rand(1, 3, 32, 32)
gray = KC.rgb_to_grayscale(rgb)  # (1, 1, 32, 32)
hsv = KC.rgb_to_hsv(rgb)  # hue in radians [0, 2pi], s/v in [0, 1]
```

## kornia.filters — blurring, gradients, edges

- `gaussian_blur2d(input, kernel_size, sigma, border_type="reflect", separable=True)` — kernel_size `(ky, kx)` ints, sigma `(sy, sx)` floats or tensor.
- `sobel(input)`, `spatial_gradient(input)`, `canny(input)`, `median_blur`, `box_blur`, `bilateral_blur`.

```python
import torch
import kornia.filters as KF

img = torch.rand(1, 3, 64, 64)
blurred = KF.gaussian_blur2d(img, kernel_size=(5, 5), sigma=(1.5, 1.5))
magnitude, edges = KF.canny(img)  # gradient magnitudes and thresholded edge map
```

## kornia.feature — detection, description, matching

Classical and learned local features with a common interface: LAFs (local affine frames) of shape `(B, N, 2, 3)`.

```python
import torch
import kornia.feature as KF

# LoFTR-style dense matching (downloads pretrained weights at construction)
matcher = KF.LoFTR(pretrained="outdoor")
input_dict = {
    "image0": torch.rand(1, 1, 128, 128),  # grayscale (B, 1, H, W)
    "image1": torch.rand(1, 1, 128, 128),
}
with torch.inference_mode():
    out = matcher(input_dict)
# out["keypoints0"], out["keypoints1"]: matched (x, y) pixel coords; out["confidence"]
```

Other entry points: `SIFTDescriptor`, `HardNet`, `DISK`, `LightGlueMatcher`, `match_smnn`, `LAFDescriptor`.

## kornia.enhance / kornia.losses / kornia.metrics / kornia.morphology

- `kornia.enhance`: `normalize`, `denormalize`, `equalize_clahe`, `adjust_gamma`, `adjust_brightness` — all differentiable.
- `kornia.losses`: `ssim_loss`, `psnr_loss`, `dice_loss`, `focal_loss`, `charbonnier_loss` — take `(B, C, H, W)` predictions/targets.
- `kornia.metrics`: `ssim`, `psnr`, `mean_iou`, `accuracy`.
- `kornia.morphology`: `dilation(tensor, kernel)`, `erosion`, `opening`, `closing` — kernel is a 2D `(kH, kW)` tensor of ones/zeros.

## kornia.io — image I/O

```python
import kornia.io as KIO

img = KIO.load_image("photo.jpg", KIO.ImageLoadType.RGB32)  # (3, H, W) float32 in [0, 1]
img = img[None]  # most ops want (B, C, H, W)
```

## Pitfalls checklist

1. Passing `(H, W, C)` NumPy-style arrays — convert with `kornia.image.image_to_tensor(np_img)[None]` (or `torch.from_numpy(...).permute(2, 0, 1)[None] / 255`). `kornia.utils.image_to_tensor` is deprecated.
2. Passing `(w, h)` to `dsize`/`size` arguments — they are `(h, w)`.
3. Passing `(y, x)` (row, col) points — point tensors are `(x, y)`.
4. Assuming `align_corners` defaults are uniform — warps default `True`, `resize` defaults `None`.
5. Using an unbatched `(3, 3)` homography — add the batch dim: `M[None]`.
6. Radians where degrees are expected — rotation angles are degrees.
7. Uint8 `[0, 255]` tensors — ops expect float `[0, 1]`; divide by 255 first.
8. Augmenting image and mask through two separate augmentation calls — the random parameters will differ; use one `AugmentationSequential` with `data_keys`.
9. Feeding `homography_warp` a source→destination pixel homography — it expects destination→source, normalized to [-1, 1]. Use `warp_perspective` (or `normalized_homography=False`) instead. To keep the normalized form, normalize the forward homography FIRST with the `align_corners` the warp uses, then invert: `torch.inverse(normalize_homography(M, size_src, size_dst, align_corners=False))` for `homography_warp`'s default `align_corners=False`, which differs from `warp_perspective`'s `True`.
10. Mixing `axis_angle_to_rotation_matrix` (right-hand rule, math convention — screen-clockwise for +z on y-down images) with `rotate` (screen-counter-clockwise) without negating the angle.
11. Treating `kornia.geometry.bbox.infer_bbox_shape` width/height as exclusive — they are inclusive (`x_right - x_left + 1`): corners (1,1),(2,2) give width 2.
12. Quaternions in XYZW order — `kornia.geometry.quaternion.Quaternion` uses WXYZ (scalar first).
13. Expecting hue in `[0, 360]` or `[0, 1]` — `rgb_to_hsv` returns radians `[0, 2π)`.
14. Wrong `data_keys` box format — `"bbox"` means 4-corner `(B, 4, 2)`; coordinate formats are `"bbox_xyxy"` / `"bbox_xywh"`.
15. Treating `kornia.geometry.boxes.Boxes` as inclusive — it stores exclusive corners (`width = xmax - xmin`, as torchvision, COCO and albumentations do); `Boxes(corners)` and `.data` are those corners and the `"xyxy_plus"` / `"vertices_plus"` modes are inclusive ([#6710](https://github.com/kornia/kornia/issues/6710)). `infer_bbox_shape` and `bbox_to_mask` take one inclusive box per image, `(B, 4, 2)`: pass them the `to_tensor("vertices_plus")` export of an unbatched `Boxes`, `(N, 4, 2)`, and use `Boxes.to_mask` for several boxes per image. `nms` takes exclusive `xyxy`.
16. Mixing box inputs in `AugmentationSequential` — a tensor under the bare `"bbox"` / `"bbox_xyxy"` key holds pixel-centre corners (a 2x resize maps `[10, 30]` to `[20.5, 60.5]`), while a `Boxes` object or a `"bbox_xywh"` tensor is exclusive (`[10, 30)` to `[20, 60)`) ([#6710](https://github.com/kornia/kornia/issues/6710)).
17. Assuming `RandomAffine(degrees=...)` turns like `rotate` — a positive angle turns the image clockwise in `RandomAffine` but counter-clockwise in `rotate` and `RandomRotation` ([#4408](https://github.com/kornia/kornia/issues/4408)).
18. Assuming one `align_corners` default across augmentations — it is `True` for `RandomRotation`, `RandomRotation90` and the crop/resize classes, and `False` for `RandomAffine`, `RandomShear`, `RandomTranslate`, `RandomPerspective`, `RandomElasticTransform` and `RandomThinPlateSpline` ([#4412](https://github.com/kornia/kornia/issues/4412)); pass it explicitly when the pixel grid matters.

## Performance (auto-refreshed from benchmarks/results)

From the in-repo benchmark harness (`benchmarks/` in the GitHub repo — warmup + repeats, median wall clock, device sync, recorded hardware metadata; see `benchmarks/README.md`). Guidance for choosing a backend, not marketing; numbers vary by hardware — reproduce with `python benchmarks/geometry/flagship.py --json out.json` before citing:

How to choose a regime:

- Kornia's regime is batched float tensors on an accelerator, differentiable end-to-end: use it for batched, GPU or differentiable pipelines.
- OpenCV wins the CPU single-image uint8 regime on image warps and resize: use OpenCV or kornia-rs for per-image CPU data loading.
- `torch.compile` speeds many ops but not all, and the first call pays the compile time: measure your own shapes before assuming it helps.
- On Apple-silicon MPS, measure the specific op you need: a few ops take slow paths on MPS.

The result block below lists, per machine, only each suite's fastest and slowest row; the per-op tables are on the performance page: <https://kornia.readthedocs.io/en/latest/get-started/performance.html>.

<!-- BENCH:BEGIN -->
- Result set: kornia 0.9.2, 0.9.1, committed in `benchmarks/results/0.9.2/` and `benchmarks/results/0.9.1/` (per-machine
  snapshots, the newest of each suite; reproduce with `python benchmarks/<dir>/<script>.py
  --contribute benchmarks/results`, the script each suite maps to in `benchmarks/README.md`).
- augmentation on apple-m1-pro/cpu (kornia 0.9.1 @ d1e7c5db8, 2026-11-13): fastest overall opencv RandomGrayscale@8 at 105532 img/s; slowest kornia op ColorJiggle@1 at 294 img/s.
- augmentation on apple-m1-pro/mps (kornia 0.9.1 @ 3dfe8620b, 2026-11-13): fastest overall opencv RandomGrayscale@8 at 105134 img/s; slowest kornia op ColorJiggle@1 at 220 img/s.
- augmentation on i7-14700k-rtx-4090/cpu (kornia 0.9.1 @ 3dfe8620b, 2026-11-13): fastest overall opencv RandomHorizontalFlip@1 at 270837 img/s; slowest kornia op ColorJiggle@32 at 401 img/s.
- augmentation on i7-14700k-rtx-4090/cuda (kornia 0.9.1 @ 3dfe8620b, 2026-11-13): fastest overall torchvision v2 RandomHorizontalFlip@32 at 1520729 img/s; slowest kornia op RandomPerspective@1 at 469 img/s.
- augmentation on kaggle-t4/cpu (kornia 0.9.2 @ 0de67ad, 2026-11-26): fastest overall opencv RandomHorizontalFlip@1 at 52536 img/s; slowest kornia op ColorJiggle@32 at 133 img/s.
- augmentation on kaggle-t4/cuda (kornia 0.9.2 @ 0de67ad, 2026-11-26): fastest overall torchvision v2 RandomResizedCrop@32 at 205262 img/s; slowest kornia op RandomPerspective@1 at 284 img/s.
- color on apple-m1-pro/cpu (kornia 0.9.2 @ b4275e48b, 2026-11-16): fastest overall opencv (stacked) rgb_to_grayscale@32 at 280442 img/s; slowest kornia op rgb_to_lab@1 at 685 img/s.
- color on apple-m1-pro/mps (kornia 0.9.2 @ b4275e48b, 2026-11-16): fastest overall opencv (stacked) rgb_to_grayscale@32 at 294056 img/s; slowest kornia op rgb_to_lab@1 at 767 img/s.
- color on i7-14700k-rtx-4090/cpu (kornia 0.9.2 @ b4275e48b, 2026-11-16): fastest overall opencv (stacked) rgb_to_grayscale@32 at 260360 img/s; slowest kornia op rgb_to_lab@8 at 715 img/s.
- color on i7-14700k-rtx-4090/cuda (kornia 0.9.2 @ b4275e48b, 2026-11-16): fastest overall torchvision v2 rgb_to_grayscale@32 at 997775 img/s; slowest kornia op hsv_to_rgb@1 at 1855 img/s.
- color on kaggle-t4/cpu (kornia 0.9.2 @ 0de67ad, 2026-11-26): fastest overall opencv (stacked) rgb_to_grayscale@32 at 91007 img/s; slowest kornia op rgb_to_lab@8 at 227 img/s.
- color on kaggle-t4/cuda (kornia 0.9.2 @ 0de67ad, 2026-11-26): fastest overall kornia (compiled) rgb_to_grayscale@32 at 163775 img/s; slowest kornia op rgb_to_lab@1 at 1895 img/s.
- contrib on apple-m1-pro/cpu (kornia 0.9.1 @ 3dfe8620b, 2026-11-13): fastest overall kornia-rs connected_components_union_find@1 at 18357 img/s; slowest kornia op distance_transform@1 at 62 img/s.
- contrib on apple-m1-pro/mps (kornia 0.9.1 @ 3dfe8620b, 2026-11-13): fastest overall kornia-rs connected_components_union_find@1 at 17312 img/s; slowest kornia op connected_components_union_find@1 at 143 img/s.
- contrib on i7-14700k-rtx-4090/cpu (kornia 0.9.1 @ 3dfe8620b, 2026-11-13): fastest overall opencv connected_components_union_find@1 at 36394 img/s; slowest kornia op distance_transform@32 at 88 img/s.
- contrib on i7-14700k-rtx-4090/cuda (kornia 0.9.1 @ 3dfe8620b, 2026-11-13): fastest overall kornia (compiled) distance_transform@32 at 53877 img/s; slowest kornia op connected_components_union_find@1 at 343 img/s.
- contrib on kaggle-t4/cpu (kornia 0.9.2 @ 0de67ad, 2026-11-26): fastest overall opencv connected_components_union_find@1 at 8966 img/s; slowest kornia op distance_transform@1 at 24 img/s.
- contrib on kaggle-t4/cuda (kornia 0.9.2 @ 0de67ad, 2026-11-26): fastest overall opencv connected_components_union_find@8 at 8249 img/s; slowest kornia op connected_components_union_find@1 at 452 img/s.
- enhance on apple-m1-pro/cpu (kornia 0.9.1 @ d1e7c5db8, 2026-11-13): fastest overall kornia (compiled) normalize@32 at 63085 img/s; slowest kornia op adjust_hue@1 at 390 img/s.
- enhance on apple-m1-pro/mps (kornia 0.9.1 @ d1e7c5db8, 2026-11-13): fastest overall kornia (compiled) normalize@32 at 51006 img/s; slowest kornia op equalize_clahe@32 at 123 img/s.
- enhance on i7-14700k-rtx-4090/cpu (kornia 0.9.1 @ d1e7c5db8, 2026-11-13): fastest overall kornia (compiled) normalize@8 at 100884 img/s; slowest kornia op equalize_clahe@32 at 381 img/s.
- enhance on i7-14700k-rtx-4090/cuda (kornia 0.9.1 @ d1e7c5db8, 2026-11-13): fastest overall torchvision v2 adjust_gamma@32 at 1895230 img/s; slowest kornia op equalize_clahe@1 at 446 img/s.
- enhance on kaggle-t4/cpu (kornia 0.9.2 @ 0de67ad, 2026-11-26): fastest overall kornia (compiled) normalize@32 at 20296 img/s; slowest kornia op equalize_clahe@32 at 92 img/s.
- enhance on kaggle-t4/cuda (kornia 0.9.2 @ 0de67ad, 2026-11-26): fastest overall torchvision v2 adjust_gamma@32 at 120454 img/s; slowest kornia op equalize_clahe@1 at 433 img/s.
- feature on apple-m1-pro/cpu (kornia 0.9.2 @ 13cfb271e, 2026-11-16): fastest overall opencv harris_response@8 at 4461 items/s; slowest kornia op SIFTFeature@32 at 12 items/s.
- feature on apple-m1-pro/mps (kornia 0.9.2 @ 13cfb271e, 2026-11-16): fastest overall kornia (compiled) gftt_response@32 at 13136 items/s; slowest kornia op SIFTFeature@32 at 21 items/s.
- feature on i7-14700k-rtx-4090/cpu (kornia 0.9.2 @ a1d4dff67, 2026-11-16): fastest overall opencv harris_response@8 at 4692 items/s; slowest kornia op SIFTFeature@1 at 21 items/s.
- feature on i7-14700k-rtx-4090/cuda (kornia 0.9.2 @ a1d4dff67, 2026-11-16): fastest overall kornia (compiled) harris_response@32 at 152405 items/s; slowest kornia op SIFTFeature@32 at 38 items/s.
- feature on kaggle-t4/cpu (kornia 0.9.2 @ 0de67ad, 2026-11-26): fastest overall opencv harris_response@8 at 1829 items/s; slowest kornia op match_smnn_batched@8 at 5 items/s.
- feature on kaggle-t4/cuda (kornia 0.9.2 @ 0de67ad, 2026-11-26): fastest overall kornia (compiled) harris_response@32 at 21575 items/s; slowest kornia op SIFTFeature@1 at 27 items/s.
- feature-laf-ops on apple-m1-pro/cpu (kornia 0.9.2 @ 13cfb271e, 2026-11-16): fastest overall kornia (compiled) laf_is_inside_image@1,n_lafs=20000 at 227277583 LAFs/s; slowest kornia op extract_patches_from_pyramid@1,n_lafs=2000 at 38518 LAFs/s.
- feature-laf-ops on apple-m1-pro/mps (kornia 0.9.2 @ 13cfb271e, 2026-11-16): fastest overall kornia (compiled) laf_is_inside_image@1,n_lafs=20000 at 79286422 LAFs/s; slowest kornia op extract_patches_from_pyramid@1,n_lafs=2000 at 102971 LAFs/s.
- feature-laf-ops on i7-14700k-rtx-4090/cpu (kornia 0.9.2 @ a1d4dff67, 2026-11-16): fastest overall kornia (compiled) laf_is_inside_image@1,n_lafs=20000 at 1058266794 LAFs/s; slowest kornia op extract_patches_from_pyramid@8,n_lafs=2000 at 81778 LAFs/s.
- feature-laf-ops on i7-14700k-rtx-4090/cuda (kornia 0.9.2 @ a1d4dff67, 2026-11-16): fastest overall kornia (compiled) laf_is_inside_image@1,n_lafs=20000 at 636117101 LAFs/s; slowest kornia op extract_patches_from_pyramid@1,n_lafs=2000 at 1330174 LAFs/s.
- feature-laf-ops on kaggle-t4/cpu (kornia 0.9.2 @ 0de67ad, 2026-11-26): fastest overall kornia (compiled) laf_is_inside_image@1,n_lafs=20000 at 208880917 LAFs/s; slowest kornia op extract_patches_from_pyramid@8,n_lafs=2000 at 14451 LAFs/s.
- feature-laf-ops on kaggle-t4/cuda (kornia 0.9.2 @ 0de67ad, 2026-11-26): fastest overall kornia (compiled) laf_is_inside_image@1,n_lafs=20000 at 334978401 LAFs/s; slowest kornia op extract_patches_from_pyramid@1,n_lafs=2000 at 395466 LAFs/s.
- filters on apple-m1-pro/cpu (kornia 0.9.1 @ d1e7c5db8, 2026-11-13): fastest overall kornia-rs gaussian_blur2d@1 at 30372 img/s; slowest kornia op bilateral_blur@32 at 137 img/s.
- filters on apple-m1-pro/mps (kornia 0.9.1 @ d1e7c5db8, 2026-11-13): fastest overall kornia (compiled) box_blur_separable@32 at 38324 img/s; slowest kornia op median_blur@1 at 59 img/s.
- filters on i7-14700k-rtx-4090/cpu (kornia 0.9.1 @ d1e7c5db8, 2026-11-13): fastest overall opencv gaussian_blur2d@8 at 51634 img/s; slowest kornia op median_blur@32 at 95 img/s.
- filters on i7-14700k-rtx-4090/cuda (kornia 0.9.1 @ d1e7c5db8, 2026-11-13): fastest overall kornia (compiled) box_blur_separable@32 at 453643 img/s; slowest kornia op canny@1 at 467 img/s.
- filters on kaggle-t4/cpu (kornia 0.9.2 @ 0de67ad, 2026-11-26): fastest overall opencv box_blur@1 at 15995 img/s; slowest kornia op bilateral_blur@1 at 34 img/s.
- filters on kaggle-t4/cuda (kornia 0.9.2 @ 0de67ad, 2026-11-26): fastest overall kornia (compiled) otsu_threshold@32 at 68448 img/s; slowest kornia op median_blur@1 at 233 img/s.
- geometry on apple-m1-pro/cpu (kornia 0.9.1 @ 3dfe8620b, 2026-11-13): fastest overall kornia (compiled) get_perspective_transform@32 at 1017230 items/s; slowest kornia op warp_perspective@1 at 768 items/s.
- geometry on apple-m1-pro/mps (kornia 0.9.1 @ d1e7c5db8, 2026-11-13): fastest overall opencv get_perspective_transform@32 at 863018 items/s; slowest kornia op rotate_shared@1 at 788 items/s.
- geometry on i7-14700k-rtx-4090/cpu (kornia 0.9.1 @ 3dfe8620b, 2026-11-13): fastest overall opencv get_perspective_transform@32 at 1152562 items/s; slowest kornia op remap@8 at 1634 items/s.
- geometry on i7-14700k-rtx-4090/cuda (kornia 0.9.1 @ 3dfe8620b, 2026-11-13): fastest overall kornia (eager) resize@32 at 1404915 items/s; slowest kornia op rotate_shared@1 at 603 items/s.
- geometry on kaggle-t4/cpu (kornia 0.9.2 @ 0de67ad, 2026-11-26): fastest overall opencv get_perspective_transform@8 at 272845 items/s; slowest kornia op warp_perspective@8 at 277 items/s.
- geometry on kaggle-t4/cuda (kornia 0.9.2 @ 0de67ad, 2026-11-26): fastest overall opencv get_perspective_transform@8 at 267199 items/s; slowest kornia op rotate_shared@1 at 539 items/s.
- io on apple-m1-pro/cpu (kornia 0.9.1 @ 3dfe8620b, 2026-11-13): fastest overall torchvision load_jpeg@1 at 4551 img/s; slowest kornia op load_png@32 at 1102 img/s.
- io on apple-m1-pro/mps (kornia 0.9.1 @ d1e7c5db8, 2026-11-13): fastest overall opencv load_jpeg@1 at 4129 img/s; slowest kornia op load_png@8 at 836 img/s.
- io on i7-14700k-rtx-4090/cpu (kornia 0.9.1 @ 3dfe8620b, 2026-11-13): fastest overall torchvision load_jpeg@8 at 6579 img/s; slowest kornia op load_png@8 at 2538 img/s.
- io on i7-14700k-rtx-4090/cuda (kornia 0.9.1 @ 3dfe8620b, 2026-11-13): fastest overall opencv load_jpeg@1 at 6340 img/s; slowest kornia op load_png@8 at 1384 img/s.
- io on kaggle-t4/cpu (kornia 0.9.2 @ 0de67ad, 2026-11-26): fastest overall opencv load_jpeg@1 at 2347 img/s; slowest kornia op load_png@8 at 968 img/s.
- io on kaggle-t4/cuda (kornia 0.9.2 @ 0de67ad, 2026-11-26): fastest overall opencv load_jpeg@32 at 2398 img/s; slowest kornia op load_png@8 at 920 img/s.
- losses on apple-m1-pro/cpu (kornia 0.9.1 @ 3dfe8620b, 2026-11-13): fastest overall kornia (eager) total_variation@32 at 3494 img/s; slowest kornia op ssim_loss@32 at 22 img/s.
- losses on apple-m1-pro/mps (kornia 0.9.1 @ d1e7c5db8, 2026-11-13): fastest overall kornia (compiled) binary_focal_loss_with_logits@32 at 23870 img/s; slowest kornia op ssim_loss@1 at 215 img/s.
- losses on i7-14700k-rtx-4090/cpu (kornia 0.9.1 @ 3dfe8620b, 2026-11-13): fastest overall kornia (compiled) total_variation@32 at 8409 img/s; slowest kornia op ssim_loss@32 at 78 img/s.
- losses on i7-14700k-rtx-4090/cuda (kornia 0.9.1 @ 3dfe8620b, 2026-11-13): fastest overall kornia (compiled) binary_focal_loss_with_logits@32 at 123800 img/s; slowest kornia op ssim_loss@1 at 363 img/s.
- losses on kaggle-t4/cpu (kornia 0.9.2 @ 0de67ad, 2026-11-26): fastest overall kornia (compiled) total_variation@32 at 1971 img/s; slowest kornia op ssim_loss@8 at 12 img/s.
- losses on kaggle-t4/cuda (kornia 0.9.2 @ 0de67ad, 2026-11-26): fastest overall kornia (compiled) total_variation@32 at 51732 img/s; slowest kornia op ssim_loss@1 at 256 img/s.
- metrics on apple-m1-pro/cpu (kornia 0.9.1 @ 3dfe8620b, 2026-11-13): fastest overall kornia (eager) psnr@32 at 33339 img/s; slowest kornia op ssim@1 at 32 img/s.
- metrics on apple-m1-pro/mps (kornia 0.9.1 @ d1e7c5db8, 2026-11-13): fastest overall kornia (eager) psnr@32 at 48128 img/s; slowest kornia op ssim@1 at 415 img/s.
- metrics on i7-14700k-rtx-4090/cpu (kornia 0.9.1 @ 3dfe8620b, 2026-11-13): fastest overall kornia (compiled) psnr@8 at 71430 img/s; slowest kornia op ssim@32 at 342 img/s.
- metrics on i7-14700k-rtx-4090/cuda (kornia 0.9.1 @ 3dfe8620b, 2026-11-13): fastest overall kornia (compiled) psnr@32 at 537788 img/s; slowest kornia op ssim@1 at 972 img/s.
- metrics on kaggle-t4/cpu (kornia 0.9.2 @ 0de67ad, 2026-11-26): fastest overall kornia (compiled) psnr@32 at 19313 img/s; slowest kornia op ssim@8 at 79 img/s.
- metrics on kaggle-t4/cuda (kornia 0.9.2 @ 0de67ad, 2026-11-26): fastest overall kornia (compiled) psnr@32 at 121770 img/s; slowest kornia op ssim@1 at 475 img/s.
- morphology on apple-m1-pro/cpu (kornia 0.9.1 @ 3dfe8620b, 2026-11-13): fastest overall opencv dilation@8 at 24551 img/s; slowest kornia op gradient@1 at 300 img/s.
- morphology on apple-m1-pro/mps (kornia 0.9.1 @ d1e7c5db8, 2026-11-13): fastest overall opencv dilation@32 at 24287 img/s; slowest kornia op gradient@1 at 245 img/s.
- morphology on i7-14700k-rtx-4090/cpu (kornia 0.9.1 @ 3dfe8620b, 2026-11-13): fastest overall opencv erosion@8 at 60471 img/s; slowest kornia op gradient@32 at 230 img/s.
- morphology on i7-14700k-rtx-4090/cuda (kornia 0.9.1 @ 3dfe8620b, 2026-11-13): fastest overall kornia (compiled) erosion@32 at 176555 img/s; slowest kornia op opening@1 at 3502 img/s.
- morphology on kaggle-t4/cpu (kornia 0.9.2 @ 0de67ad, 2026-11-26): fastest overall opencv erosion@1 at 25465 img/s; slowest kornia op gradient@32 at 101 img/s.
- morphology on kaggle-t4/cuda (kornia 0.9.2 @ 0de67ad, 2026-11-26): fastest overall opencv erosion@1 at 27394 img/s; slowest kornia op gradient@32 at 1360 img/s.
<!-- BENCH:END -->

## Links

- Docs: <https://kornia.readthedocs.io/en/latest/>
- Machine-readable index: <https://kornia.readthedocs.io/en/latest/llms.txt>
- Source: <https://github.com/kornia/kornia>
- Tutorials: <https://www.kornia.org/tutorials/>
