cfa_collect¶
- dnois.sensor.cfa_collect(image: Tensor, unit_size: int | tuple[int, int] = 1) Tensor ¶
Rearrange all the pixels in an image with shape \((\cdots,H,W)\) into channels-wise form \((\cdots,C,H/h,W/w)\), where \(C=hw\) is the number of channels and \(h\) and \(w\) are the size of a unit of a regular color filter array (CFA). In this way, the vanilla 2D pixel array is divided into contiguous and non-overlapping pixel groups, or units. ‘Regular’ means all the units have same size.
The pixels in a unit will be rearranged into a single pixel with \(C=hw\) channels in a row-major manner.
Note
This function is similar to
pixel_unshuffle()
but adds a new dimension to the input and supports unequal unit height and width.- Parameters:
image (Tensor) – The image to be rearranged, a tensor shape \((\cdots,H,W)\).
unit_size – Height and width of a pixel group \((h,w)\). Default:
(1, 1)
.
- Type:
int or tuple[int, int]
- Returns:
Rearranged image with shape \((\cdots,hw,H/h,W/w)\).
- Return type:
Tensor