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

Python color.gray2rgb函数代码示例

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

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



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

示例1: set_image

    def set_image(self, params, images, background):
        """ creates a strip with the cell in different images
            images is a list of rgb images
            background is a grayscale image to use for the masks
        """

        x0, y0, x1, y1 = self.box
        img = color.gray2rgb(np.zeros((x1 - x0 + 1, (len(images) + 4) * (y1 - y0 + 1))))
        bx0 = 0
        bx1 = x1 - x0 + 1
        by0 = 0
        by1 = y1 - y0 + 1

        for im in images:
            img[bx0:bx1, by0:by1] = im[x0 : x1 + 1, y0 : y1 + 1]
            by0 = by0 + y1 - y0 + 1
            by1 = by1 + y1 - y0 + 1

        perim = self.perim_mask
        axial = self.sept_mask
        cyto = self.cyto_mask
        img[bx0:bx1, by0:by1] = color.gray2rgb(background[x0 : x1 + 1, y0 : y1 + 1] * self.cell_mask)
        by0 = by0 + y1 - y0 + 1
        by1 = by1 + y1 - y0 + 1
        img[bx0:bx1, by0:by1] = color.gray2rgb(background[x0 : x1 + 1, y0 : y1 + 1] * perim)
        by0 = by0 + y1 - y0 + 1
        by1 = by1 + y1 - y0 + 1
        img[bx0:bx1, by0:by1] = color.gray2rgb(background[x0 : x1 + 1, y0 : y1 + 1] * cyto)
        if params.find_septum:
            by0 = by0 + y1 - y0 + 1
            by1 = by1 + y1 - y0 + 1
            img[bx0:bx1, by0:by1] = color.gray2rgb(background[x0 : x1 + 1, y0 : y1 + 1] * axial)
        self.image = img_as_int(img)
开发者ID:brunomsaraiva,项目名称:eHooke_1.0,代码行数:33,代码来源:cells.py


示例2: loadPictures

def loadPictures(data):

    N_hieros = len(data)
    repertory, file = data['anchor'][0].split("_")
    label=str(data['label'][0])

    picture="/Users/fgimbert/Documents/Dataset/Manual/Preprocessed/"+str(repertory)+"/"+str(file)+"_"+label+".png"

    #im = Image.open(picture)


    #img_x=im.size[0]
    #img_y=im.size[1]

    img_x=50
    img_y=75

    anchor, positive, negative = np.zeros((N_hieros,img_x*img_y,3)),np.zeros((N_hieros,img_x*img_y,3)),np.zeros((N_hieros,img_x*img_y,3))
    labels_true = []
    labels_wrong= []


    for index, row in data.iterrows():

        repertory, file = row['anchor'].split("_")
        label = row['label']
        picture = path + str(repertory) + "/" + str(
            file) + "_" + str(label) + ".png"
        labels_true.append(label)

        img_gray = mpimg.imread(picture)
        img_rgb=gray2rgb(img_gray)
        anchor[index]=img_rgb.reshape(1,img_x*img_y,3)

        repertory, file = row['positive'].split("_")
        picture = path + str(repertory) + "/" + str(
            file) + "_" + str(label) + ".png"
        img_gray = mpimg.imread(picture)
        img_rgb = gray2rgb(img_gray)
        positive[index] = img_rgb.reshape(1, img_x * img_y, 3)

        repertory, file = row['negative'].split("_")
        label = row['neg_label']
        picture = path + str(repertory) + "/" + str(
            file) + "_" + str(label) + ".png"
        labels_wrong.append(label)
        img_gray = mpimg.imread(picture)
        img_rgb = gray2rgb(img_gray)
        negative[index] = img_rgb.reshape(1, img_x * img_y, 3)

    return [anchor,positive,negative],labels_true,labels_wrong
开发者ID:fgimbert,项目名称:Hieroglyphs,代码行数:51,代码来源:clean_inwork.py


示例3: _apply

 def _apply(self, imgmsg, maskmsg):
     bridge = cv_bridge.CvBridge()
     img = bridge.imgmsg_to_cv2(imgmsg)
     if img.ndim == 2:
         img = gray2rgb(img)
     mask = bridge.imgmsg_to_cv2(maskmsg, desired_encoding='mono8')
     mask = mask.reshape(mask.shape[:2])
     mask = gray2rgb(mask)
     # compute label
     roi = closed_mask_roi(mask)
     roi_labels = masked_slic(img=img[roi], mask=mask[roi],
                              n_segments=20, compactness=30)
     if roi_labels is None:
         return
     labels = np.zeros(mask.shape, dtype=np.int32)
     # labels.fill(-1)  # set bg_label
     labels[roi] = roi_labels
     if self.is_debugging:
         # publish debug slic label
         slic_labelmsg = bridge.cv2_to_imgmsg(labels)
         slic_labelmsg.header = imgmsg.header
         self.pub_slic.publish(slic_labelmsg)
     # compute rag
     g = rag_solidity(labels, connectivity=2)
     if self.is_debugging:
         # publish debug rag drawn image
         rag_img = draw_rag(labels, g, img)
         rag_img = img_as_uint(rag_img)
         rag_imgmsg = bridge.cv2_to_imgmsg(
             rag_img.astype(np.uint8), encoding='rgb8')
         rag_imgmsg.header = imgmsg.header
         self.pub_rag.publish(rag_imgmsg)
     # merge rag with solidity
     merged_labels = merge_hierarchical(
         labels, g, thresh=1, rag_copy=False,
         in_place_merge=True,
         merge_func=_solidity_merge_func,
         weight_func=_solidity_weight_func)
     merged_labels += 1
     merged_labels[mask == 0] = 0
     merged_labelmsg = bridge.cv2_to_imgmsg(merged_labels.astype(np.int32))
     merged_labelmsg.header = imgmsg.header
     self.pub.publish(merged_labelmsg)
     if self.is_debugging:
         out = label2rgb(merged_labels, img)
         out = (out * 255).astype(np.uint8)
         out_msg = bridge.cv2_to_imgmsg(out, encoding='rgb8')
         out_msg.header = imgmsg.header
         self.pub_label.publish(out_msg)
开发者ID:TakaomiHasegawa,项目名称:jsk_recognition,代码行数:49,代码来源:solidity_rag_merge.py


示例4: overlay_cells

def overlay_cells(cells, image, colors):
    "Overlay the edges of each individual cell in the provided image"

    tmp = color.gray2rgb(image)

    for k in cells.keys():
        c = cells[k]
        if c.selection_state == 1:
            col = colors[c.color_i][:3]

            for px in c.outline:
                x, y = px
                tmp[x, y] = col

            if c.sept_mask is not None:
                try:
                    x0, y0, x1, y1 = c.box
                    tmp[x0:x1, y0:y1] = mark_boundaries(tmp[x0:x1, y0:y1],
                                                        img_as_int(
                                                            c.sept_mask),
                                                        color=col)
                except IndexError:
                    c.selection_state = -1

    return tmp
开发者ID:brunomsaraiva,项目名称:eHooke_1.0,代码行数:25,代码来源:cellprocessing.py


示例5: any2rgb

def any2rgb(array, name=''):
    """ Returns a normalized float 3-channel array regardless of original
    dtype and channel.  All valid pyparty images must pass this

    name : str
        Name of array which will be referenced in logger messages"""

    if not isinstance(array, np.ndarray):
        return to_normrgb(array)

    # *****
    # Quick way to convert to float (don't use img_as_float becase we want
    # to enforce that upperlimit of 255 is checked
    array = array / 1.0  

    # Returns scalar for 1-channel OR 3-channel
    if array.max() > 1:
        # For 8-bit, divide by 255!
        if array.max() > COLORTYPE[1]:
            raise ColorError("Only 8bit ints are supported for now")
        array = array / COLORTYPE[1] 

    if array.ndim == 3:
        # If RGBA
        if array.shape[2] == 4:
            array = array[..., 0:3]
            logger.warn("4-channel RGBA recieved; ignoring A channel")            
        return array 

    elif array.ndim == 2:
        logger.warn('%s color has been converted (1-channel to 3-channel RGB)'
                    % name)
        return skcol.gray2rgb(array)

    raise ColorError('%s must be 2 or 3 dimensional array!' % name )    
开发者ID:hugadams,项目名称:pyparty,代码行数:35,代码来源:utils.py


示例6: main

def main(args):
    """
        Entry point.
    """

    # load the image
    img = imread(args.input)
    if img.ndim == 2:
        img = gray2rgb(img)
    elif img.shape[2] == 4:
        img = img[:, :, :3]
    upper_dim = max(img.shape[:2])
    if upper_dim > args.max_dim:
        img = rescale(img, args.max_dim/float(upper_dim), order=3) 

    # compute saliency
    start = timeit.default_timer()
    img_sal = compute_saliency(img)
    runtime = timeit.default_timer() - start
    print("Took {0} seconds.".format(runtime))

    # save image
    (fname, ext) = os.path.splitext(args.input)
    out_path = fname + "_saliency" + ext
    imsave(out_path, img_sal)
开发者ID:caomw,项目名称:saliency-bms,代码行数:25,代码来源:saliency.py


示例7: prep_image

def prep_image(im, IMAGE_W, IMAGE_H, BGR=BGR, bw=False):
    if len(im.shape) == 2:
        im = im[:, :, np.newaxis]
        im = np.repeat(im, 3, axis=2)
    h, w, _ = im.shape
    if h*IMAGE_W < w*IMAGE_H:
        im = skimage.transform.resize(im, (IMAGE_H, w*IMAGE_H//h), preserve_range=True)
    else:
        im = skimage.transform.resize(im, (h*IMAGE_W//w, IMAGE_W), preserve_range=True)            

    # Central crop
    h, w, _ = im.shape
    im = im[h//2-IMAGE_H//2:h//2+IMAGE_H-IMAGE_H//2, w//2-IMAGE_W//2: w//2-IMAGE_W//2 +IMAGE_W]        
    rawim = im.astype('uint8')
    # Shuffle axes to c01
    if bw:
        if BGR:
            im = im[:,:,::-1]
        bwim = gray2rgb(rgb2gray(im))
        im = (bwim*bw+im.astype("float64")*(1.-bw))
        if BGR:
            im = im[:,:,::-1]
    
    im = np.swapaxes(np.swapaxes(im, 1, 2), 0, 1)
    
    # Convert RGB to BGR
    if not BGR:
        im = im[::-1, :, :]

    im = im - MEAN_VALUES
    return rawim, floatX(im[np.newaxis])
开发者ID:ChunHungLiu,项目名称:Neural-Matching,代码行数:31,代码来源:ns_helpers.py


示例8: add_rectangle

def add_rectangle(img, y0, x0, y1, x1, color="r", width=1):
    """Colors: 'r', 'g', 'b', 'w', 'k'"""
    im = np.copy(img)
    if im.ndim == 2:
        im = gray2rgb(im)
    max_val = 1
    if np.max(img) > 1:
        max_val = 255

    channel = 3  # Bogus value when color = 'w' or 'k'
    if color == "r":
        channel = 0
    if color == "g":
        channel = 1
    if color == "b":
        channel = 2

    for i in range(width):
        yy0 = y0 + i
        xx0 = x0 + i
        yy1 = y1 - i
        xx1 = x1 - i
        rr, cc = line(yy0, xx0, yy1, xx0)  # left
        im = paint_line(im, rr, cc, color, channel, max_val)
        rr, cc = line(yy1, xx0, yy1, xx1)  # bottom
        im = paint_line(im, rr, cc, color, channel, max_val)
        rr, cc = line(yy1, xx1, yy0, xx1)  # right
        im = paint_line(im, rr, cc, color, channel, max_val)
        rr, cc = line(yy0, xx1, yy0, xx0)  # top
        im = paint_line(im, rr, cc, color, channel, max_val)

    return im
开发者ID:robertmcanany,项目名称:coursera_image_processing_duke,代码行数:32,代码来源:inpaint_functions.py


示例9: vis_col_im

def vis_col_im(im, gt):
	indices_0 = np.where(gt == 0) # nothing
	indices_1 = np.where(gt == 1) # necrosis
	indices_2 = np.where(gt == 2) # edema
	indices_3 = np.where(gt == 3) # non-enhancing tumor
	indices_4 = np.where(gt == 4) # enhancing tumor
	
	im = np.asarray(im, dtype='float32')
	im = im*1./im.max()
	rgb_image = color.gray2rgb(im)
	m0 = [1., 1., 1.]
	m1 = [1., 0., 0.]
	m2 = [0.2, 1., 0.2]
	m3 = [1., 1., 0.2]
	m4 = [1., 0.6, 0.2]
	
	im = rgb_image.copy()
	im[indices_0[0], indices_0[1], :] *= m0
	im[indices_1[0], indices_1[1], :] *= m1
	im[indices_2[0], indices_2[1], :] *= m2
	im[indices_3[0], indices_3[1], :] *= m3
	im[indices_4[0], indices_4[1], :] *= m4
	
	plt.imshow(im)
	plt.show()
	plt.close()
开发者ID:jhzhou1111,项目名称:CNNbasedMedicalSegmentation,代码行数:26,代码来源:show_images.py


示例10: process_image

def process_image(sub_folder, image, img_rows, img_cols):
    '''Process individual images'''
    
    # Using the mean pixel values used in VGG16 Model
    mean_pixel = [103.939, 116.779, 123.68]
    image_path = os.path.join(sub_folder, image)
    image_file = imread(image_path)
    
    # If the image has 4 channels, change it to 3 channels
    if len(image_file.shape) > 2 and image_file.shape[2] == 4:
        image_file = image_file[:,:,:-1]
    # If the image is in grey scale, change it to RGB
    if len(image_file.shape) < 3:
        image_file = gray2rgb(image_file)
    image_file = image_file.astype(np.float32, copy=False)
    # There are some images where the actual image we are interested is in 
    # the right side. For such images remove the left half
    if image_file.shape[1] > image_file.shape[0]:
        new_shape = image_file.shape[1] / 2
        image_file = image_file[:,new_shape:,:]
    # one more image pattern
    elif image_file.shape[0] == 1000 & image_file.shape[1] == 677:
        image_file = image_file[:,:455,:]
    image_resized = imresize(image_file, (img_rows, img_cols))
    # normalize the image
    for c in xrange(3):
        image_resized[:, :, c] = image_resized[:, :, c] - mean_pixel[c]
        image_res = image_resized.transpose((2,0,1))
    return image_res
开发者ID:ernest-s,项目名称:Data-Hacks,代码行数:29,代码来源:ernest.py


示例11: markPath

def markPath(mat, path, mark_as='red'):
    assert mark_as in ['red','green','blue','black','white']
    
    if len(mat.shape) == 2:
        mat = color.gray2rgb(mat)
    
    ret = np.zeros(mat.shape)
    ret[:,:,:] = mat[:,:,:]
    
    # Preprocess image
    if np.max(ret) < 1.1 or np.max(ret) > 256: # matrix is in float numbers
        ret -= np.min(ret)
        ret /= np.max(ret)
        ret *= 256
    
    # Determinate components
    if mark_as == 'red':
        r,g,b = 255,0,0
    elif mark_as == 'green':
        r,g,b = 0,255,0
    elif mark_as == 'blue':
        r,g,b = 0,0,255
    elif mark_as == 'white':
        r,g,b = 255,255,255
    elif mark_as == 'black':
        r,b,b = 0,0,0

    # Place R,G,B
    for i in path:
        ret[i[0],i[1],0] = r
        ret[i[0],i[1],1] = g
        ret[i[0],i[1],2] = b
    return ret.astype('uint8')    
开发者ID:Yue93,项目名称:PID,代码行数:33,代码来源:Elimination_YueLin_EnriqueMiralles.py


示例12: load_images

def load_images(path):
    print 'reading file names ... '
    names = [d for d in os.listdir (path) if d.endswith('.jpg')]
    names = natsorted(names)
    num_rows = len(names)
    print names

    print 'making dataset ... '
    test_image = np.zeros((num_rows, num_features), dtype = float)
    label = np.zeros((num_rows, 1), dtype = int)
    file_names = []
    i = 0
    for n in names:
        print n.split('.')[0]

        image = imread(os.path.join(path, n))
        if len(image.shape) == 3 and image.shape[2] == 3:
            image = image.transpose(2, 0, 1)
            test_image[i, 0:num_features] = np.reshape(image, (1, num_features))
            label[i] = n.split('.')[0]
            i += 1
        else:
            image = gray2rgb(image)
            image = image.transpose(2, 0, 1)
            test_image[i, 0:num_features] = np.reshape(image, (1, num_features))
            label[i] = n.split('.')[0]
            i += 1

    return test_image, label
开发者ID:FlorianMuellerklein,项目名称:dogs_vs_cats,代码行数:29,代码来源:make_test.py


示例13: imreadconvert

def imreadconvert(Xname):
    X=imread(Xname).astype(np.float32)
    if len(X.shape)==3:
        X=X.transpose(2,0,1)
        return X
    else:
        return gray2rgb(X).transpose(2,0,1)  
开发者ID:annashcherbina,项目名称:cs231n_project,代码行数:7,代码来源:load_data.py


示例14: get_image

def get_image(fname):
    arr = io.imread(fname)
    if arr.ndim == 2:
        arr = color.gray2rgb(arr)
    arr = util.img_as_float(arr)
    assert arr.ndim == 3
    return arr
开发者ID:npinto,项目名称:kolax,代码行数:7,代码来源:kolax.py


示例15: slics_3D

def slics_3D(im, pseudo_3D=True, n_segments=100, get_slicewise=False):
    if im.ndim != 3:
        raise Exception('3D image is needed.')

    if not pseudo_3D:
        # need to convert to RGB image
        im_rgb = np.zeros((im.shape[0], im.shape[1], im.shape[2], 3))
        im_rgb[:,:,:,0] = im
        im_rgb[:,:,:,1] = im
        im_rgb[:,:,:,2] = im

        suppxls = skiseg.slic(im_rgb, n_segments=n_segments, spacing=(2,1,1))

    else:
        suppxls = np.zeros(im.shape)
        if get_slicewise:
            suppxls_slicewise = np.zeros(im.shape)
        offset = 0
        for i in range(im.shape[0]):
            # suppxl = skiseg.slic(cv2.cvtColor(im[i,:,:], cv2.COLOR_GRAY2RGB), n_segments=n_segments)
            suppxl = skiseg.slic(skicol.gray2rgb(im[i,:,:]), n_segments=n_segments)
            suppxls[i,:,:] = suppxl + offset
            if get_slicewise:
                suppxls_slicewise[i,:,:] = suppxl
            offset = suppxls.max() + 1

    if get_slicewise:
        return suppxls, suppxls_slicewise
    else:
        return suppxls
开发者ID:nagyistoce,项目名称:mazoku-data_viewers,代码行数:30,代码来源:tools_old.py


示例16: writeMask

 def writeMask(self,mask):
     FILL_CHANNEL = 4
     REMOVE_CHANNEL = 8
     imgMasked = np.uint8(255 * color.gray2rgb(color.rgb2gray(self.image)))
     imgMasked[mask == FILL_CHANNEL] = 255
     imgMasked[mask == REMOVE_CHANNEL] = 0
     return imgMasked #imageOut
开发者ID:hanifsudira,项目名称:TA,代码行数:7,代码来源:Main3.py


示例17: _apply

 def _apply(self, img_msg, label_msg):
     bridge = cv_bridge.CvBridge()
     img = bridge.imgmsg_to_cv2(img_msg)
     label_img = bridge.imgmsg_to_cv2(label_msg)
     # publish only valid label region
     applied = img.copy()
     applied[label_img == 0] = 0
     applied_msg = bridge.cv2_to_imgmsg(applied, encoding=img_msg.encoding)
     applied_msg.header = img_msg.header
     self.pub_img.publish(applied_msg)
     # publish visualized label
     if img_msg.encoding in {'16UC1', '32SC1'}:
         # do dynamic scaling to make it look nicely
         min_value, max_value = img.min(), img.max()
         img = (img - min_value) / (max_value - min_value) * 255
         img = gray2rgb(img)
     label_viz_img = label2rgb(label_img, img, bg_label=0)
     label_viz_img = mark_boundaries(label_viz_img, label_img, (1, 0, 0))
     label_viz_img = (label_viz_img * 255).astype(np.uint8)
     label_viz_msg = bridge.cv2_to_imgmsg(label_viz_img, encoding='rgb8')
     label_viz_msg.header = img_msg.header
     self.pub_label_viz.publish(label_viz_msg)
     # publish mask
     if self._publish_mask:
         bg_mask = (label_img == 0)
         fg_mask = ~bg_mask
         bg_mask = (bg_mask * 255).astype(np.uint8)
         fg_mask = (fg_mask * 255).astype(np.uint8)
         fg_mask_msg = bridge.cv2_to_imgmsg(fg_mask, encoding='mono8')
         fg_mask_msg.header = img_msg.header
         bg_mask_msg = bridge.cv2_to_imgmsg(bg_mask, encoding='mono8')
         bg_mask_msg.header = img_msg.header
         self.pub_fg_mask.publish(fg_mask_msg)
         self.pub_bg_mask.publish(bg_mask_msg)
开发者ID:Horisu,项目名称:jsk_recognition,代码行数:34,代码来源:label_image_decomposer.py


示例18: get

    def get(self, uri):
        i = imread(uri)
        if len(i.shape) == 2:
            i = gray2rgb(i)
        else:
            i = i[:, :, :3]
        c = self._image_to_color.get(i)

        dbg = self._settings['debug']
        if dbg is None:
            return c

        c, imgs = c
        b = splitext(basename(uri))[0]
        imsave(join(dbg, b + '-resized.jpg'), imgs['resized'])
        imsave(join(dbg, b + '-back.jpg'), img_as_float(imgs['back']))
        imsave(join(dbg, b + '-skin.jpg'), img_as_float(imgs['skin']))
        imsave(join(dbg, b + '-clusters.jpg'), imgs['clusters'])

        return c, {
            'resized': join(dbg, b + '-resized.jpg'),
            'back': join(dbg, b + '-back.jpg'),
            'skin': join(dbg, b + '-skin.jpg'),
            'clusters': join(dbg, b + '-clusters.jpg'),
        }
开发者ID:algolia,项目名称:color-extractor,代码行数:25,代码来源:from_file.py


示例19: markPath

def markPath(mat, path, mark_as="red"):
    assert mark_as in ["red", "green", "blue", "black", "white"]

    if len(mat.shape) == 2:
        mat = color.gray2rgb(mat)

    ret = np.zeros(mat.shape)
    ret[:, :, :] = mat[:, :, :]

    # Preprocess image
    if np.max(ret) < 1.1 or np.max(ret) > 256:  # matrix is in float numbers
        ret -= np.min(ret)
        ret /= np.max(ret)
        ret *= 256

    # Determinate components
    if mark_as == "red":
        r, g, b = 255, 0, 0
    elif mark_as == "green":
        r, g, b = 0, 255, 0
    elif mark_as == "blue":
        r, g, b = 0, 0, 255
    elif mark_as == "white":
        r, g, b = 255, 255, 255
    elif mark_as == "black":
        r, b, b = 0, 0, 0

    # Place R,G,B
    for i in path:
        ret[i[0], i[1], 0] = r
        ret[i[0], i[1], 1] = g
        ret[i[0], i[1], 2] = b
    return ret.astype("uint8")
开发者ID:Yue93,项目名称:PID,代码行数:33,代码来源:Reduction_Sintesis_YueLin_EnriqueMiralles.py


示例20: transform

    def transform(self, Xb, yb):
        Xb, yb = super(ReadImageBatchIteratorMixin, self).transform(Xb, yb)

        batch_size = min(Xb.shape[0], self.batch_size)
        num_channels = 1 if self.read_image_as_gray is True else 3
        h = self.read_image_size[0]
        w = self.read_image_size[1]

        imgs = np.empty((batch_size, num_channels, h, w), dtype=np.float32)
        for i, path in enumerate(Xb):
            img_fname = os.path.join(self.read_image_prefix_path, path)
            if self.verbose > 2:
                print('Reading %s' % img_fname)
            img = imread(img_fname,
                         as_grey=self.read_image_as_gray)

            if img.shape[0] != h or img.shape[1] != w:
                img = resize(img, (h, w))
            else:
                img = img.astype(float) / 255

            # When reading image as color image, convert grayscale image to RGB for consistency
            if len(img.shape) == 2 and self.read_image_as_gray is False:
                img = gray2rgb(img)

            # Transpose to bc01
            if self.read_image_as_bc01 and self.read_image_as_gray is False:
                img = img.transpose(2, 0, 1)
            elif self.read_image_as_bc01 and self.read_image_as_gray is True:
                img = np.expand_dims(img, axis=0)

            imgs[i] = img
        return imgs, yb
开发者ID:4Catalyzer,项目名称:nolearn_utils,代码行数:33,代码来源:iterators.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python color.hsv2rgb函数代码示例发布时间:2022-05-27
下一篇:
Python utils.assert_nD函数代码示例发布时间: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