Beispiel #1
0
def imwrite(a, fname):
    '''
    Write RGB(A) data array or image into an image file.
    
    :param a: (*array or BufferedImage*) RGB(A) data array or image.
    :param fname: (*String*) Image file name.
    '''
    ImageUtil.imageSave(a, fname)
Beispiel #2
0
def imwrite(a, fname):
    '''
    Write RGB(A) data array or image into an image file.
    
    :param a: (*array or BufferedImage*) RGB(A) data array or image.
    :param fname: (*String*) Image file name.
    '''
    ImageUtil.imageSave(a, fname)
Beispiel #3
0
def gifwrite(imfns, giffn, repeat=0, delay=1000):
    '''
    Write a gif animation file.
    
    :param imfns: (*list*) Input image file names.
    :param giffn: (*string*) Output gif file name.
    :param: repeat: (*int, Default 0*) Animation repeat time number. 0 means repeat forever.
    :param: delay: (*int, Default 1000*) Animation frame delay time with units of millsecond.
    '''
    ImageUtil.createGifAnimator(imfns, giffn, delay, repeat)
Beispiel #4
0
def gifwrite(imfns, giffn, repeat=0, delay=1000):
    '''
    Write a gif animation file.
    
    :param imfns: (*list*) Input image file names.
    :param giffn: (*string*) Output gif file name.
    :param: repeat: (*int, Default 0*) Animation repeat time number. 0 means repeat forever.
    :param: delay: (*int, Default 1000*) Animation frame delay time with units of millsecond.
    '''
    ImageUtil.createGifAnimator(imfns, giffn, delay, repeat)
    
Beispiel #5
0
def __getimage(src):
    if isinstance(src, BufferedImage):
        return src
    elif isinstance(src, Graphic):
        return src.getShape().getImage()
    elif isinstance(src, MILayer):
        return src.layer.getImage()
    elif isinstance(src, MIArray):
        return ImageUtil.createImage(src.asarray())
    return None
Beispiel #6
0
def __getimage(src):
    if isinstance(src, BufferedImage):
        return src
    elif isinstance(src, Graphic):
        return src.getShape().getImage()
    elif isinstance(src, MILayer):
        return src.layer.getImage()
    elif isinstance(src, MIArray):
        return ImageUtil.createImage(src.asarray())
    return None
Beispiel #7
0
def maximum_filter(a, size):
    '''
    Calculate a multi-dimensional maximum filter.

    :param a: (*array*) Input array
    :param size: (*int*) Window size
    :return: Filtered array. Has the same shape as input array.
    '''
    r = ImageUtil.maximumFilter(a._array, size)
    return NDArray(r)
Beispiel #8
0
def count(a, size):
    '''
    Count none-zero points with window size
    
    :param a: (*array_like*) 2-D array.
    :param size: (*int*) Window size.
    
    :returns: (*array_like*) Count result.
    '''
    r = ImageUtil.count(a.asarray(), size)
    return MIArray(r)
Beispiel #9
0
def count(a, size):
    '''
    Count none-zero points with window size
    
    :param a: (*array_like*) 2-D array.
    :param size: (*int*) Window size.
    
    :returns: (*array_like*) Count result.
    '''
    r = ImageUtil.count(a.asarray(), size)
    return MIArray(r)
Beispiel #10
0
def gaussian_filter(a, sigma, size=3):
    '''
    Calculate a multi-dimensional gaussian filter.

    :param a: (*array*) Input array
    :param sigma: (*float*) Standard deviation for Gaussian kernel.
    :param size: (*int*) Window size
    :return: Filtered array. Has the same shape as input array.
    '''
    r = ImageUtil.gaussianFilter(a._array, size, sigma)
    return NDArray(r)
Beispiel #11
0
def imload(fname):
    '''
    Load image from image file.
    
    :param fname: (*String*) Image file name.
    
    :returns: (*BufferedImage*) Loadded image.
    '''
    if not os.path.exists(fname):
        raise IOError(fname)
    r = ImageUtil.imageLoad(fname)
    return r
Beispiel #12
0
def __getreturn(src, dst):
    if isinstance(src, Graphic):
        src.getShape().setImage(dst)
        return src
    elif isinstance(src, MILayer):
        src.layer.setImage(dst)
        return src
    elif isinstance(src, MIArray):
        r = ImageUtil.imageRead(dst)
        return MIArray(r)
    else:
        return dst
Beispiel #13
0
def imload(fname):
    '''
    Load image from image file.
    
    :param fname: (*String*) Image file name.
    
    :returns: (*BufferedImage*) Loadded image.
    '''
    if not os.path.exists(fname):
        raise IOError(fname)
    r = ImageUtil.imageLoad(fname)
    return r
Beispiel #14
0
def imread(fname):
    '''
    Read RGB(A) data array from image file.
    
    :param fname: (*String*) Image file name.
    
    :returns: (*array*) RGB(A) data array.
    '''
    if not os.path.exists(fname):
        raise IOError(fname)
    r = ImageUtil.imageRead(fname)
    return NDArray(r)
Beispiel #15
0
def mean(a, size, positive=True):
    '''
    Calculate mean value with window size
    
    :param a: (*array_like*) 2-D array.
    :param size: (*int*) Window size.
    :param positive: (*boolean*) Only calculate the positive value or not.
    
    :returns: (*array_like*) Mean result.
    '''
    r = ImageUtil.mean(a.asarray(), size, positive)
    return MIArray(r)
Beispiel #16
0
def __getreturn(src, dst):
    if isinstance(src, Graphic):
        src.getShape().setImage(dst)
        return src
    elif isinstance(src, MILayer):
        src.layer.setImage(dst)
        return src
    elif isinstance(src, MIArray):
        r = ImageUtil.imageRead(dst)
        return MIArray(r)
    else:
        return dst
Beispiel #17
0
def imread(fname):
    '''
    Read RGB(A) data array from image file.
    
    :param fname: (*String*) Image file name.
    
    :returns: (*array*) RGB(A) data array.
    '''
    if not os.path.exists(fname):
        raise IOError(fname)
    r = ImageUtil.imageRead(fname)
    return MIArray(r)
Beispiel #18
0
def mean(a, size, positive=True):
    '''
    Calculate mean value with window size
    
    :param a: (*array_like*) 2-D array.
    :param size: (*int*) Window size.
    :param positive: (*boolean*) Only calculate the positive value or not.
    
    :returns: (*array_like*) Mean result.
    '''
    r = ImageUtil.mean(a.asarray(), size, positive)
    return MIArray(r)
Beispiel #19
0
def gifread(gif, frame=0):
    '''
    Read RGB(A) data array from a gif image file or a gif decoder object.
    
    :param gif: (*string or GifDecoder*) Gif image file or gif decoder object.
    :param frame: (*int*) Image frame index.
    
    :returns: (*array*) RGB(A) data array.
    '''
    if isinstance(gif, basestring):
        gif = gifopen(gif)
    im = gif.getFrame(frame)
    r = ImageUtil.imageRead(im)
    return MIArray(r)
Beispiel #20
0
def gifread(gif, frame=0):
    '''
    Read RGB(A) data array from a gif image file or a gif decoder object.
    
    :param gif: (*string or GifDecoder*) Gif image file or gif decoder object.
    :param frame: (*int*) Image frame index.
    
    :returns: (*array*) RGB(A) data array.
    '''
    if isinstance(gif, basestring):
        gif = gifopen(gif)
    im = gif.getFrame(frame)
    r = ImageUtil.imageRead(im)
    return NDArray(r)