In [1]:
%pylab inline


Populating the interactive namespace from numpy and matplotlib

In [26]:
a = imread(r"C:\Users\Public\Pictures\Sample Pictures\Jellyfish.jpg")

In [27]:
a.shape


Out[27]:
(768, 1024, 3)

In [28]:
a[100,100]


Out[28]:
array([  2,  38, 122], dtype=uint8)

In [29]:
a[100,100,0]


Out[29]:
2

In [30]:
imshow(a);



In [31]:
imshow(255-a);



In [32]:
imshow(a[100:600:,::, ::]);



In [102]:
b = np.zeros_like(a)

In [37]:
b[100:500, 200:400]=255

In [73]:
imshow(b)


Out[73]:
<matplotlib.image.AxesImage at 0xa4bbcf0>

In [71]:
b[700:750,700:750, 2]= 44

In [72]:
b[700:750,700:750]


Out[72]:
array([[[128, 111,  44],
        [128, 111,  44],
        [128, 111,  44],
        ..., 
        [128, 111,  44],
        [128, 111,  44],
        [128, 111,  44]],

       [[128, 111,  44],
        [128, 111,  44],
        [128, 111,  44],
        ..., 
        [128, 111,  44],
        [128, 111,  44],
        [128, 111,  44]],

       [[128, 111,  44],
        [128, 111,  44],
        [128, 111,  44],
        ..., 
        [128, 111,  44],
        [128, 111,  44],
        [128, 111,  44]],

       ..., 
       [[128, 111,  44],
        [128, 111,  44],
        [128, 111,  44],
        ..., 
        [128, 111,  44],
        [128, 111,  44],
        [128, 111,  44]],

       [[128, 111,  44],
        [128, 111,  44],
        [128, 111,  44],
        ..., 
        [128, 111,  44],
        [128, 111,  44],
        [128, 111,  44]],

       [[128, 111,  44],
        [128, 111,  44],
        [128, 111,  44],
        ..., 
        [128, 111,  44],
        [128, 111,  44],
        [128, 111,  44]]], dtype=uint8)

In [56]:
b[700:750, 0:100] = [255, 0 , 255 ]

In [45]:
b[700,700]


Out[45]:
array([255, 255, 255], dtype=uint8)

In [76]:
a.shape


Out[76]:
(768, 1024, 3)

In [75]:
imshow(a[300:500, 200:400]);



In [77]:
b[100:300, 400:600] = a[300:500, 200:400]

In [79]:
imshow(b);



In [82]:
imshow(a[::10, ::10]);



In [85]:
a[::4, ::4].shape


Out[85]:
(192, 256, 3)

In [86]:
b[:192, :256] = a[::4, ::4]
imshow(b);



In [95]:
for y in range(b.shape[0]):
    for x in range(b.shape[1]):
        if 100**2 < (x-400)**2 + (y-400)**2 < 200**2:
            b[y,x] =[255,0,255]
imshow(b);



In [99]:
for y in range(b.shape[0]):
    for x in range(b.shape[1]):
        b[y,x] =[x%255,y%255, 128+120*sin((x+y)/200.)]
imshow(b);



In [109]:
for y in range(b.shape[0]):
    for x in range(b.shape[1]):
        R = 100+120*sin(sqrt((x-300)**2 + (y-400)**2)/300.)
        G = 100+120*sin(sqrt((x-400)**2 + (y-400)**2)/700.)
        B = 100+120*cos(sqrt((x-500)**2 + (y-400)**2)/400.)
        b[y,x] = [R,G,B]
imshow(b);



In [ ]: