darsia.Resize#
- class Resize(ref_image=None, shape=None, fx=None, fy=None, interpolation=None, dtype=None, key='', **kwargs)[source]#
Bases:
objectObject for resizing 2d arrays.
Examples
import darsia options = { "example resize x": 0.2, "example resize y": 0.5, "example interpolation": "inter_nearest", } resizer = darsia.Resize(key="example ", **options) img_small = resizer(img_large)
- Parameters:
- ref_image
Image,optional Image whose shape is desired.
- shape
tupleofint,optional Desired shape (in matrix indexing).
- fx
float,optional Resize factor in x-dimension.
- fy
float,optional Resize factor in y-dimension.
- interpolation
str,optional Interpolation method, default: None, invoking the default option in cv2.resize.
- dtype
np.dtypeortype,optional Conversion dtype before resizing; nothing happens if None.
- ref_image
Methods
load(path)Load parameters from file.
resize_array(img_array[, is_extensive])Core resize logic for arrays, shared with BaseCorrection subclasses.
save(path)Save parameters to npz file.
- resize_array(img_array, is_extensive=False)[source]#
Core resize logic for arrays, shared with BaseCorrection subclasses.
- Parameters:
- img_array
np.ndarray Input image array (any shape).
- is_extensivebool
Whether to apply conservative (extensive) rescaling.
- img_array
- Returns:
np.ndarrayResized array.