<jupyter_start><jupyter_text>What's this notebook about?This example illustrates how RGB to HSV **(Hue, Saturation, Value)** conversion can be used to facilitate segmentation processes.Usually, objects in images have distinct colors (hues) and luminosities, so that these features can be used to separate different areas of the image. In the RGB representation the hue and the luminosity are expressed as a linear combination of the R,G,B channels, whereas they correspond to single channels of the HSV image (the Hue and the Value channels). **A simple segmentation of the image can then be effectively performed by a mere thresholding of the HSV channels.**See: https://en.wikipedia.org/wiki/HSL_and_HSV<jupyter_code>import matplotlib.pyplot as plt

from skimage import data
from skimage.color import rgb2hsv<jupyter_output><empty_output><jupyter_text>Original and HSV converted image (using `rgb2hsv()` method)<jupyter_code>rgb_img = data.coffee()
hsv_img = rgb2hsv(rgb_img)<jupyter_output><empty_output><jupyter_text>Images with hue, saturation, and value channels (separately)<jupyter_code>hue_img = hsv_img[:, :, 0]
sat_img = hsv_img[:, :, 1]
value_img = hsv_img[:, :, 2]<jupyter_output><empty_output><jupyter_text>Show images<jupyter_code>fig, (ax0, ax1, ax2, ax3) = plt.subplots(ncols=4, figsize=(15, 5))

ax0.imshow(rgb_img)
ax0.set_title("RGB image")
ax0.axis('off')

ax1.imshow(hue_img, cmap='hsv')
ax1.set_title("Hue channel")
ax1.axis('off')

ax2.imshow(sat_img)
ax2.set_title("Saturation channel")
ax2.axis('off')

ax3.imshow(value_img)
ax3.set_title("Value channel")
ax3.axis('off')

plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11226357535082367, 'fraction_numerical': 0.01586333129957291, 'mean_word_length': 7.078817733990148, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '439366', 'license': 'MIT', 'n_tokens_mistral': 584, 'n_tokens_neox': 558, 'n_words': 161, 'path': 'RGB_to_HSV.ipynb', 'repo_name': 'tirthajyoti/Scikit-image-processing', 'size': '1639'}