Resize image for optimal DFT and computes it

    Parameters
    ----------
    im: 2d array
        The image
    shape: 2 numbers, optional
        The shape of the output image (None will optimize the shape)

    Returns
    -------
    dft: 2d array
        The dft in CCS representation

    Notes
    -----
    Th shape shoulb be a product of 2, 3, and 5

def dft_optsize(im, shape=None):
    """Resize image for optimal DFT and computes it

    Parameters
    ----------
    im: 2d array
        The image
    shape: 2 numbers, optional
        The shape of the output image (None will optimize the shape)

    Returns
    -------
    dft: 2d array
        The dft in CCS representation

    Notes
    -----
    Th shape shoulb be a product of 2, 3, and 5
    """
    im = np.asarray(im)
    # save shape
    initshape = im.shape
    # get optimal size
    if shape is None:
        ys = cv2.getOptimalDFTSize(initshape[0])
        xs = cv2.getOptimalDFTSize(initshape[1])
        shape = [ys, xs]
    # Add zeros to go to optimal size
    im = cv2.copyMakeBorder(im, 0, shape[0] - initshape[0],
                            0, shape[1] - initshape[1],
                            borderType=cv2.BORDER_CONSTANT, value=0)
    # Compute dft ignoring 0 rows (0 columns can not be optimized)
    f = cv2.dft(im, nonzeroRows=initshape[0])
    return f