本文整理汇总了Python中skimage.color.hsv2rgb函数的典型用法代码示例。如果您正苦于以下问题:Python hsv2rgb函数的具体用法?Python hsv2rgb怎么用?Python hsv2rgb使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了hsv2rgb函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: ton_and_color_corrections
def ton_and_color_corrections():
#色调和彩色校正
image=data.astronaut()
h1=color.rgb2hsv(image)
h2=h1.copy()
h1[:,:,1]=h1[:,:,1]*0.5
image1=color.hsv2rgb(h1)
h2[:,:,1]=h2[:,:,1]*0.5+0.5
image2=color.hsv2rgb(h2)
io.imshow(image)
io.imsave('astronaut.png',image)
io.imshow(image1)
io.imsave('astronautlight.png',image1)
io.imshow(image2)
io.imsave('astronautdark.png',image2)
imagered=image.copy()
imagered[:,:,0]=image[:,:,0]*127.0/255+128
io.imsave('astronautred.png',imagered)
imageblue=image.copy()
imageblue[:,:,2]=image[:,:,2]*127.0/255+128
io.imsave('astronautblue.png',imageblue)
imageyellow=image.copy()
imageyellow[:,:,0]=image[:,:,0]*127.0/255+128
imageyellow[:,:,1]=image[:,:,1]*127.0/255+128
io.imsave('astronautyellow.png',imageyellow)
io.imshow(imageyellow)
开发者ID:xingnix,项目名称:learning,代码行数:27,代码来源:colorimage.py
示例2: classify_and_show
def classify_and_show(km, img_dir):
'''Use a km object to display both the original and altered version of the image at
img_dir, must be PNG'''
img = rgb2hsv(mpimg.imread(img_dir)[...,:3])
s = img.shape
data = img.reshape((s[0] * s[1], s[2]))
labels = km.classify(data)
plt.imshow(hsv2rgb(img))
plt.figure()
plt.imshow(hsv2rgb(km.means[labels].reshape(s)))
开发者ID:athuras,项目名称:colors,代码行数:11,代码来源:color_workshop.py
示例3: gaborbank_orientation_vis
def gaborbank_orientation_vis(d, method='mean', legend=True):
""" Visualise the orientation for each point in the image.
Method 'mean' uses the mean resultant vector over
all orientation filters. Method 'max' takes the orientation
at each pixel to be that of the filter with maximum energy
at that pixel.
Adapted from http://nbviewer.ipython.org/github/gestaltrevision\
/python_for_visres/blob/master/Part7/Part7_Image_Statistics.ipynb
Args:
d: the dict output by gaborbank_convolve.
"""
res = d['res']
e = res.real**2 + res.imag**2 # energy
e = e.sum(axis=3).sum(axis=2) # sum energy over scales and orientations.
if method == 'mean':
ori = gaborbank_mean_orientation(d)
elif method == 'max':
ori = gaborbank_max_orientation(d)
else:
raise ValueError('Unknown method!')
# output values range 0--pi; adjust hues accordingly:
H = ori / np.pi
S = np.ones_like(H)
V = (e - e.min()) / e.max()
HSV = np.dstack((H, S, V))
RGB = hsv2rgb(HSV)
if legend is True:
# Render a hue circle
sz = int(e.shape[0] * 0.1)
r, a = pu.image.axes_polar(sz)
a[a < 0] += np.pi
a /= np.pi
# a = (a - a.min()) / a.max()
a = 1 - a # not sure why I have to flip this, but
# otherwise diagonals are reversed.
mask = (r < 0.9) & (r > 0.3)
hsv_legend = np.dstack((a,
np.ones_like(a, dtype='float'),
mask.astype('float')))
rgb_legend = hsv2rgb(hsv_legend)
RGB[:sz, :sz, :] = rgb_legend[::-1, ::]
return RGB
开发者ID:tomwallis,项目名称:PsyUtils,代码行数:50,代码来源:_gabor_filterbank.py
示例4: get_merged_pic
def get_merged_pic(self, nuclei_color = 0.66, foci_color = 0.33, seeds = False):
'''Return merged pic with foci and nuclei'''
x_max, y_max = self.nuclei.shape
active_cells = self.active_cells()
cell_number = len(active_cells)
if cell_number == 0:
return np.zeros((x_max, y_max, 3), dtype = np.uint8)
merged_pic_peaces = []
nuclei_rgb_koef = hsv2rgb(np.array([nuclei_color, 1., 1.]).reshape((1,1,3))).reshape(3)
foci_rgb_koef = hsv2rgb(np.array([foci_color, 1., 1.]).reshape((1,1,3))).reshape(3)
for cur_cell in active_cells:
if seeds:
foci = cur_cell.foci_seeds
else:
foci = cur_cell.foci_binary
nucleus_only = cur_cell.nucleus - foci
pic_foci_enhanced = 255 - np.floor((255 - cur_cell.pic_foci)*0.6)
pic_foci_enhanced = foci*pic_foci_enhanced
pic_nucleus_only = cur_cell.pic_nucleus*nucleus_only
pic_foci_enhanced_3d = np.dstack((pic_foci_enhanced, pic_foci_enhanced, pic_foci_enhanced))
pic_nucleus_only_3d = np.dstack((pic_nucleus_only, pic_nucleus_only, pic_nucleus_only))
pic_foci_rgb = pic_foci_enhanced_3d*foci_rgb_koef
pic_nucleus_only_rgb = pic_nucleus_only_3d*nuclei_rgb_koef
pic_merged_rgb = np.floor(pic_foci_rgb + pic_nucleus_only_rgb).astype(np.uint8)
merged_pic_peaces.append(peace(pic_merged_rgb, cur_cell.coords))
merged_pic = join_peaces_3d(merged_pic_peaces, x_max, y_max, dtype = np.uint8)
return merged_pic
开发者ID:varnivey,项目名称:darfi,代码行数:49,代码来源:pic_an.py
示例5: stretchImageHue
def stretchImageHue(imrgb):
# Image must be stored as 0-1 bound float. If it's 0-255 int, convert
if( imrgb.max() > 1 ):
imrgb = imrgb*1./255
# Transform to HSV
imhsv = rgb2hsv(imrgb)
# Find 2-98 percentiles of H histogram (except de-saturated pixels)
plt.figure()
plt.hist(imhsv[imhsv[:,:,1]>0.1,0].flatten(), bins=360)
p2, p98 = np.percentile(imhsv[imhsv[:,:,1]>0.1,0], (2, 98))
print p2, p98
imhsv[:,:,0] = doStretch(imhsv[:,:,0], p2, p98, 0.6, 0.99)
plt.figure()
plt.hist(imhsv[imhsv[:,:,1]>0.1,0].flatten(), bins=360)
imrgb_stretched = hsv2rgb(imhsv)
plt.figure()
plt.imshow(imrgb)
plt.figure()
plt.imshow(imrgb_stretched)
plt.show()
开发者ID:adfoucart,项目名称:deep-net-histology,代码行数:25,代码来源:huestretcher.py
示例6: color_augment_image
def color_augment_image(data):
image = data.transpose(1, 2, 0)
hsv = color.rgb2hsv(image)
# Contrast 2
s_factor1 = numpy.random.uniform(0.25, 4)
s_factor2 = numpy.random.uniform(0.7, 1.4)
s_factor3 = numpy.random.uniform(-0.1, 0.1)
hsv[:, :, 1] = (hsv[:, :, 1] ** s_factor1) * s_factor2 + s_factor3
v_factor1 = numpy.random.uniform(0.25, 4)
v_factor2 = numpy.random.uniform(0.7, 1.4)
v_factor3 = numpy.random.uniform(-0.1, 0.1)
hsv[:, :, 2] = (hsv[:, :, 2] ** v_factor1) * v_factor2 + v_factor3
# Color
h_factor = numpy.random.uniform(-0.1, 0.1)
hsv[:, :, 0] = hsv[:, :, 0] + h_factor
hsv[hsv < 0] = 0.0
hsv[hsv > 1] = 1.0
rgb = color.hsv2rgb(hsv)
data_out = rgb.transpose(2, 0, 1)
return data_out
开发者ID:Tinrry,项目名称:anna,代码行数:28,代码来源:__init__.py
示例7: hsi_equalize_hist
def hsi_equalize_hist():
image=data.astronaut()
h=color.rgb2hsv(image)
h[:,:,2]=exposure.equalize_hist(h[:,:,2])
image_equal=color.hsv2rgb(h)
io.imshow(image_equal)
io.imsave('astronautequal.png',image_equal)
开发者ID:xingnix,项目名称:learning,代码行数:7,代码来源:colorimage.py
示例8: test_hsv2rgb_conversion
def test_hsv2rgb_conversion(self):
rgb = self.img_rgb.astype("float32")[::16, ::16]
# create HSV image with colorsys
hsv = np.array([colorsys.rgb_to_hsv(pt[0], pt[1], pt[2]) for pt in rgb.reshape(-1, 3)]).reshape(rgb.shape)
# convert back to RGB and compare with original.
# relative precision for RGB -> HSV roundtrip is about 1e-6
assert_almost_equal(rgb, hsv2rgb(hsv), decimal=4)
开发者ID:soupault,项目名称:scikit-image,代码行数:7,代码来源:test_colorconv.py
示例9: RDMcolormap
def RDMcolormap(nCols=256):
# blue-cyan-gray-red-yellow with increasing V (BCGRYincV)
anchorCols = np.array([
[0, 0, 1],
[0, 1, 1],
[.5, .5, .5],
[1, 0, 0],
[1, 1, 0],
])
# skimage rgb2hsv is intended for 3d images (RGB)
# here we add a new axis to our 2d anchorCols to satisfy skimage, and then squeeze
anchorCols_hsv = rgb2hsv(anchorCols[np.newaxis, :]).squeeze()
incVweight = 1
anchorCols_hsv[:, 2] = (1-incVweight)*anchorCols_hsv[:, 2] + \
incVweight*np.linspace(0.5, 1, anchorCols.shape[0]).T
# anchorCols = brightness(anchorCols)
anchorCols = hsv2rgb(anchorCols_hsv[np.newaxis, :]).squeeze()
cols = colorScale(nCols, anchorCols)
return ListedColormap(cols)
开发者ID:ilogue,项目名称:pyrsa,代码行数:25,代码来源:RDMcolormap.py
示例10: _process
def _process(self, img):
hsv = rgb2hsv(img)
h = hsv[:, :, 0] + self._adjust
h[h > 1] -= 1
hsv[:, :, 0] = h
img[:, :, :] = hsv2rgb(hsv)
return img
开发者ID:jason2506,项目名称:imeffect,代码行数:7,代码来源:basic.py
示例11: saturate
def saturate(im, amount=1.1):
hsvim = skcolor.rgb2hsv(im)
hue = np.take(hsvim, 0, axis=2)
sat = np.take(hsvim, 1, axis=2)
val = np.take(hsvim, 2, axis=2)
# sat = sat * amount
newhsv = np.dstack((hue, sat, val))
return skcolor.hsv2rgb(newhsv)
开发者ID:akshayknarayan,项目名称:cs194-final,代码行数:8,代码来源:tiltshift.py
示例12: main
def main():
# read the images
image_from = io.imread(name_from) / 256
image_to = io.imread(name_to) / 256
# change to hsv domain (if requested)
if args.use_hsv:
image_from[:] = rgb2hsv(image_from)
image_to[:] = rgb2hsv(image_to)
# get shapes
shape_from = image_from.shape
shape_to = image_to.shape
# flatten
X_from = im2mat(image_from)
X_to = im2mat(image_to)
# number of pixes
n_pixels_from = X_from.shape[0]
n_pixels_to = X_to.shape[0]
# subsample
X_from_ss = X_from[np.random.randint(0, n_pixels_from-1, n_pixels),:]
X_to_ss = X_to[np.random.randint(0, n_pixels_to-1, n_pixels),:]
if save_col_distribution:
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_style('white')
fig, axes = plt.subplots(nrows=2, figsize=(5, 10))
for ax, X in zip(axes, [X_from_ss, X_to_ss]):
ax.scatter(X[:,0], X[:,1], color=X)
if args.use_hsv:
ax.set_xhsvel('hue')
ax.set_yhsvel('value')
else:
ax.set_xhsvel('red')
ax.set_yhsvel('green')
axes[0].set_title('distr. from')
axes[1].set_title('distr. to')
fig.tight_layout()
fig.savefig('color_distributions.png')
# optimal tranportation
ot_color = OptimalTransport(X_to_ss, X_from_ss, lam=lam,
distance_metric=distance_metric)
# model transfer
transfer_model = KNeighborsRegressor(n_neighbors=n_neighbors)
transfer_model.fit(X_to_ss, n_pixels * ot_color.P @ X_from_ss)
X_transfered = transfer_model.predict(X_to)
image_transferd = minmax(mat2im(X_transfered, shape_to))
if args.use_hsv:
image_transferd[:] = hsv2rgb(image_transferd)
io.imsave(name_out, image_transferd)
开发者ID:MichielStock,项目名称:Teaching,代码行数:58,代码来源:color_transfer.py
示例13: _rotate_Scale_fired
def _rotate_Scale_fired(self):
"""" _rotate_Scale_fired(self): rotates scale and re-displays image when button is pressed """
max = 255. # this will only work with certain image types...
hsvimage = rgb2hsv([x/max for x in self.image])
hsvimage[:,:,1] = [np.mod(x+0.5,1) for x in hsvimage[:,:,1]]
hsvimage = [np.uint8(x*max) for x in hsv2rgb(hsvimage)]
self.image = hsvimage
self.ax.imshow(hsvimage)
self.figure.canvas.draw()
开发者ID:kuleana,项目名称:ay250_pyseminar,代码行数:9,代码来源:imagesearch.py
示例14: _rotate_Hue_fired
def _rotate_Hue_fired(self):
"""" _rotate_Hue_fired(self): rotates hue and re-displays image when button is pressed """
max = 255.
hsvimage = rgb2hsv([x/max for x in self.image])
hsvimage[:,:,0] = [np.mod(x+0.5,1) for x in hsvimage[:,:,0]]
hsvimage = [np.uint8(x*max) for x in hsv2rgb(hsvimage)]
self.image = hsvimage
self.ax.imshow(hsvimage)
self.figure.canvas.draw()
开发者ID:kuleana,项目名称:ay250_pyseminar,代码行数:9,代码来源:imagesearch.py
示例15: colorize
def colorize(image, hue, saturation=1):
""" Add color of the given hue to an RGB image.
By default, set the saturation to 1 so that the colors pop!
"""
hsv = color.rgb2hsv(image)
hsv[:, :, 1] = saturation
hsv[:, :, 0] = hue
return color.hsv2rgb(hsv)
开发者ID:AceHao,项目名称:scikit-image,代码行数:9,代码来源:plot_tinting_grayscale_images.py
示例16: adjust_saturation_hue
def adjust_saturation_hue(image, saturation_factor, hue_delta):
"""Adjust saturation and hue of an RGB image.
Converts to HSV, add an offset to the saturation channel and
converts back to RGB.
"""
img_hsv = color.rgb2hsv(image)
# Adjust saturation and hue channels.
img_hsv[:, :, 1] = np.clip(img_hsv[:, :, 1] * np.abs(saturation_factor), 0.0, 1.0)
img_hsv[:, :, 0] = np.mod(img_hsv[:, :, 0] + 1. + hue_delta, 1.0)
# Back to RGB mod.
return color.hsv2rgb(img_hsv)
开发者ID:zhuhaijun753,项目名称:SDC-Behavioral-Cloning,代码行数:11,代码来源:image_preprocessing.py
示例17: match
def match(img, ref, bins):
hsv = color.rgb2hsv(img)
vals = hsv[:, :, 2].flatten()
vhist, vbins = numpy.histogram(vals, bins, density=True)
vcdf = vhist.cumsum()
a = numpy.interp(vals, vbins[:-1], vcdf)
mapped = ref(a).reshape(hsv[:, :, 2].shape)
hsv[:, :, 2] = mapped
ret_img = color.hsv2rgb(hsv)
return ret_img
开发者ID:abuchanan,项目名称:image-bolts,代码行数:13,代码来源:deflicker2.py
示例18: call
def call(self, image, saliency_image):
img_resize = resize(image, saliency_image.shape)
saliency_range = max(0.15, saliency_image.max() - saliency_image.min())
saliency_norm = (saliency_image - saliency_image.min()) / saliency_range
saliency_gamma = adjust_gamma(saliency_norm, gamma=self.gamma)
cmap = matplotlib.cm.get_cmap('viridis')
cmap_hsv = rgb2hsv(cmap(saliency_gamma)[:, :, :3])
hsv = np.stack([
cmap_hsv[:, :, 0],
saliency_gamma,
img_resize
], axis=-1)
return hsv2rgb(hsv)
开发者ID:BioroboticsLab,项目名称:bb_pipeline,代码行数:13,代码来源:visualization.py
示例19: generate
def generate(image, width=4096, height=4096):
image_width, image_height, image_bands = image.shape
left = center(image_width, width)
top = center(image_height, height)
result = np.zeros((width, height, image_bands), dtype=image.dtype)
result[left:left+image_width, top:top+image_height] = image
result = rgb2hsv(result)
flattened = result.view(hsv_dtype)
flattened.shape = -1 # Throws an exception if a copy must be made
flattened[np.argsort(flattened, order=['H', 'S', 'V'])] = get_hsv_spectrum()
return hsv2rgb(result).view(image.dtype)
开发者ID:AsteriscoProducciones,项目名称:allrgb,代码行数:13,代码来源:allrgb.py
示例20: updateColorAll
def updateColorAll(self):
_Vs = list()
for signalType in self.signalColors.keys():
_v = self.signal[signalType][:,:,0]
_v[_v > 100] = 100
_Vs.append(_v/100)
V = sum(_Vs)
S = np.ones(V.shape)
S[V == 0] = 0
H = np.ones(V.shape)
H[V == 0] = 0.5
V = 1 - V
HSV = np.dstack((H, S, V))
self.color = 255*hsv2rgb(HSV).astype(np.uint8, copy=False)
开发者ID:cwhy,项目名称:AntWorld,代码行数:14,代码来源:life.py
注:本文中的skimage.color.hsv2rgb函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论