B = R[:,::-1] rgb = np.array((R,G,B)) print(rgb.shape) ia.adshow(rgb) ia.show(rgb) ff = rgb.transpose((1,2,0)) print(ff.shape) ia.adshow(ff,'teste') ia.show(ff) # In[7]: if testing: A = (np.arange(256*256) % 256).reshape(256,256).astype('uint8') nb = ia.nbshow(3) nb.nbshow(A,'apenas uma', flush=True) for i in range(4): nb.nbshow(A,'legenda %d' % (i,)) nb.nbshow(flush=True) # In[8]: if testing: nb = ia.nbshow(3) nb.nbshow(ff,'apenas uma', flush=True) for i in range(4): nb.nbshow(rgb,'legenda %d' % (i,)) nb.nbshow(flush=True)
sys.path.append(ia898path) import ia898.src as ia # In[3]: import skimage.transform import scipy f = plt.imread('/home/lotufo/ia898/data/cameraman.tif') H, W = f.shape scale1 = 2 scale2 = 0.5 np.set_printoptions(precision=2) nb = ia.nbshow(1) nb.nbshow(f, 'Imagem original') nb.nbshow() # ## skimage.transform.rescale # In[4]: # skimage.transform.rescale skimage_rescale1 = skimage.transform.rescale(f, scale1) skimage_rescale2 = skimage.transform.rescale(f, scale2) nb = ia.nbshow(3) nb.nbshow(ia.normalize(skimage_rescale2), 'skimage_rescale x%s' % (scale2)) nb.nbshow(f, 'Imagem original')
m, t = ia.sobel(f) print('m:\n', m) print('t:\n', t) # ### Image examples # ### Example 1. # In[3]: if testing: f = mpimg.imread('../data/cameraman.tif') (g, a) = ia.sobel(f) nb = ia.nbshow(2) nb.nbshow(ia.normalize(g), title='Sobel') nb.nbshow(ia.normalize(np.log(g + 1)), title='Log of sobel') nb.nbshow() # ### Example 2. # In[4]: if testing: f = ia.circle([200, 300], 90, [100, 150]) m, t = ia.sobel(f) dt = np.select([m > 2], [t]) nb = ia.nbshow(3)
dt = ia.nbread('/home/lotufo/ia898/data/digits_train.png') ia.adshow(dt, 'digits_train.png') # In[5]: print(dt.shape) print(dt.dtype) print(dt[:3, :20]) # ## Visualizando o dataset # O dataset é composto de 80 amostras. Cada amostra está organizado como: primeira coluna é o rótulo do dígito, de 0 a 9 e seguida 160 atributos (16 linhas e 10 colunas). O típo é uint8. # In[6]: nb = ia.nbshow(10) # In[7]: for i in range(80): f = dt[i, 1:].reshape(16, 10) label = dt[i, 0] nb.nbshow(f, label) nb.nbshow() # ## Montando o X # In[8]: X = dt[:, 1:].astype(np.float) print(X.shape)
dtype=np.uint8) s = ia.sat(f) print('f (input):\n', f) print('s (output):\n', s) a = ia.satarea(s, (0, 0), (3, 8)) print('area:', a) # ### Image example # # In[3]: if testing: f = mpimg.imread('../data/lenina.pgm')[::2, ::2] nb = ia.nbshow(2) nb.nbshow(f, 'Original Image') nb.nbshow(ia.normalize(ia.sat(f)), 'Integral Image') nb.nbshow() # ### Calculating a rectangle area with SAT (Summed Area Table) # In[4]: if testing: f = mpimg.imread('../data/lenina.pgm')[::2, ::2] H, W = f.shape s = ia.sat(f) a0 = ia.satarea(s, (0, 0), (H - 1, W - 1)) atopleft = ia.satarea(s, (0, 0), (H // 2 - 1, W // 2 - 1)) abotleft = ia.satarea(s, (H // 2, 0), (H - 1, W // 2 - 1))
import ia898.src as ia # ### Example 1 # In[3]: if testing: get_ipython().run_line_magic('matplotlib', 'inline') import matplotlib.pyplot as plt import matplotlib.image as mpimg f = mpimg.imread('../data/cameraman.tif') g07 = ia.logfilter(f, 0.7) nb = ia.nbshow(3) nb.nbshow(f, 'Imagem original') nb.nbshow(ia.normalize(g07), 'LoG filter') nb.nbshow(g07 > 0, 'positive values') nb.nbshow() # ### Example 2 # In[4]: if testing: g5 = ia.logfilter(f, 5) g10 = ia.logfilter(f, 10) nb = ia.nbshow(2, 2) nb.nbshow(ia.normalize(g5), 'sigma=5')