In [18]:
photo_data = misc.imread('./wifire/sd-3layers.jpg')
In [19]:
photo_data.shape
Out[19]:
In [23]:
low_value_filter = photo_data < 100
low_value_filter.shape
Out[23]:
In [24]:
low_value_filter[ : 10 , : 10 , 0]
Out[24]:
In [25]:
import random
plt.figure(figsize=(10, 10))
plt.imshow(photo_data)
photo_data[low_value_filter] = 0
plt.figure(figsize = (10, 10))
plt.imshow(photo_data)
Out[25]:
In [27]:
rows_range = np.arange(len(photo_data))
cols_range = rows_range
type(rows_range)
Out[27]:
In [31]:
rows_range.shape, cols_range.shape
Out[31]:
In [32]:
photo_data[rows_range, cols_range] = 255
In [33]:
plt.figure(figsize=(15,15))
plt.imshow(photo_data)
Out[33]:
In [35]:
total_rows , total_cols, totoal_layers = photo_data.shape
x , y = np.ogrid[ : total_rows, : total_cols]
x.shape, y.shape, photo_data.shape
Out[35]:
In [48]:
center_row, center_col = total_rows / 2 , total_cols / 2
#center_row, center_col
#x - center_row
#y - center_col
dist_from_center = (x - center_row)**2 + (y - center_col)**2
#dist_from_center.shape
radius = (total_rows/ 2)**2
circular_mask = (dist_from_center > radius)
circular_mask[1500:1700, 2000:3000]
Out[48]:
In [49]:
photo_data = misc.imread('./wifire/sd-3layers.jpg')
photo_data[circular_mask] = 0
plt.figure(figsize=(15,15))
plt.imshow(photo_data)
Out[49]:
In [51]:
x, y = np.ogrid[ : total_rows, : total_cols]
half_upper = x < center_row
half_upper_mask = np.logical_and(half_upper, circular_mask)
In [53]:
photo_data = misc.imread('./wifire/sd-3layers.jpg')
photo_data[half_upper_mask] = 255
plt.figure(figsize=(15,15))
plt.imshow(photo_data)
Out[53]:
In [54]:
half_upper.shape
Out[54]:
In [55]:
half_upper_mask.shape
Out[55]:
In [56]:
photo_data = misc.imread('./wifire/sd-3layers.jpg')
red_mask = photo_data[: , : , 0 ] < 150
photo_data[red_mask] = 0
plt.figure(figsize=(15,15))
plt.imshow(photo_data)
Out[56]:
In [57]:
photo_data = misc.imread('./wifire/sd-3layers.jpg')
red_mask = photo_data[: , : , 0 ] < 150
green_mask = photo_data[: , : , 1 ] > 100
blue_mask = photo_data[: , : , 2 ] < 100
final_mask = np.logical_and(red_mask, green_mask, blue_mask)
photo_data[final_mask] = 0
plt.figure(figsize=(15,15))
plt.imshow(photo_data)
Out[57]:
'Python Library > Numpy' 카테고리의 다른 글
Day 4. Image Processing with a numpy - 01 (0) | 2019.06.12 |
---|---|
Day 4. Numpy02 (0) | 2019.06.12 |
Day 3. Numpy01 (0) | 2019.06.11 |