def step7(): img = imageio.imread("../assets/img/bb.jpg") red = img[:, :, 0] green = img[:, :, 1] blue = img[:, :, 2] nb_rows, nb_cols = red.shape row, col = np.ogrid[:nb_rows, :nb_cols] cnt_row, cnt_col = nb_rows / 2, nb_cols / 2 outer_disk_mask = ((row - cnt_row)**2 + (col - cnt_col)**2 > (nb_rows / 2)**2) red[outer_disk_mask] = 0 green[outer_disk_mask] = 0 blue[outer_disk_mask] = 0 img[0:100, 0:50, :] = 0 plt.subplot(2, 2, 1) plt.imshow(img) plt.subplot(2, 2, 2) plt.title("red") plt.imshow(red) plt.subplot(2, 2, 3) plt.title("green") plt.imshow(green) plt.subplot(2, 2, 4) plt.title("blue") plt.imshow(blue) plt.show() """Effectuer ce travail d'encerclement sur les 3 composantes RGB puis exporter l'image couleur. Petit défit : vous pouvez le faire sans rajouter de ligne de code en traitant les 3 composantes en même temps""" saveRGB(red, green, blue, 'my.png')
def step5(): img = imageio.imread("../assets/img/g2.jpg") red = (img[:, :, 0] // 10) * 10 #type:np.ndarray green = (img[:, :, 1] // 10) * 10 #type:np.ndarray blue = (img[:, :, 2] // 10) * 10 #type:np.ndarray h_red = histogramme(red) h_green = histogramme(green) h_blue = histogramme(blue) maxi = max([h_red.max(), h_blue.max(), h_blue.max()]) plt.figure(figsize=(8, 6)) plt.plot(h_red, c='red') plt.plot(h_green, c='green') plt.plot(h_blue, c='blue') plt.axis([0, 255, 0, maxi]) plt.xlabel("valeur") plt.ylabel("Nombre") saveRGB(red, green, blue, 'babouin_quantize.png') plt.show()
def step2b(): img = imageio.imread("../assets/img/ernst.jpg") r = img[:, :, 0] g = img[:, :, 1] saveRGB(np.zeros(g.shape), g, r, "ernst_sb.png")
def step2a(): img = imageio.imread("../assets/img/ernst.jpg") r = img[:, :, 0] b = img[:, :, 2] saveRGB(np.zeros(r.shape), r, b, "ernst_sg.png")
def step2(): img = imageio.imread("../assets/img/ernst.jpg") g = img[:, :, 1] b = img[:, :, 2] saveRGB(np.zeros(g.shape), g, b, "ernst_sr.png")
def step2(): img = imageio.imread("../assets/img/shoe.jpg") g = img[:, :, 1] b = img[:, :, 2] saveRGB(np.zeros(g.shape), g, b, "showr.png")