code: def scale_to_h(img, target_height):
      assert img.dtype == np.uint8
  
      h, w = img.shape[:2]
      if h == target_height:
          return img
      if h == 0 or img.size == 0:
          # empty image
          return np.zeros(
              shape=(target_height, w) + img.shape[2:], dtype=img.dtype
          )
  
      scale = target_height * 1.0 / h
      target_width = np.maximum(round(scale * w), 1)
      if scale <= 1:
          # Down-Sampling: interpolation "area"
          return cv.resize(
              img,
              (target_width, target_height),
              interpolation=cv.INTER_AREA,
          )
  
      else:
          # Up-Sampling: linear interpolation
          return cv.resize(
              img,
              (target_width, target_height),
              interpolation=cv.INTER_LINEAR,
          )
  
file_path: calamari/calamari_ocr/ocr/dataset/imageprocessors/scale_to_height_processor.py
imports: from dataclasses import dataclass, field
  from typing import Type
  import cv2
  import numpy
  from paiargparse import pai_dataclass
  from tfaip.data.pipeline.processor.dataprocessor import DataProcessorParams
  from calamari_ocr.ocr.dataset.imageprocessors.data_preprocessor import ImageProcessor
label_desc: Use image node_id 1 for calling a global function with example usage: scale_to_h(img, target_height) and returns: img, np, cv, cv