In [4]:
import skimage
import numpy as np
import matplotlib.pyplot as plt
# %matplotlib
%matplotlib inline

In [8]:
from skimage import data
camera = data.camera()

type(camera)


Out[8]:
numpy.ndarray

In [9]:
camera.shape, camera.size, camera.min(), camera.max(), camera.mean(), camera.std(), camera.var()


Out[9]:
((512, 512),
 262144,
 0,
 255,
 118.31400299072266,
 61.996043576099197,
 3843.5094190895907)

In [10]:
mask = camera < 87
camera[mask] = 255
plt.imshow(camera)


Out[10]:
<matplotlib.image.AxesImage at 0x19383128320>

In [11]:
inds_r = np.arange(len(camera))
inds_c = 4 * inds_r % len(camera)
camera[inds_r, inds_c] = 0
plt.imshow(camera)


Out[11]:
<matplotlib.image.AxesImage at 0x193831c2e48>

In [12]:
nrows, ncols = camera.shape
row, col = np.ogrid[:nrows, :ncols]

cnt_row, cnt_col = nrows / 2, ncols / 2
outer_disk_mask = (row - cnt_row)**2 + (col - cnt_col)**2 > (nrows / 2)**2
camera[outer_disk_mask] = 0
plt.imshow(camera)


Out[12]:
<matplotlib.image.AxesImage at 0x19383254e48>

In [13]:
np.array([[1],[2,]]), np.array([[1,2]]), np.array([[1],[2,]]) + np.array([[1,2]])


Out[13]:
(array([[1],
        [2]]), array([[1, 2]]), array([[2, 3],
        [3, 4]]))

In [14]:
lower_half = row > cnt_row
lower_half_disk = np.logical_and(lower_half, outer_disk_mask)
camera[lower_half_disk] = 0
plt.imshow(camera)


Out[14]:
<matplotlib.image.AxesImage at 0x193832f3048>

In [15]:
1


Out[15]:
1

In [ ]:


In [ ]: