当前位置: 首页>>代码示例>>Python>>正文


Python color.rgb2hed函数代码示例

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


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

示例1: load_list_files

def load_list_files(filename):
    """
    load all data form the file of list data
    """
    files = []
    data = []
    hist_data = []
    labels = []
    with open(filename, "r") as f:
        files = [line.strip() for line in f.readlines()]

    for img in files:
        label = img[-5:-4]
        labels.append(float(label))
        image = cv2.imread(img, flags=1)
        hed = cv2.split(rgb2hed(image))[1]
        hed = img_as_ubyte(hed)
        hist = cv2.calcHist([hed], [0], None, [256], [0, 256]).flatten()
        hist_data.append(hist)
        _, region = preprocessor.run(image)
        region = cv2.resize(region, (256, 256))
        lbp_hist, lbp_img = lbp.compute(region)
        # com.debug_im(lbp_img)
        lbp_img = cv2.resize(lbp_img, (30, 30))
        lbp_img = np.nan_to_num(lbp_img)
        data.append(lbp_img.flatten())
        # data.append(lbp_hist)

    data = np.array(data, dtype=np.float32)
    hist_data = np.array(hist_data, dtype=np.float32)
    return data, labels, hist_data
开发者ID:dangkhoasdc,项目名称:CellCounter,代码行数:31,代码来源:allidb2_hist.py

示例2: color_conversion

def color_conversion(img):
    # This function converts rgb image to the IHC color space, where channel 1 is Hematoxylin, 2 in Eosin and 3 is DAB

    ihc_rgb = skimage.io.imread(img)
    ihc_hed = rgb2hed(ihc_rgb)

    return ihc_rgb, ihc_hed
开发者ID:AidanRoss,项目名称:histology,代码行数:7,代码来源:ihc_analysis.py

示例3: run

    def run(self, image):
        assert image.size > 0
        hed = cv2.split(rgb2hed(image))[1]
        hed = img_as_ubyte(1.0 - hed)
        # hed = 1.0 - hed
        hed = rescale_intensity(hed)
        im = hed
        # im = img_as_ubyte(hed)
        # com.debug_im(im)
        im[im >= 115] = 255
        im[im < 115] = 0
        im = rank.enhance_contrast(im, disk(5))
        im = morph.close(im, disk(3))

        can = cv2.adaptiveBilateralFilter(im,
                                          self.bilateral_kernel,
                                          self.sigma_color)
        return can
开发者ID:dangkhoasdc,项目名称:CellCounter,代码行数:18,代码来源:hed_bilateral.py

示例4: salvarcombinacoes

def salvarcombinacoes(img):
    img_rgb = color.convert_colorspace(img, 'RGB', 'RGB')
    img_hsv = color.convert_colorspace(img_rgb, 'RGB', 'HSV')
    img_lab = color.rgb2lab(img_rgb)
    img_hed = color.rgb2hed(img_rgb)
    img_luv = color.rgb2luv(img_rgb)
    img_rgb_cie = color.convert_colorspace(img_rgb, 'RGB', 'RGB CIE')
    img_xyz = color.rgb2xyz(img_rgb)
    img_cmy = rgb2cmy(img_rgb)

    lista = [img_rgb, img_hsv, img_lab, img_hed, img_luv, img_rgb_cie, img_xyz, img_cmy]
    lista2 = ["rgb", "hsv", "lab", "hed", "luv", "rgb_cie", "xyz", "cmy"]
    for i in range(len(lista)):
        for j in range(len(lista)):
            for k in range(3):
                for l in range(3):
                    nome = lista2[i] + str(k) + lista2[j] + str(l) + ".jpg"
                    io.imsave(nome, juntarcanais(lista[i][:, :,k], lista[j][:, :, l]), )

    return
开发者ID:ssscassio,项目名称:PathoSpotter,代码行数:20,代码来源:extrairmagenta.py

示例5: _apply_

    def _apply_(self, *image):
        res = ()
        n_img = 0
        for img in image:
            if n_img == 0:

                dec_img = color.rgb2hed(img)
                ### perturbe each channel H, E, Dab
                for i in range(3):
                    k_i = self.params['k'][i]
                    b_i = self.params['b'][i]
                    dec_img[:,:,i] = GreyValuePerturbation(dec_img[:, :, i], k_i, b_i)
                sub_res = color.hed2rgb(dec_img).astype('uint8')

                ### Have to implement deconvolution of the deconvolution


            else:
                sub_res = img

            res += (sub_res,)
            n_img += 1
        return res
开发者ID:PeterJackNaylor,项目名称:PhD_Fabien,代码行数:23,代码来源:ImageTransf.py

示例6: processhed

def processhed(imagefile, algorithm):
    """Process images with different algorithms"""
    image = plt.imread(StringIO.StringIO(imagefile), format="JPG")

    ihc_hed = rgb2hed(image)

    if algorithm == '01':
        result = plt.cm.gray(rescale_intensity(ihc_hed[:, :, 0],
                                               out_range=(0, 1)))
    elif algorithm == '02':
        result = plt.cm.gray(rescale_intensity(ihc_hed[:, :, 1],
                                               out_range=(0, 1)))
    elif algorithm == '03':
        result = plt.cm.gray(rescale_intensity(ihc_hed[:, :, 2],
                                               out_range=(0, 1)))
    else:
        result = image

    output = StringIO.StringIO()
    plt.imsave(output, result, format="PNG")
    contents = output.getvalue()
    output.close()

    return contents
开发者ID:andor-pierdelacabeza,项目名称:pypatho,代码行数:24,代码来源:processors.py

示例7: test_hed_rgb_float_roundtrip

 def test_hed_rgb_float_roundtrip(self):
     img_rgb = img_as_float(self.img_rgb)
     assert_array_almost_equal(hed2rgb(rgb2hed(img_rgb)), img_rgb)
开发者ID:AceHao,项目名称:scikit-image,代码行数:3,代码来源:test_colorconv.py

示例8: print

import matplotlib.pyplot as plt
from skimage.color import rgb2hed
import cv2
import numpy as np
import sys

print("python: ",str(sys.argv[1]))
img = cv2.imread(str(sys.argv[1]),1)
#img = cv2.imread("Training Data/A03/frames/x40/A03_00Aa.tiff",1)
#img = cv2.pyrDown(img)
ihc_hed = rgb2hed(img)

min,max,minLoc,maxLoc = cv2.minMaxLoc(ihc_hed[:,:,2])
print min,max

ihc_hed = np.array(ihc_hed,dtype = 'float32');
ret,thresh = cv2.threshold(ihc_hed[:,:,2],min+(max-min)*0.5,255,cv2.THRESH_BINARY);
#thresh = ihc_hed[:,:,2]
#ret = 0
kernelSize = 5
kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE,(kernelSize,kernelSize))
#thresh = cv2.erode(thresh,kernel,iterations=2)
#thresh = cv2.dilate(thresh,kernel,iterations=2)
#thresh = cv2.morphologyEx(thresh,cv2.MORPH_OPEN,kernel, iterations=1)
thresh = cv2.convertScaleAbs(thresh);thresh = cv2.medianBlur(thresh,9)
#print ret

#cv2.imshow("1",thresh)
cv2.imwrite(sys.argv[2],thresh)
#cv2.waitKey(0)
开发者ID:arnaghosh,项目名称:mitotic-figure-detection,代码行数:30,代码来源:reg2hedTest.py

示例9: test_hed_rgb_roundtrip

 def test_hed_rgb_roundtrip(self):
     img_rgb = img_as_ubyte(self.img_rgb)
     assert_equal(img_as_ubyte(hed2rgb(rgb2hed(img_rgb))), img_rgb)
开发者ID:A-0-,项目名称:scikit-image,代码行数:3,代码来源:test_colorconv.py

示例10: test_hed_rgb_roundtrip

 def test_hed_rgb_roundtrip(self):
     img_rgb = img_as_ubyte(self.img_rgb)
     with expected_warnings(['precision loss']):
         new = img_as_ubyte(hed2rgb(rgb2hed(img_rgb)))
     assert_equal(new, img_rgb)
开发者ID:AceHao,项目名称:scikit-image,代码行数:5,代码来源:test_colorconv.py

示例11: rgb2hed

from mahotas.features import texture, zernike_moments
import pywt
from scipy.stats.stats import skew, kurtosis
from Tamura import Tamura
from scipy.stats.mstats_basic import mquantiles

"""
    Constant for L resizing
"""
rangeL = (1.0 / 0.95047) * 116.0 - 16.0

"""
    Constants for HEDAB resizing
"""
imageTest = np.array([[[255, 0, 0]]], dtype=np.uint8)
minH = rgb2hed(imageTest)[0][0][0]
imageTest = np.array([[[0, 255, 255]]], dtype=np.uint8)
maxH = rgb2hed(imageTest)[0][0][0]
rangeH = maxH - minH
imageTest = np.array([[[0, 255, 0]]], dtype=np.uint8)
minE = rgb2hed(imageTest)[0][0][1]
imageTest = np.array([[[255, 0, 255]]], dtype=np.uint8)
maxE = rgb2hed(imageTest)[0][0][1]
rangeE = maxE - minE
imageTest = np.array([[[0, 0, 255]]], dtype=np.uint8)
minDAB = rgb2hed(imageTest)[0][0][2]
imageTest = np.array([[[255, 255, 0]]], dtype=np.uint8)
maxDAB = rgb2hed(imageTest)[0][0][2]
rangeDAB = maxDAB - minDAB

"""
开发者ID:kosklain,项目名称:MitosisDetection,代码行数:31,代码来源:ImageWorker.py

示例12:

    ax1.axis("off")
    ax2.axis("off")

    return plt

#Input's Block

    #Single Reader
img = data.imread('img/nor.jpg', False,)
    #Set Reader

#Convert Block
img_rgb = color.convert_colorspace(img, 'RGB', 'RGB') #No need
img_hsv = color.convert_colorspace(img_rgb, 'RGB', 'HSV')
img_lab = color.rgb2lab(img_rgb)
img_hed = color.rgb2hed(img_rgb)
img_luv = color.rgb2luv(img_rgb)
img_rgb_cie = color.convert_colorspace(img_rgb, 'RGB', 'RGB CIE')
img_xyz = color.rgb2xyz(img_rgb)

#Save Test Block
"""io.imsave("image_hsv.jpg", img_hsv, )
io.imsave("image_lab.jpg", img_lab, )
io.imsave("image_hed.jpg", img_hed, )
io.imsave("image_luv.jpg", img_luv, )
io.imsave("image_rgb_cie.jpg", img_rgb_cie, )
io.imsave("image_xyz.jpg", img_xyz, )
"""
#Layers Block
"""
canalExtration(img_rgb, "RGB").show()
开发者ID:ssscassio,项目名称:PathoSpotter,代码行数:31,代码来源:ColorSpace_Analisis.py

示例13: rgb2hed

"""
import matplotlib.pyplot as plt

from skimage import data
from skimage.color import rgb2hed
from matplotlib.colors import LinearSegmentedColormap

# Create an artificial color close to the original one
cmap_hema = LinearSegmentedColormap.from_list('mycmap', ['white', 'navy'])
cmap_dab = LinearSegmentedColormap.from_list('mycmap', ['white',
                                             'saddlebrown'])
cmap_eosin = LinearSegmentedColormap.from_list('mycmap', ['darkviolet',
                                               'white'])

ihc_rgb = data.immunohistochemistry()
ihc_hed = rgb2hed(ihc_rgb)

fig, axes = plt.subplots(2, 2, figsize=(7, 6), sharex=True, sharey=True)
ax = axes.ravel()

ax[0].imshow(ihc_rgb)
ax[0].set_title("Original image")

ax[1].imshow(ihc_hed[:, :, 0], cmap=cmap_hema)
ax[1].set_title("Hematoxylin")

ax[2].imshow(ihc_hed[:, :, 1], cmap=cmap_eosin)
ax[2].set_title("Eosin")

ax[3].imshow(ihc_hed[:, :, 2], cmap=cmap_dab)
ax[3].set_title("DAB")
开发者ID:TheArindham,项目名称:scikit-image,代码行数:31,代码来源:plot_ihc_color_separation.py

示例14: rgb2hed

from skimage.feature import blob_log
from pylab import uint8
from skimage.filter import threshold_otsu
from skimage import img_as_ubyte #Conversão
from PIL import Image
from skimage.morphology import disk
from skimage.color import rgb2hed
from skimage.measure import label, regionprops 

print __doc__

glom_rgb = Image.open('s3.jpg')
glom_gl = glom_rgb.convert('L') #Gray Level

glom_hed = rgb2hed(glom_rgb) #hed
glom_h =  glom_hed[:, :, 0] #hematoxylim
glom_h = ia.ianormalize(glom_h)
selem = disk(10) #elemento estruturante
glom_h = np.array(glom_h) 
glom_h = 255 - uint8(glom_h)

#Segmentation
glom_by_reconsTopHat = morph.closerecth(glom_h,selem) #reconstrução morfológicas de fechamento

global_thresh = threshold_otsu(glom_by_reconsTopHat) #Otsu
glom_bin = glom_by_reconsTopHat > global_thresh + global_thresh*0.1 
glom_bin = img_as_ubyte(glom_bin)
selem = disk(3)    
glom_seg = morph.open(glom_bin, selem)
glom_seg = morph.close(glom_seg, selem) #Fechamento final
开发者ID:geogob,项目名称:PathoSpotter-K,代码行数:30,代码来源:pathoSpotter-K-featuresExtraction.py

示例15: max

data = []

for img in files:
    label = img[-5:-4]
    labels.append(float(label))
    image = cv2.imread(img, flags=1)
    canny, gray = preprocessor.run(image)
    # com.debug_im(image)
    conts = segment.run(canny, gray, image)
    try:
        max_cont = max(conts, key=lambda x: x.area)
    except ValueError:
        print "filename: ", img
        exit()
    # com.debug_im(max_cont.get_region(rgb2hed(image)[1]))
    region = max_cont.get_region(cv2.split(rgb2hed(image))[1])
    # com.debug_im(region)
    max_cont = cv2.resize(region, (30, 30)).flatten()
    data.append(max_cont)

data_train, data_test, labels_train, labels_test = train_test_split(
    data, labels, test_size=0.25)
print "test size: ", len(data_test)
print "train size: ", len(data_train)

# Randomized PCA
components_range = range(2, 300, 6)

scores = []
for n_components in components_range:
    # pca = SparsePCA(n_components, n_jobs=-1).fit(data_train)
开发者ID:dangkhoasdc,项目名称:CellCounter,代码行数:31,代码来源:allidb2_canny.py


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