In [1]:
%matplotlib inline
from pylab import *
import skimage
from skimage import data, io, filters, exposure, feature
from skimage.filters import rank
from skimage.util.dtype import convert
from skimage import img_as_float, img_as_ubyte
from skimage.io import Image
from skimage.color import rgb2hsv, hsv2rgb, rgb2gray
from skimage.filters.edges import convolve
from matplotlib import pylab as plt  
import numpy as np
from numpy import array
from IPython.display import display
from ipywidgets import interact, interactive, fixed
from IPython.core.display import clear_output

import warnings
warnings.simplefilter("ignore")

Reprezentacja obrazów

In [2]:
coins = data.coins()
Image(coins)
Out[2]:
In [3]:
coins
Out[3]:
array([[ 47, 123, 133, ...,  14,   3,  12],
       [ 93, 144, 145, ...,  12,   7,   7],
       [126, 147, 143, ...,   2,  13,   3],
       ..., 
       [ 81,  79,  74, ...,   6,   4,   7],
       [ 88,  82,  74, ...,   5,   7,   8],
       [ 91,  79,  68, ...,   4,  10,   7]], dtype=uint8)
In [4]:
type(coins)
Out[4]:
numpy.ndarray
In [5]:
coins.shape
Out[5]:
(303, 384)
In [6]:
coins[20:30, 10:-10] = 255
coins[::10, ::10] = 255
Image(coins)
Out[6]:
In [7]:
chelsa = data.chelsea()
Image(chelsa)
Out[7]:
In [8]:
chelsa.shape
Out[8]:
(300, 451, 3)
In [9]:
chelsa[:4,:4,:]
Out[9]:
array([[[143, 120, 104],
        [143, 120, 104],
        [141, 118, 102],
        [141, 118, 102]],

       [[146, 123, 107],
        [145, 122, 106],
        [143, 120, 104],
        [142, 119, 103]],

       [[148, 126, 112],
        [147, 125, 111],
        [146, 122, 109],
        [145, 121, 108]],

       [[151, 129, 116],
        [149, 127, 114],
        [147, 125, 112],
        [147, 125, 112]]], dtype=uint8)
In [10]:
tmp = rgb2hsv(chelsa)
tmp[:,:,1] = 0
tmp = hsv2rgb(tmp)
Image(tmp)
Out[10]:
In [11]:
@interact(x=(0.0, 1.0, 0.01))
def on_change(x=0):
    tmp = rgb2hsv(chelsa)
    tmp[:,:,0] = x
    display(Image(hsv2rgb(tmp)))