本文整理汇总了Python中skimage.color.rgb2xyz函数的典型用法代码示例。如果您正苦于以下问题:Python rgb2xyz函数的具体用法?Python rgb2xyz怎么用?Python rgb2xyz使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rgb2xyz函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_rgb2xyz_conversion
def test_rgb2xyz_conversion(self):
gt = np.array([[[0.950456, 1. , 1.088754],
[0.538003, 0.787329, 1.06942 ],
[0.592876, 0.28484 , 0.969561],
[0.180423, 0.072169, 0.950227]],
[[0.770033, 0.927831, 0.138527],
[0.35758 , 0.71516 , 0.119193],
[0.412453, 0.212671, 0.019334],
[0. , 0. , 0. ]]])
assert_almost_equal(rgb2xyz(self.colbars_array), gt)
示例2: 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
示例3: extract_color_descriptors
def extract_color_descriptors(image, space=None, verbose=False):
"""
Extract color descriptors of the image
Parameters
----------
image:
space:
None, equivalent to rgb
rgb
hsv
xyz
rgbcie
Returns
-------
Descriptors
"""
if space == 'hsv':
image = color.rgb2hsv(image)
elif space == 'xyz':
image = color.rgb2xyz(image)
elif space == 'rgbcie':
image = color.rgb2rgbcie(image)
elif space == 'gray' or space == 'grey':
image = color.rgb2gray(image)
gen = get_patch(image, size=1)
descs = []
for patch, coord in gen:
if verbose and coord[1] % 5 == 0 and coord[0] == 0:
print 'computed up to %d, %d' % coord
desc = patch.flatten()
desc = np.concatenate((desc, np.array(coord)))
descs.append(desc)
return np.array(descs)
示例4: ColConv
def ColConv(px):
out = col.rgb2xyz([[px]])[0][0]
return out
示例5: test_xyz2rgb_conversion
def test_xyz2rgb_conversion(self):
# only roundtrip test, we checked rgb2xyz above already
assert_almost_equal(xyz2rgb(rgb2xyz(self.colbars_array)),
self.colbars_array)
示例6: test_xyz_rgb_roundtrip
def test_xyz_rgb_roundtrip(self):
img_rgb = img_as_float(self.img_rgb)
assert_array_almost_equal(xyz2rgb(rgb2xyz(img_rgb)), img_rgb)
示例7:
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()
canalExtration(img_hsv, "HSV").show()
canalExtration(img_lab, "LAB").show()
canalExtration(img_hed, "HED").show()
示例8:
A = io.imread(files[0])
As = transform.rescale(A, 0.25)
io.imshow(A)
plt.grid(False)
# <codecell>
#B = exposure.adjust_sigmoid(A, gain=12)
Bs = exposure.adjust_sigmoid(ski.img_as_float(As), gain=12)
#io.imshow(B - exposure.adjust_sigmoid(ski.img_as_float(A), gain=12))
# <codecell>
#C = color.rgb2xyz(B)[:, :, 1]
Cs = color.rgb2xyz(Bs)[:, :, 1]
io.imshow(Cs)
plt.grid(0)
# <codecell>
#D = filter.threshold_adaptive(C, 301)
Ds = filter.threshold_adaptive(Cs, 75)
io.imshow(Ds)
plt.grid(0)
# <codecell>
#E = morphology.remove_small_objects(~morphology.remove_small_objects(~D, 100), 100)
Es = morphology.remove_small_objects(~morphology.remove_small_objects(~Ds, 10), 10)
io.imshow(Es)
示例9:
labels = morphology.watershed(-distance, markers, mask = clean)
io.imshow(labels, interpolation = "nearest", cmap = plt.cm.spectral)
# <codecell>
io.imshow(filter.gaussian_filter(image, 31))
# <codecell>
# Local density
B = image[:, :, 2]
#B = filter.gaussian_filter(np.abs(B - B.mean()), 31)
#io.imshow(B > 1.1*filter.threshold_otsu(B))
io.imshow(color.rgb2xyz(image)[:, :, 2])
#local_density = filter.gaussian_filter(image[:,:,0], 41)# - filter.gaussian_filter(clean, 201)
#io.imshow(local_density > 1.2 * filter.threshold_otsu(local_density, nbins = 1000))
#io.imshow(local_density - local_density.mean() > 0)
"""
#io.imshow(filter.gaussian_filter(clean, 51))
Q = (signal.convolve2d(ski.img_as_float(clean / clean.max()), ski.img_as_float(morphology.disk(201)), "valid"))# - filter.gaussian_filter(clean, 251))
Q -= Q.min()
Q /= Q.max()
io.imshow(Q)
"""
# <codecell>
示例10:
print "Thread %s. Opening file : %s" % (sys.argv[1], f)
### PROCESSING
# Read the image
A = io.imread(f)
# Constrast enhancement
print "Thread %s. Sigmoid transform for contrast." % sys.argv[1]
B = exposure.adjust_sigmoid(A, gain=12)
# Extract luminosity
print "Thread %s. Generating luminosity." % sys.argv[1]
C = color.rgb2xyz(B)[:, :, 1]
# Apply adaptive thresholding
print "Thread %s. Performing adaptive thresholding." % sys.argv[1]
D = filter.threshold_adaptive(C, 301)
D2 = filter.threshold_adaptive(C, 301, offset=-0.01)
# Clean
print "Thread %s. Cleaning image." % sys.argv[1]
E = morphology.remove_small_objects(~morphology.remove_small_objects(~D, 100), 100)
E2 = morphology.remove_small_objects(~morphology.remove_small_objects(~D2, 100), 100)
blur.append(np.abs(E[:2000, 1000:-1000] - E2[:2000, 1000:-1000]).sum() / 6368000.)
# Save to disk
io.imsave(f + "_processed.jpg", ski.img_as_float(E))
示例11: to_xyz
def to_xyz(self):
return Image(rgb2xyz(self.to_rgb_from_gray()[:, :, :3])).convert_type(self.dtype)
示例12: SGD
model.add(Convolution2D(64, 4, 4, border_mode='valid'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.5))
model.add(Activation('relu'))
model.add(Convolution2D(64, 3, 3, border_mode='valid'))
model.add(Dropout(0.5))
model.add(Activation('relu'))
model.add(Flatten())
model.add(Dense(512))
model.add(Activation('relu'))
model.add(Dense(6))
model.add(Activation('softmax')) #aqui o certo é um htan
sgd = SGD()
model.compile(loss = 'categorical_crossentropy', optimizer = sgd)
env = gym.make('Pong-v0')
obs = env.reset()
xyz = color.rgb2xyz(obs)
y = xyz[:,:,1]
small = resize(y,(84,84))
in_obs = small.reshape(1, 1, 84, 84)
pred = model.predict(in_obs,batch_size=1,verbose=0)
print(pred)
#h = model.fit(X_train, Y_train, batch_size = 128, nb_epoch=3, validation_data =(X_test, Y_test), verbose=1)
示例13: rgb2xyz
def rgb2xyz(self,imageArray):
return color.rgb2xyz(imageArray)