diff --git a/Anaconda-files/Program_18b.py b/Anaconda-files/Program_18b.py index 4ec728c..78ef44b 100644 --- a/Anaconda-files/Program_18b.py +++ b/Anaconda-files/Program_18b.py @@ -9,17 +9,11 @@ fig1 = plt.figure() plt.imshow(face) -width, height, _ = face.shape +height, width, _ = face.shape print('Image dimensions: {}x{}'.format(width, height)) -white_pixels = np.zeros((width, height)) -def white_pixel_filter(pixel, threshold): - return 1 if all(value > threshold for value in pixel) else 0 - -for i, row in enumerate(face): - for j, pixel in enumerate(row): - white_pixels[i, j] = white_pixel_filter(pixel, threshold=180) +white_pixels = np.all(face > 180, axis=2) fig2 = plt.figure() plt.imshow(white_pixels, cmap='gray')