(fn, image)
return image
Run a complex function on a non-complex image.

    The image needs to be complex, or have an even number of bands. The input
    can be int, the output is always float or double.
Run a complex function on a non-complex image.
Run a complex function on a non - complex image .
def _run_cmplx(fn, image):
    """Run a complex function on a non-complex image.

    The image needs to be complex, or have an even number of bands. The input
    can be int, the output is always float or double.
    """
    original_format = image.format

    if image.format != 'complex' and image.format != 'dpcomplex':
        if image.bands % 2 != 0:
            raise Error('not an even number of bands')

        if image.format != 'float' and image.format != 'double':
            image = image.cast('float')

        if image.format == 'double':
            new_format = 'dpcomplex'
        else:
            new_format = 'complex'

        image = image.copy(format=new_format, bands=image.bands / 2)

    image = fn(image)

    if original_format != 'complex' and original_format != 'dpcomplex':
        if image.format == 'dpcomplex':
            new_format = 'double'
        else:
            new_format = 'float'

        image = image.copy(format=new_format, bands=image.bands * 2)

    return image
def _run_cmplx ( fn , image ) : original_format = image . format if image . format != 'complex' and image . format != 'dpcomplex' : if image . bands % 2 != 0 : raise Error ( 'not an even number of bands' ) if image . format != 'float' and image . format != 'double' : image = image . cast ( 'float' ) if image . format == 'double' : new_format = 'dpcomplex' else : new_format = 'complex' image = image . copy ( format = new_format , bands = image . bands / 2 ) image = fn ( image ) if original_format != 'complex' and original_format != 'dpcomplex' : if image . format == 'dpcomplex' : new_format = 'double' else : new_format = 'float' image = image . copy ( format = new_format , bands = image . bands * 2 ) return image