Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | 430x | import type Point3 from '../../types/Point3';
import type { ImageVolumeProps } from '../../types';
import type {
DecimatedVolumeModifier,
DecimatedVolumeModifierContext,
} from './types';
/**
* In-Plane Decimation Modifier
*
* A volume modifier that reduces the resolution of a volume in the in-plane dimensions
* (i and j axes).
*
* The modifier:
* - Applies decimation factors from `context.options.ijkDecimation` for the i and j dimensions
* - Calculates new column and row dimensions by dividing the original dimensions by the decimation factors
* - Adjusts pixel spacing proportionally (spacing increases by the decimation factor)
* - Updates DICOM metadata (Columns, Rows, PixelSpacing) to reflect the new dimensions
* - Leaves the k dimension (slices) unchanged
*
* If no decimation is specified or both factors are 1, the volume properties are returned unchanged.
*
* @example
* // Decimate by factor of 2 in both i and j directions
* const context = {
* options: { ijkDecimation: [2, 2, 1] }
* };
* // Original: 512x512x100, spacing [1, 1, 1]
* // Result: 256x256x100, spacing [2, 2, 1]
*/
export const inPlaneDecimationModifier: DecimatedVolumeModifier = {
name: 'InPlaneDecimationModifier',
apply(volumeProps, context) {
const [iDecimation = 1, jDecimation = iDecimation] =
context.options.ijkDecimation ?? [];
const columnFactor = Math.max(1, Math.floor(iDecimation));
const rowFactor = Math.max(1, Math.floor(jDecimation));
if (columnFactor === 1 && rowFactor === 1) {
return volumeProps;
}
const [columns, rows] = volumeProps.dimensions;
const newColumns = Math.max(1, Math.floor(columns / columnFactor));
const newRows = Math.max(1, Math.floor(rows / rowFactor));
const newDimensions = [
newColumns,
newRows,
volumeProps.dimensions[2],
] as Point3;
const newSpacing = [
volumeProps.spacing[0] * columnFactor,
volumeProps.spacing[1] * rowFactor,
volumeProps.spacing[2],
] as Point3;
const metadata = {
...volumeProps.metadata,
Columns: newColumns,
Rows: newRows,
PixelSpacing: [newSpacing[1], newSpacing[0]],
};
return {
...volumeProps,
dimensions: newDimensions,
spacing: newSpacing,
metadata,
};
},
};
|