本文整理汇总了Python中skimage.color.rgb2hed函数的典型用法代码示例。如果您正苦于以下问题:Python rgb2hed函数的具体用法?Python rgb2hed怎么用?Python rgb2hed使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rgb2hed函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: open
filename = "allidb2.txt"
files = []
with open(filename, "r") as f:
files = [line.strip() for line in f.readlines()]
# Create samples and its label
labels = []
data = []
for img in files:
label = img[-5:-4]
labels.append(float(label))
image = cv2.imread(img, flags=1)
image = cv2.split(rgb2hed(image))[1]
image = cv2.resize(image, (40, 40))
data.append(image.flatten())
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)
data_train = np.array(data_train)
# data_train = np.transpose(data_train)
data_test = np.array(data_test)
# data_test = np.transpose(data_test)
# Randomized PCA
n_components = 400
# pca = SparsePCA(n_components, n_jobs=-1).fit(data_train)
# pca = RandomizedPCA(n_components, whiten=True).fit(data_train)
开发者ID:dangkhoasdc,项目名称:CellCounter,代码行数:31,代码来源:eigencell.py
示例17: getBinaryImage
def getBinaryImage(self):
self.ploting = False
HEDAB = rgb2hed(self.image)
R = self.image[:, :, 0]
G = self.image[:, :, 1]
B = self.image[:, :, 2]
H = HEDAB[:, :, 0]
E = HEDAB[:, :, 1]
DAB = HEDAB[:, :, 2]
BR = B * 2 / ((1 + R + G) * (1 + B + R + G)) # Blue-ratio image
V = self.getV() # From HSV
(L, L2) = self.getL() # From CIELAB and CIELUV
BRSmoothed = ndimage.gaussian_filter(BR, 1)
LSmoothed = ndimage.gaussian_filter(L, 1)
VSmoothed = ndimage.gaussian_filter(V, 1)
HSmoothed = ndimage.gaussian_filter(H, 1)
ESmoothed = ndimage.gaussian_filter(E, 1)
RSmoothed = ndimage.gaussian_filter(R, 1)
DABSmoothed = ndimage.gaussian_filter(DAB, 1)
imLLog = self.filterImage(gaussian_laplace(LSmoothed, 9), 85) == False
imVLog = self.filterImage(gaussian_laplace(VSmoothed, 9), 85) == False
imELog = self.filterImage(gaussian_laplace(ESmoothed, 9), 84) == False
imRLog = self.filterImage(gaussian_laplace(RSmoothed, 9), 84) == False
imDABLog = self.filterImage(gaussian_laplace(DABSmoothed, 9), 50)
imHLog = self.filterImage(gaussian_laplace(HSmoothed, 9), 8)
imLog = self.filterImage(gaussian_laplace(BRSmoothed, 9), 9)
imR = self.filterImage(R, 2.5)
imB = self.filterImage(B, 10.5)
imV = self.filterImage(V, 6.5)
imL = self.filterImage(L, 2.5)
imL2 = self.filterImage(L2, 2.5)
imE = self.filterImage(E, 18)
imH = self.filterImage(H, 95) == False
imDAB = self.filterImage(DAB, 55) == False
imBR = self.filterImage(BR, 63) == False
binaryImg = (
imR
& imV
& imB
& imL
& imL2
& imE
& imH
& imDAB
& imLog
& imBR
& imLLog
& imVLog
& imELog
& imHLog
& imRLog
& imDABLog
)
openImg = ndimage.binary_opening(binaryImg, iterations=2)
closedImg = ndimage.binary_closing(openImg, iterations=8)
if self.ploting:
plt.imshow(self.image)
plt.show()
plt.imshow(imR)
plt.show()
plt.imshow(imV)
plt.show()
plt.imshow(imB)
plt.show()
plt.imshow(imL)
plt.show()
plt.imshow(closedImg)
plt.show()
BRVL = np.zeros(self.image.shape)
BRVL[:, :, 0] = BR
BRVL[:, :, 1] = V
BRVL[:, :, 2] = L / rangeL
# ResizeHEDAB, from 0 to 1.
HEDAB[:, :, 0] = (H - minH) / rangeH
HEDAB[:, :, 1] = (E - minE) / rangeE
HEDAB[:, :, 2] = (DAB - minDAB) / rangeDAB
return (
BinaryImageWorker(closedImg, self.rows, self.columns),
RGBImageWorker(HEDAB, self.rows, self.columns),
RGBImageWorker(BRVL, self.rows, self.columns),
BinaryImageWorker(binaryImg, self.rows, self.columns),
)
开发者ID:kosklain,项目名称:MitosisDetection,代码行数:84,代码来源:ImageWorker.py
注:本文中的skimage.color.rgb2hed函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论