• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python skimage.img_as_float函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中skimage.img_as_float函数的典型用法代码示例。如果您正苦于以下问题:Python img_as_float函数的具体用法?Python img_as_float怎么用?Python img_as_float使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了img_as_float函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: mpl_image_to_rgba

def mpl_image_to_rgba(mpl_image):
    """Return RGB image from the given matplotlib image object.

    Each image in a matplotlib figure has its own colormap and normalization
    function. Return RGBA (RGB + alpha channel) image with float dtype.

    Parameters
    ----------
    mpl_image : matplotlib.image.AxesImage object
        The image being converted.

    Returns
    -------
    img : array of float, shape (M, N, 4)
        An image of float values in [0, 1].
    """
    image = mpl_image.get_array()
    if image.ndim == 2:
        input_range = (mpl_image.norm.vmin, mpl_image.norm.vmax)
        image = rescale_intensity(image, in_range=input_range)
        # cmap complains on bool arrays
        image = mpl_image.cmap(img_as_float(image))
    elif image.ndim == 3 and image.shape[2] == 3:
        # add alpha channel if it's missing
        image = np.dstack((image, np.ones_like(image)))
    return img_as_float(image)
开发者ID:almarklein,项目名称:scikit-image,代码行数:26,代码来源:core.py


示例2: crop_image

def crop_image(x, target_height=227, target_width=227):

    if isinstance(x, str):
        image = skimage.img_as_float(skimage.io.imread(x)).astype(np.float32)
    else:
        image = skimage.img_as_float(x).astype(np.float32)

    if len(image.shape) == 2:
        image = np.tile(image[:,:,None], 3)
    elif len(image.shape) == 4:
        image = image[:,:,:,0]

    height, width, rgb = image.shape
    if width == height:
        resized_image = cv2.resize(image, (target_height,target_width))

    elif height < width:
        resized_image = cv2.resize(image, (int(width * float(target_height)/height), target_width))
        cropping_length = int((resized_image.shape[1] - target_height) / 2)
        resized_image = resized_image[:,cropping_length:resized_image.shape[1] - cropping_length]

    else:
        resized_image = cv2.resize(image, (target_height, int(height * float(target_width) / width)))
        cropping_length = int((resized_image.shape[0] - target_width) / 2)
        resized_image = resized_image[cropping_length:resized_image.shape[0] - cropping_length,:]

    return cv2.resize(resized_image, (target_height, target_width))
开发者ID:jazzsaxmafia,项目名称:video_recognition,代码行数:27,代码来源:cnn_util.py


示例3: __init__

    def __init__(self, headers, lightfield_name, darkfield_name):
        """
        Load images from a detector for given Header(s). Subtract
        dark images from each corresponding light image automatically.

        Parameters
        ----------
        headers : Header or list of Headers
        lightfield_name : str
            alias (data key) of lightfield images
        darkfield_name : str
            alias (data key) of darkfield images

        Example
        -------
        >>> header = DataBroker[-1]
        >>> images = SubtractedImages(header, 'my_lightfield', 'my_darkfield')
        >>> for image in images:
                # do something
        """
        self.light = Images(headers, lightfield_name)
        self.dark = Images(headers, darkfield_name)
        if len(self.light) != len(self.dark):
            raise ValueError("The streams from {0} and {1} have unequal "
                             "length and cannot be automatically subtracted.")
        self._len = len(self.light)
        example = img_as_float(self.light[0]) - img_as_float(self.dark[0])
        self._dtype = example.dtype
        self._shape = example.shape
开发者ID:giltis,项目名称:dataportal,代码行数:29,代码来源:pims_readers.py


示例4: transform_image

def transform_image(image, params=[], tags=[]):
    image = apply_tags(image, tags)
    image = extract_roi(image, params)
    for k,v in params:
        if k=='saturation':
            saturation = float(v)
            image = scale_saturation(image, saturation)
        elif k=='gamma':
            gamma = float(v)
            image = np.power(img_as_float(image), gamma)
        elif k=='brightness':
            b = float(v)
            image = (img_as_float(image) * b).clip(0.,1.)
        elif k=='width':
            scale = float(v) / image.shape[1]
            image = rescale(image, scale)
        elif k=='maxwidth':
            w = float(v)
            if image.shape[1] > w:
                scale = w / image.shape[1]
                image = rescale(image, scale)
        elif k=='height':
            scale = float(v) / image.shape[0]
            image = rescale(image, scale)
        elif k=='maxheight':
            h = float(v)
            if image.shape[0] > h:
                scale = h / image.shape[0]
                image = rescale(image, scale)
    return image
开发者ID:joefutrelle,项目名称:habcam-image-service,代码行数:30,代码来源:transform.py


示例5: repeated_sales

def repeated_sales(df, artistname, artname, r2thresh=7000, fftr2thresh=10000, IMAGES_DIR='/home/ryan/asi_images/'):
    """
        Takes a dataframe, artistname and artname and tries to decide, via image matching, if there is a repeat sale. Returns a dict of lot_ids, each entry a list of repeat sales
    """
    artdf = df[(df['artistID']==artistname) & (df['artTitle']==artname)]

    artdf.images = artdf.images.apply(getpath)
    paths = artdf[['_id','images']].dropna()
    id_dict = {}
    img_buffer = {}
    already_ordered = []
    for i, path_i in paths.values:
        id_dict[i] = []
        img_buffer[i] = img_as_float(rgb2gray(resize(imread(IMAGES_DIR + path_i), (300,300))))
        for j, path_j in paths[paths._id != i].values:
            if j > i and j not in already_ordered:
                if j not in img_buffer.keys():
                    img_buffer[j] = img_as_float(rgb2gray(resize(imread(IMAGES_DIR + path_j), (300,300))))
                if norm(img_buffer[i] - img_buffer[j]) < r2thresh and\
                        norm(fft2(img_buffer[i]) - fft2(img_buffer[j])) < fftr2thresh:
                    id_dict[i].append(j)
                    already_ordered.append(j)
    for key in id_dict.keys():
        if id_dict[key] == []:
            id_dict.pop(key)
    return id_dict
开发者ID:rhsimplex,项目名称:artsift,代码行数:26,代码来源:art_utils.py


示例6: main

def main():
    img = imread('givenImg.png')
    img = img_as_float(img)
    subplot(1, 3, 1)
    imshow(imread('givenImg.png'))
    title('Given')
    figure()
    gray()
    """
    >>>img = imread('givenImg.png')
    >>>img = img_as_float(img)
    >>>energy=dual_gradient_energy(img)
    >>>minval,minIndex,sOfIJ=find_seam(img,energy)
    >>>print minval
    0.488050766739
    """
    for i in range(50): #Plot 50 Seams
        energy = dual_gradient_energy(img)
        minval, minIndex, sOfIJ = find_seam(img, energy)
        img = plot_seam(img, minIndex, sOfIJ)
    subplot(1, 3, 2)
    imshow(img)
    title('Seam Plot')
    img = imread('givenImg.png')
    img = img_as_float(img)
    for i in range(50): #Delete 50 Seams
        energy = dual_gradient_energy(img)
        minval, minIndex, sOfIJ = find_seam(img, energy)
        print minval
        img = remove_seam(img, minIndex, sOfIJ)
    subplot(1, 3, 3)
    imshow(img)
    title('Resized Image')
    show()
    pass
开发者ID:mpatward,项目名称:Seam-Carving-Algorithm,代码行数:35,代码来源:seamcarver.py


示例7: readTrainingFragment

def readTrainingFragment(datapath, fragList, imgSize=(1,224,224), meanImage=[], classNum=10):
    ch, ih, iw = imgSize
    fragLen = len(fragList)
    if ch == 1:
        X = np.zeros((fragLen, 1, ih, iw))
        Y = np.zeros((fragLen), dtype=int)
        idx = -1
        print('reading data')
        for f in fragList:
            idx += 1
            # print(f)
            label = np.int(f[0])
            img = skimage.img_as_float(skio.imread(datapath+f) )
#            img -= meanImage
            X[idx, 0, ...] = img
            Y[idx] = label
    elif ch == 3:
        X = np.zeros((fragLen, 3, ih, iw))
        Y = np.zeros((fragLen), dtype=int)
        idx = -1
        print('reading data')
        for f in fragList:
            idx += 1
            label = np.int(f[0])
            img = skimage.img_as_float(skio.imread(datapath+f) )
            img = img.swapaxes(1, 2)
            img = img.swapaxes(0, 1)
#            img -= meanImage
            X[idx, ...] = img
            Y[idx] = label
    X -= np.tile(meanImage, [fragLen, 1, 1, 1])
    Y = np_utils.to_categorical(Y, classNum)
    return X, Y
开发者ID:fucusy,项目名称:kaggle-state-farm-distracted-driver-detection,代码行数:33,代码来源:DataReader_KERAS.py


示例8: readTestingFragment

def readTestingFragment(datapath, fragList, imgSize=(1,224,224), meanImage=[]):
    ch, ih, iw = imgSize
    fragLen = len(fragList)
    if ch == 1:
        X = np.zeros((fragLen, 1, ih, iw))
        idx = -1
        print('reading data')
        for f in fragList:
            idx += 1
            # print(f)
            img = skimage.img_as_float(skio.imread(datapath+f) )
#            img -= meanImage
            X[idx, 0, ...] = img
    elif ch == 3:
        X = np.zeros((fragLen, 3, ih, iw))
        idx = -1
        print('reading data')
        for f in fragList:
            idx += 1
            img = skimage.img_as_float(skio.imread(datapath+f) )
            img = img.swapaxes(1, 2)
            img = img.swapaxes(0, 1)
#            img -= meanImage
            X[idx, ...] = img
    X -= np.tile(meanImage, [fragLen, 1, 1, 1])
    return X
开发者ID:fucusy,项目名称:kaggle-state-farm-distracted-driver-detection,代码行数:26,代码来源:DataReader_KERAS.py


示例9: find_movement

def find_movement():
    # img = imread('shot1.jpg')
    # img2 = imread('shot2.jpg')
    img = imread("frame0.jpg")
    img2 = imread("frame2.jpg")
    img1 = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
    img2 = cv2.cvtColor(img2, cv2.COLOR_BGR2GRAY)
    img1 = img_as_float(img1)
    img2 = img_as_float(img2)
    # print img1
    h1, w1 = img1.shape
    h2, w2 = img2.shape

    img3 = zeros((h1, w1))

    for x in range(0, h1 - 1):
        for y in range(0, w1 - 1):
            if abs(img1[x, y] - img2[x, y]) > 0.01:
                # print img1[x, y], " ", img2[x, y]
                img3[x, y] = 1

    figure()
    # subplot(1, 2, 1), imshow(img)
    # subplot(1, 2, 2), \
    imshow(img3)
    show()
开发者ID:bks2009,项目名称:ImageDeepLearning,代码行数:26,代码来源:Subtraction.py


示例10: computeMeanImage

def computeMeanImage(trainingPath, testingPath, savePath, imgSize):
    ch, ih, iw = imgSize
    meanImage = np.zeros((ch, ih, iw))
    print('computing mean image')
    folder = os.listdir(trainingPath)
    trainNum = 0
    for f in folder:
        if not f[-4:] == '.jpg':
            continue
        img = skimage.img_as_float( skio.imread(trainingPath+f) )
        trainNum += 1
        if ch == 3:
            img = img.swapaxes(1, 2)
            img = img.swapaxes(0, 1)
        meanImage += img
    
    folder = os.listdir(testingPath)
    testNum = 0
    for f in folder:
        if not f[-4:] == '.jpg':
            continue
        img = skimage.img_as_float( skio.imread(testingPath+f) )
        testNum += 1
        if ch == 3:
            img = img.swapaxes(1, 2)
            img = img.swapaxes(0, 1)
        meanImage += img
    meanImage /= (trainNum + testNum)
    with open(savePath, 'wb') as f:
        np.save(f, meanImage)
开发者ID:fucusy,项目名称:kaggle-state-farm-distracted-driver-detection,代码行数:30,代码来源:DataReader_KERAS.py


示例11: compute_mean_image

def compute_mean_image(training_data_path, testing_data_path, save_flag=True, save_file=''):
    print('computing mean images')
    folder = os.listdir(training_data_path)
    trainNum = len(folder)
    init_flag = True
    for f in folder:
        img = skimage.img_as_float( skio.imread(training_data_path+f) )
        if init_flag:
            mean_image = img
            init_flag = False
        else:
            mean_image += img
    
    folder = os.listdir(testing_data_path)
    testNum = len(folder)
    for f in folder:
        img = skimage.img_as_float( skio.imread(testing_data_path+f) )
        mean_image += img
    
    mean_image /= (trainNum + testNum)
    
    
    if len(mean_image.shape) == 2:
        '''if gray, (h, w) to (1, h, w)'''
        tmp = np.zeros((1, mean_image.shape[0], mean_image.shape[1]))
        tmp[0, ...] = mean_image
        mean_image = tmp
    else:
        '''if color, swap (h, w, ch) to (ch, h, w)'''
        mean_image = mean_image.swapaxes(1,2)
        mean_image = mean_image.swapaxes(0,1)
    if save_flag:
        with open(save_file, 'wb') as f:
            np.save(f, mean_image)
    return mean_image
开发者ID:fucusy,项目名称:kaggle-state-farm-distracted-driver-detection,代码行数:35,代码来源:data_tools.py


示例12: image_compare

def image_compare(df, IMAGES_DIR='/home/ryan/asi_images/'):
    '''
    takes a list of n image ids and returns sum(n..n-1) n comparisons of r2 difference, r2(fft) difference, and average number of thresholded pixels
    '''
    img_buffer = {}
    return_list = []
    artdf = df[['_id', 'images']].copy()
    artdf.images = artdf.images.apply(getpath) 
    paths = artdf[['_id','images']].dropna()
    paths.index = paths._id
    paths = paths.images
    if paths.shape[0] < 2:
        return DataFrame([])
    for id_pair in combinations(paths.index, 2):
        if id_pair[0] in img_buffer:
            img1 = img_buffer[id_pair[0]]
        else:
            img_buffer[id_pair[0]] = img_as_float(rgb2gray(resize(imread(IMAGES_DIR + paths[id_pair[0]]), (300,300))))
            img1 = img_buffer[id_pair[0]]
        
        if id_pair[1] in img_buffer:
            img2 = img_buffer[id_pair[1]]
        else:
            img_buffer[id_pair[1]] = img_as_float(rgb2gray(resize(imread(IMAGES_DIR + paths[id_pair[1]]), (300,300))))
            img2 = img_buffer[id_pair[1]]
        return_list.append(
                [id_pair[0], id_pair[1], \
                    norm(img1 - img2), \
                    norm(fft2(img1) - fft2(img2)), \
                    #mean([sum(img1 > threshold_otsu(img1)), sum(img2 > threshold_otsu(img2))])]
                    #mean([sum(img1 > 0.9), sum(img2 > 0.9)])] 
                    std(img1)+std(img2)/2.]
       )
    return DataFrame(return_list, columns=['id1','id2','r2diff', 'fftdiff', 'stdavg'])
开发者ID:rhsimplex,项目名称:artsift,代码行数:34,代码来源:art_utils.py


示例13: main

def main():
    img = img_as_float(imread("HJoceanSmall.png"))
    img_seam_v = img_as_float(imread("HJoceanSmall.png"))
    img_transformed_v = img_as_float(imread("HJoceanSmall.png"))
    iterations = 20
    img_seam_v, img_transformed_v = seam_carve(iterations, img_seam_v, img_transformed_v)

    figure()

    subplot(221)
    imshow(img)
    title("1. Original")

    subplot(222)
    imshow(img_seam_v)
    title("2. Seam carved vertical")

    # Transposed Image

    img_seam_hv = img_transformed_v.transpose(1, 0, 2)
    img_transformed_hv = img_transformed_v.transpose(1, 0, 2)
    iterations = 20

    img_seam_hv, img_transformed_hv = seam_carve(iterations, img_seam_hv, img_transformed_hv)

    subplot(223)
    imshow(img_seam_hv.transpose(1, 0, 2))
    title("3. Seam carved horizontal")

    subplot(224)
    imshow(img_transformed_hv.transpose(1, 0, 2))
    title("4. Transformed Image")

    show()
开发者ID:srikiranpanchavati,项目名称:DataStructures,代码行数:34,代码来源:seamcarver.py


示例14: test_copy

def test_copy():
    x = np.array([1], dtype=np.float64)
    y = img_as_float(x)
    z = img_as_float(x, force_copy=True)

    assert y is x
    assert z is not x
开发者ID:GerardoLopez,项目名称:scikits-image,代码行数:7,代码来源:test_dtype.py


示例15: main

def main(image):

    matplotlib.rcParams["font.size"] = 10

    def show_img(img, axes):
        """Plot the image as float"""
        # img = img_as_float(img)
        ax_img = axes
        ax_img.imshow(img, cmap=plt.cm.gray)
        ax_img.set_axis_off()

        return ax_img

    # Open and read in the fits image
    try:
        fits = pyfits.open(image)
        # fits = Image.open(image)
    except IOError:
        print "Can not read the fits image: " + image + " !!"

    # Check the input image
    img = fits[0].data
    # img = np.array(fits)
    if img.ndim != 2:
        raise NameError("Data need to be 2-D image !")

    # Logrithm scaling of the image
    img_log = np.log10(img)
    img_log = img_as_float(img_log)

    # Contrast streching
    p5, p95 = np.percentile(img, (2, 98))
    img_rescale = exposure.rescale_intensity(img, in_range=(p5, p95))

    # Adaptive equalization
    img_new = bytescale(img_rescale)
    img_ahe = exposure.equalize_adapthist(img_new, ntiles_x=16, ntiles_y=16, clip_limit=0.05, nbins=256)
    img_ahe = img_as_float(img_ahe)

    # Display results
    fig, axes = plt.subplots(nrows=1, ncols=3, figsize=(16, 5))

    # Original image
    ax_img = show_img(img_log, axes[0])
    ax_img.set_title("Original")

    # Contrast Enhanced one
    ax_img = show_img(img_rescale, axes[1])
    ax_img.set_title("Rescale")

    # AHE Enhanced one
    ax_img = show_img(img_ahe, axes[2])
    ax_img.set_title("AHE")

    # Prevent overlap of y-axis
    fig.subplots_adjust(bottom=0.1, right=0.9, top=0.9, left=0.1, wspace=0.05)

    # Save a PNG file
    plt.gcf().savefig("ahe_test.png")
开发者ID:dr-guangtou,项目名称:hs_python,代码行数:59,代码来源:hs_local_ahe.py


示例16: test_bounding_values

def test_bounding_values():
    image = img_as_float(data.page())
    template = np.zeros((3, 3))
    template[1, 1] = 1
    result = match_template(img_as_float(data.page()), template)
    print(result.max())
    assert result.max() < 1 + 1e-7
    assert result.min() > -1 - 1e-7
开发者ID:TheArindham,项目名称:scikit-image,代码行数:8,代码来源:test_template.py


示例17: main

def main():
    """
    >>> img = imread('C:\Users\DELL\PycharmProjects\cc3\image.png')
    >>> img = img_as_float(img)
    >>> energy = dual_gradient_energy(img)
    >>> minVal,minIndex,sOfTJ=find_seam(img,energy)
    >>> img_modified, path = plot_seam(img, minIndex, sOfTJ)
    >>> print minVal
    0.488050766739
    """
    img = imread("C:\Users\DELL\PycharmProjects\cc3\image.png")
    img = img_as_float(img)
    R = img[:, :, 0]
    G = img[:, :, 1]
    B = img[:, :, 2]
    figure(1)
    gray()
    subplot(1, 4, 1)
    imshow(img)
    title("RGB")
    subplot(1, 4, 2)
    imshow(R)
    title("Red")
    subplot(1, 4, 3)
    imshow(G)
    title("Green")
    subplot(1, 4, 4)
    imshow(B)
    title("Blue")
    show()
    energy = dual_gradient_energy(img)
    figure(2)
    subplot(2, 1, 1)
    imshow(energy)
    title("Dual Energy Gradient")
    show()

    for i in range(50):
        energy = dual_gradient_energy(img)
        val, index, seam = find_seam(img, energy)
        img1, path = plot_seam(img, index, seam)
    figure(3)
    subplot(3, 2, 1)
    imshow(img1)
    title("Seams Plotted")
    img = imread('C:\Users\DELL\PycharmProjects\cc3\image.png')
    img = img_as_float(img)
    for i in range(50):
        energy = dual_gradient_energy(img)
        val, index, seam = find_seam(img, energy)
        img1, path = plot_seam(img, index, seam)
        img = remove_seam(img1, path)
    subplot(3, 2, 2)
    imshow(img)
    title("Seams Removed")
    show()
开发者ID:richsta,项目名称:SER501,代码行数:56,代码来源:seamcarving.py


示例18: mpl_image_to_rgba

def mpl_image_to_rgba(mpl_image):
    """Return RGB image from the given matplotlib image object.

    Each image in a matplotlib figure has it's own colormap and normalization
    function. Return RGBA (RGB + alpha channel) image with float dtype.
    """
    input_range = (mpl_image.norm.vmin, mpl_image.norm.vmax)
    image = rescale_intensity(mpl_image.get_array(), in_range=input_range)
    image = mpl_image.cmap(img_as_float(image)) # cmap complains on bool arrays
    return img_as_float(image)
开发者ID:Autodidact24,项目名称:scikit-image,代码行数:10,代码来源:core.py


示例19: preprocess

def preprocess(im, blur=True, boxcar=True, noise_size=1, boxcar_width=5):
    """
    Perform bluring and background subtraction of image.

    Parameters
    ----------
    im : ndarray
        Image to preprocess.
    blur : bool
        If True, perform a Gaussian blur on each image.
    boxcar : bool
        If True, perfrom a boxcar (mean) filter to compute background.
        The background is then subtracted.
    noise_size : float
        The characteristic length scale of noise in the images
        in units of pixels.  This is used to set the sigma value
        in the Gaussian blur.  Ignored if blur is False.
    boxcar_width : int
        Width of the boxcar filter.  Should be an odd integer greater
        than the pixel radius, but smaller than interparticle distance.

    Returns
    -------
    output : ndarray, shape as im, dtype float
        Blurred, background subtracted image.
    """

    # Convert the image to float
    im = skimage.img_as_float(im)

    # Return image back if we do nothing
    if not blur and not boxcar:
        return skimage.img_as_float(im)

    # Compute background using boxcar (mean) filter
    if boxcar:
        if boxcar_width % 2 == 0:
            raise ValueError('boxcar_width must be odd.')

        # Perform mean filter with a square structuring element
        im_bg = scipy.ndimage.uniform_filter(im, boxcar_width)
    else:
        im_bg = 0.0

    # Perform Gaussian blur
    if blur:
        im_blur = skimage.filters.gaussian(im, noise_size)
    else:
        im_blur = im

    # Subtract background from blurred image
    bg_subtracted_image = im_blur - im_bg

    # Set negative values to zero and return
    return np.maximum(bg_subtracted_image, 0)
开发者ID:acorbe,项目名称:simple-particle-tracker,代码行数:55,代码来源:particle_find.py


示例20: compute_mean_image

def compute_mean_image(training_data_path
                       , testing_data_path
                       , save_file):

    if os.path.exists(save_file):
        logging.info("mean file already exists at %s, return it directly" % save_file)

        mean_img = skio.imread(save_file)
        logging.info("mean img is %s" % mean_img)
        return mean_img
    logging.info('computing mean images')
    folder = ["c%d" % x for x in range(10)]
    total_num = 0
    mean_image = None
    # count image first
    for train_path in training_data_path:
        for f in folder:
            folder_path = os.path.join(train_path, f)
            total_num += len(load_image_path_list(folder_path))

    for path in testing_data_path:
        total_num += len(load_image_path_list(path))

    i = 0
    for train_path in training_data_path:
        for f in folder:
            folder_path = os.path.join(train_path, f)
            for img_path in load_image_path_list(folder_path):
                i += 1
                if i % 100 == 0:
                    logging.info("process %d/%d images now" % (i, total_num))
                img = skimage.img_as_float(skio.imread(img_path))
                if mean_image is None:
                    mean_image = np.zeros(img.shape)
                mean_image += img / total_num

    for path in testing_data_path:
        for file_path in load_image_path_list(path):
            i += 1
            if i % 100 == 0:
                logging.info("process %d/%d images now" % (i, total_num))
            img = skimage.img_as_float( skio.imread(file_path))
            mean_image += img / total_num
        
    if save_file != "":
        base_path = os.path.dirname(save_file)
        if not os.path.exists(base_path):
            os.makedirs(base_path)
        with open(save_file, 'wb') as f:
            imsave(f, mean_image)
            logging.debug("saving mean file to %s" % save_file)
    print mean_image
    return mean_image
开发者ID:fucusy,项目名称:gait-simple-cnn,代码行数:53,代码来源:data_tools.py



注:本文中的skimage.img_as_float函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python skimage.img_as_ubyte函数代码示例发布时间:2022-05-27
下一篇:
Python numerics.Gaussian类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap