日本不卡不码高清免费观看,久久国产精品久久w女人spa,黄色aa久久,三上悠亚国产精品一区二区三区

您的位置:首頁技術文章
文章詳情頁

python庫skimage給灰度圖像染色的方法示例

瀏覽:193日期:2022-07-27 11:22:18

灰度圖像染成紅色和黃色

# 1.將灰度圖像轉換為RGB圖像image = color.gray2rgb(grayscale_image)# 2.保留紅色分量和黃色分量red_multiplier = [1, 0, 0]yellow_multiplier = [1, 1, 0]# 3.顯示圖像fig, (ax1, ax2) = plt.subplots(ncols=2, figsize=(8, 4),sharex=True, sharey=True)ax1.imshow(red_multiplier * image)ax2.imshow(yellow_multiplier * image)

python庫skimage給灰度圖像染色的方法示例

HSV圖像,H從0到1表示的顏色

hue_gradient = np.linspace(0, 1)# print(hue_gradient.shape) # output:(50,)hsv = np.ones(shape=(1, len(hue_gradient), 3), dtype=float)hsv[:, :, 0] = hue_gradientall_hues = color.hsv2rgb(hsv)fig, ax = plt.subplots(figsize=(5, 2))# Set image extent so hues go from 0 to 1 and the image is a nice aspect ratio.ax.imshow(all_hues, extent=(0, 1, 0, 0.2))ax.set_axis_off()

python庫skimage給灰度圖像染色的方法示例

將灰度圖像染成不同的顏色

hue_rotations = np.linspace(0, 1, 6)fig, axes = plt.subplots(nrows=2, ncols=3, sharex=True, sharey=True)for ax, hue in zip(axes.flat, hue_rotations): # Turn down the saturation to give it that vintage look. tinted_image = colorize(image, hue, saturation=0.3) ax.imshow(tinted_image, vmin=0, vmax=1) ax.set_axis_off()fig.tight_layout()

python庫skimage給灰度圖像染色的方法示例

完整代碼

'''=========================Tinting gray-scale images=========================It can be useful to artificially tint an image with some color, either tohighlight particular regions of an image or maybe just to liven up a grayscaleimage. This example demonstrates image-tinting by scaling RGB values and byadjusting colors in the HSV color-space.In 2D, color images are often represented in RGB---3 layers of 2D arrays, wherethe 3 layers represent (R)ed, (G)reen and (B)lue channels of the image. Thesimplest way of getting a tinted image is to set each RGB channel to thegrayscale image scaled by a different multiplier for each channel. For example,multiplying the green and blue channels by 0 leaves only the red channel andproduces a bright red image. Similarly, zeroing-out the blue channel leavesonly the red and green channels, which combine to form yellow.'''import matplotlib.pyplot as pltfrom skimage import datafrom skimage import colorfrom skimage import img_as_floatgrayscale_image = img_as_float(data.camera()[::2, ::2])image = color.gray2rgb(grayscale_image)red_multiplier = [1, 0, 0]yellow_multiplier = [1, 1, 0]fig, (ax1, ax2) = plt.subplots(ncols=2, figsize=(8, 4),sharex=True, sharey=True)ax1.imshow(red_multiplier * image)ax2.imshow(yellow_multiplier * image)####################################################################### In many cases, dealing with RGB values may not be ideal. Because of that,# there are many other `color spaces`_ in which you can represent a color# image. One popular color space is called HSV, which represents hue (~the# color), saturation (~colorfulness), and value (~brightness). For example, a# color (hue) might be green, but its saturation is how intense that green is# ---where olive is on the low end and neon on the high end.## In some implementations, the hue in HSV goes from 0 to 360, since hues wrap# around in a circle. In scikit-image, however, hues are float values from 0# to 1, so that hue, saturation, and value all share the same scale.## .. _color spaces:# https://en.wikipedia.org/wiki/List_of_color_spaces_and_their_uses## Below, we plot a linear gradient in the hue, with the saturation and value# turned all the way up:import numpy as nphue_gradient = np.linspace(0, 1)# print(hue_gradient.shape) # output:(50,)hsv = np.ones(shape=(1, len(hue_gradient), 3), dtype=float)hsv[:, :, 0] = hue_gradientall_hues = color.hsv2rgb(hsv)fig, ax = plt.subplots(figsize=(5, 2))# Set image extent so hues go from 0 to 1 and the image is a nice aspect ratio.ax.imshow(all_hues, extent=(0, 1, 0, 0.2))ax.set_axis_off()####################################################################### Notice how the colors at the far left and far right are the same. That# reflects the fact that the hues wrap around like the color wheel (see HSV_# for more info).## .. _HSV: https://en.wikipedia.org/wiki/HSL_and_HSV## Now, let’s create a little utility function to take an RGB image and:## 1. Transform the RGB image to HSV 2. Set the hue and saturation 3.# Transform the HSV image back to RGBdef 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)####################################################################### Notice that we need to bump up the saturation; images with zero saturation# are grayscale, so we need to a non-zero value to actually see the color# we’ve set.## Using the function above, we plot six images with a linear gradient in the# hue and a non-zero saturation:hue_rotations = np.linspace(0, 1, 6)fig, axes = plt.subplots(nrows=2, ncols=3, sharex=True, sharey=True)for ax, hue in zip(axes.flat, hue_rotations): # Turn down the saturation to give it that vintage look. tinted_image = colorize(image, hue, saturation=0.3) ax.imshow(tinted_image, vmin=0, vmax=1) ax.set_axis_off()fig.tight_layout()####################################################################### You can combine this tinting effect with numpy slicing and fancy-indexing# to selectively tint your images. In the example below, we set the hue of# some rectangles using slicing and scale the RGB values of some pixels found# by thresholding. In practice, you might want to define a region for tinting# based on segmentation results or blob detection methods.from skimage.filters import rank# Square regions defined as slices over the first two dimensions.top_left = (slice(100),) * 2bottom_right = (slice(-100, None),) * 2sliced_image = image.copy()sliced_image[top_left] = colorize(image[top_left], 0.82, saturation=0.5)sliced_image[bottom_right] = colorize(image[bottom_right], 0.5, saturation=0.5)# Create a mask selecting regions with interesting texture.noisy = rank.entropy(grayscale_image, np.ones((9, 9)))textured_regions = noisy > 4# Note that using `colorize` here is a bit more difficult, since `rgb2hsv`# expects an RGB image (height x width x channel), but fancy-indexing returns# a set of RGB pixels (# pixels x channel).masked_image = image.copy()masked_image[textured_regions, :] *= red_multiplierfig, (ax1, ax2) = plt.subplots(ncols=2, nrows=1, figsize=(8, 4),sharex=True, sharey=True)ax1.imshow(sliced_image)ax2.imshow(masked_image)plt.show()####################################################################### For coloring multiple regions, you may also be interested in# `skimage.color.label2rgb http://scikit-# image.org/docs/0.9.x/api/skimage.color.html#label2rgb`_.

python庫skimage給灰度圖像染色的方法示例

到此這篇關于python庫skimage給灰度圖像染色的方法示例的文章就介紹到這了,更多相關python 灰度圖像染色內容請搜索好吧啦網以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持好吧啦網!

標簽: Python 編程
相關文章:
日本不卡不码高清免费观看,久久国产精品久久w女人spa,黄色aa久久,三上悠亚国产精品一区二区三区
久久福利精品| 精品国产a一区二区三区v免费| 久久精品72免费观看| 国产精品片aa在线观看| 久久精品资源| 久久九九精品| 999精品一区| 国产中文一区| 伊人久久在线| 婷婷精品在线| av资源亚洲| 日韩高清欧美| 亚洲主播在线| 精品免费视频| 激情综合自拍| 日本免费一区二区视频| 另类综合日韩欧美亚洲| 国产精选在线| 日韩不卡一区二区| 欧美国产一级| 亚洲精品黄色| 精品丝袜在线| 成人在线免费观看网站| 亚洲婷婷在线| 久久wwww| 日韩精品成人| 亚洲在线观看| 在线精品视频一区| 国产专区一区| 久久精品资源| 精品丝袜久久| 国产欧美日韩精品高清二区综合区 | 久久久久伊人| 亚洲欧美视频一区二区三区| 精品一区二区三区免费看| 热久久国产精品| 日韩伦理一区| 欧美视频久久| 亚洲资源在线| 夜夜嗨av一区二区三区网站四季av| 色婷婷精品视频| 日韩一区免费| 欧美女激情福利| 国产精品日韩久久久| 91综合网人人| 久久精品亚洲一区二区| 欧美中文一区| 中文字幕亚洲在线观看| 久久亚洲风情| 亚洲神马久久| 国产中文一区| 欧洲av不卡| 国产一区白浆| 红桃视频国产一区| 在线综合视频| 亚洲一区区二区| 91精品久久久久久久久久不卡| 国产欧美一区| 精品久久视频| 999久久久精品国产| 亚洲二区精品| av不卡在线看| 国产日韩欧美在线播放不卡| 久久这里只有| 成人影视亚洲图片在线| 精品国产麻豆| 国产精品视频一区二区三区四蜜臂 | 成人三级高清视频在线看| 黄色在线网站噜噜噜| 极品日韩av| 日本午夜精品久久久| 精品久久久久久久| 在线国产一区二区| 97精品久久| 国产自产自拍视频在线观看| 亚洲激情另类| 国产精品久久免费视频| 亚洲免费中文| 高清日韩中文字幕| 亚洲精一区二区三区| 精品视频一区二区三区四区五区 | 天堂久久av| 精品精品99| 亚洲人成网站在线在线观看| 国产精品二区影院| 亚洲一区欧美| 国内精品福利| 国产成人77亚洲精品www| 欧美私人啪啪vps| 国产亚洲一卡2卡3卡4卡新区| 欧美有码在线| 中文在线中文资源| 国产精品女主播一区二区三区| 亚洲欧美日韩一区在线观看| 美女视频网站久久| 欧美亚洲激情| 麻豆久久一区二区| 亚洲综合电影一区二区三区| 国产精品一区亚洲| 欧美性感美女一区二区| 国产探花一区在线观看| 91久久国产| 久久亚洲人体| 亚洲男人在线| 激情丁香综合| 青草国产精品| 国内精品福利| 国产一区一一区高清不卡| 日韩制服丝袜先锋影音| 精品三级久久| 久久久国产精品入口麻豆| 午夜性色一区二区三区免费视频| 欧美日韩视频免费观看| 国产精品自拍区| 玖玖玖国产精品| 久久人人97超碰国产公开结果| 欧美综合精品| 免费久久精品视频| 九九久久电影| 久久91导航| 麻豆一区在线| 国产精品www.| 日韩美女精品| 日本亚洲不卡| 日韩av中文字幕一区二区三区| 丝袜美腿高跟呻吟高潮一区| 一区在线视频观看| 亚洲精品一区二区在线看| 成人精品中文字幕| 91精品蜜臀一区二区三区在线| 日韩精品网站| 精品一区在线| 亚洲日本在线观看视频| 婷婷五月色综合香五月| 欧美日韩中出| 国产精品男女| 国产探花一区在线观看| 国产极品一区| 日韩欧美精品一区| 色综合视频一区二区三区日韩 | 欧美jjzz| 国内精品麻豆美女在线播放视频| 欧美一区91| 欧美激情视频一区二区三区免费| 婷婷综合亚洲| 91成人网在线观看| 亚洲一区亚洲| 欧美丝袜一区| 国产亚洲一区在线| 石原莉奈在线亚洲二区| 日韩视频在线一区二区三区 | 91精品一区二区三区综合| 蜜臀久久精品| 亚洲www啪成人一区二区| 欧美日韩国产高清电影| 国产一区欧美| 日韩av在线免费观看不卡| 欧美国产三级| 久久亚洲国产精品尤物| 亚洲性图久久| 国产精品丝袜在线播放| 免费视频一区二区三区在线观看| 欧美日韩视频网站| 亚洲一二三区视频| 国产成人久久精品麻豆二区| 亚洲福利专区| 欧美中文日韩| 老牛国内精品亚洲成av人片| 久久裸体视频| 91国内精品| 欧美午夜精彩| 久久精品国产福利| 蘑菇福利视频一区播放| 久久久91麻豆精品国产一区| 亚洲一二av| av高清一区| 国模大尺度视频一区二区| 日韩天堂av| 蜜桃精品在线| 美女久久久久久 | 精品精品国产三级a∨在线| 悠悠资源网久久精品| 国产91在线精品| 亚洲精品无吗| 国产精品呻吟| 99精品国产一区二区三区| 国产精品不卡| 久久中文欧美| 久久一区视频| 91久久精品无嫩草影院| 99re国产精品| 久久美女精品| 久久激情中文| 精品国产一级| 麻豆精品新av中文字幕| 日韩亚洲精品在线观看| 99国内精品| 亚洲成人一区| 欧美日韩在线播放视频| 免费在线小视频|