コード例 #1
0
ファイル: utils.py プロジェクト: themis0888/cycleGAN_custom
def imread(path, is_grayscale = False):
    if '.npy' in path:
        return np.load(path)
    elif (is_grayscale):
        return _imread(path, flatten=True).astype(np.float)
    else:
        return _imread(path, mode='RGB').astype(np.float)
コード例 #2
0
ファイル: imread.py プロジェクト: cpieringer/pybalu
def imread(filename, *, normalize=False, flatten=False):
    '''\
    imread(filename, flatten=False)

    Loads an image as a numerical matrix of either 2 or 3 dimensions.

    Parameters
    ----------
    filename: string
        The path of the image to load
    normalize: boolean, optional
        If set to true, the return value will be an array with float values between 0 and 1.
        If set to false, the reurn value will be an array with uint8 values between 0 and 255.
        default value is False.
    flatten: boolean, optional
        If set to true, the return value is a 2 dimensional ndarray with the grayscale
        representation of the loaded image.

    Returns
    -------
    image: ndarray
        matrix representation of the loaded image, either 2 or 3 dimensional depending on the
        file and the `flatten` parameter.

    Examples
    --------
    (TODO)
    '''
    img = _imread(filename)
    if flatten:
        img = img @ [0.299, 0.587, 0.114]
    if normalize:
        return (img / 255)
    return img.astype(_np.uint8)
def imread(filename, *, normalize=False, flatten=False):
    img = _imread(filename)
    if flatten:
        img = img @ [0.299, 0.587, 0.114]
    if normalize:
        return (img / 255)
    return img.astype(_np.uint8)
コード例 #4
0
ファイル: tools.py プロジェクト: ericyang125/gpu-mp
def imread(filename, flatten=0):
    """Read an image file into a numpy array
    using imageio.imread
    
    Parameters
    ----------
    filename :  string
        the absolute path of the image file
    flatten :   bool
        True if the image is RGB color or False (default) if greyscale
        
    Returns
    -------
    frame : np.ndarray
        a numpy array with grey levels
        
        
    Examples
    --------
    
    >>> image = openpiv.tools.imread( 'image.bmp' )
    >>> print image.shape 
        (1280, 1024)
    
    
    """
    im = _imread(filename)
    if np.ndim(im) > 2:
        im = rgb2gray(im)

    return im
コード例 #5
0
ファイル: utilsc.py プロジェクト: randomnoisevlad/persoml
def imread(path, is_grayscale = False):
    if (is_grayscale):
        return _imread(path, flatten=True).astype(np.float)
    else:
        image = cv2.imread(path, cv2.IMREAD_UNCHANGED)
        image[..., :3] = cv2.cvtColor(image[..., :3], cv2.COLOR_BGR2RGB)

        if image.shape[2] == 4:
            image_fill = np.ones((image.shape[0], image.shape[1], 3)) * 255
            image_new = image[..., :3] * image[..., 3:] + image_fill * (1 - image[..., 3:])
            cv2.imwrite('img.png', cv2.cvtColor(image_new.astype(np.uint8), cv2.COLOR_RGB2BGR))
            return image_new
        #_imread(path, mode='RGB').astype(np.float)
        return image.astype(np.float32)
コード例 #6
0
def find_bg(list_file=None, list_img=None):
    """finds the background for image list or file list, similar to mark_background2 function but
    with minor differences in handling the images and image intensities"""
    
    if list_img == None:
        list_img = []
        for I in range(len(list_file)):
            list_img.append(_imread(list_file[I]))
    
    background = np.zeros(list_img[0].shape, dtype=np.int32)
    for I in range(background.shape[0]):
        for J in range(background.shape[1]):
            min_1 = list_img[0][I,J]
            for K in range(len(list_img)):
                if min_1 > list_img[K][I,J]:
                    min_1 = list_img[K][I,J]
            background[I,J]=min_1
    return background
コード例 #7
0
ファイル: utils.py プロジェクト: abc99lr/CycleGAN-tensorflow
def imread(path, is_grayscale=True):
    if (is_grayscale):
        return _imread(path, flatten=True).astype(np.float)
    else:
        return _imread(path, mode='RGB').astype(np.float)
コード例 #8
0
def imread(path, is_grayscale=False):

    return _imread(path).astype(np.float)
コード例 #9
0
ファイル: __init__.py プロジェクト: gwappa/python-videobatch
 def __init__(self, specs):
     super().__init__()
     self.path = specs
     mask = _imread(specs).astype(bool)
     self.ypos, self.xpos = _np.where(mask)
コード例 #10
0
ファイル: utils.py プロジェクト: mcaseyrehm/ColabCycleGan
def imread(path, is_grayscale = False):
    if (is_grayscale):
        return _imread(path, flatten=True).astype(np.float)
    else:
        return _imread(path, pilmode="RGB").astype(np.float)
コード例 #11
0
ファイル: utils.py プロジェクト: zqcr/CycleGAN-tensorflow
def imread(path, is_grayscale = False):
    if (is_grayscale):
        return _imread(path, flatten=True).astype(np.float)
    else:
        return _imread(path, mode='RGB').astype(np.float)
コード例 #12
0
def imread(path, is_grayscale=False):
    if is_grayscale:
        return _imread(path, as_gray=True).astype(np.float)
    else:
        return _imread(path, mode='RGB').astype(np.float)