def get_scaled_cutout_wdht(data_np, x1, y1, x2, y2, new_wd, new_ht,
                           interpolation='nearest'):
    if have_opencv and (interpolation != 'basic'):
        # opencv is fastest
        method = cv2_resize[interpolation]
        newdata = cv2.resize(data_np[y1:y2+1, x1:x2+1], (new_wd, new_ht),
                             interpolation=method)

        old_wd, old_ht = max(x2 - x1 + 1, 1), max(y2 - y1 + 1, 1)
        ht, wd = newdata.shape[:2]
        scale_x, scale_y = float(wd) / old_wd, float(ht) / old_ht

    else:
        view, (scale_x, scale_y) = get_scaled_cutout_wdht_view(data_np.shape,
                                                               x1, y1, x2, y2,
                                                               new_wd, new_ht)
        new_data = data_np[view]

    return new_data, (scale_x, scale_y)
dataset/ETHPy150Open ejeschke/ginga/ginga/trcalc.py/get_scaled_cutout_wdht/original