{"id":415319,"date":"2024-06-30T00:18:07","date_gmt":"2024-06-30T00:18:07","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=415319"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-06-30T00:18:07","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=415319","title":{"rendered":"<span>\u0421\u043c\u043e\u0436\u0435\u0442\u0435 \u043b\u0438 \u0432\u044b \u043e\u0442\u043b\u0438\u0447\u0438\u0442\u044c \u0441\u043e\u0431\u0430\u043a\u0443 \u043e\u0442 \u043a\u043e\u0448\u043a\u0438, \u0438\u043b\u0438 \u041a\u0430\u043a \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0434\u0430\u0442\u0430-\u0441\u0430\u0439\u0435\u043d\u0442\u0438\u0441\u0442\u0430 \u043a\u043e\u043b\u043b\u0435\u0433\u0430\u043c. \u0427\u0430\u0441\u0442\u044c 3<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 <a href=\"https:\/\/habr.com\/ru\/companies\/rosbank\/articles\/750492\/\">\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438<\/a> \u0432\u044b \u0443\u0437\u043d\u0430\u043b\u0438, \u0447\u0442\u043e \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u043c\u043e\u0434\u0435\u043b\u0438 Data Science \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445: \u0440\u0430\u0441\u0442\u0435\u0442, \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0438 \u0443\u0440\u043e\u0432\u043d\u0435\u0439 \u0433\u0440\u0430\u0434\u0430\u0446\u0438\u0438 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437 \u043d\u0438\u0445, \u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445; \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u043c\u0435\u043d\u044c\u0448\u0435 \u043f\u0440\u043e\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0438 \u043e\u043d\u0438 \u043c\u0435\u043d\u0435\u0435 \u0441\u043a\u043e\u0440\u0440\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c. \u0418 \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u0435\u0441\u043b\u0438 \u0432\u0430\u0448\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0435\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0438\u0437 \u043f\u0440\u043e\u0448\u043b\u043e\u0433\u043e, \u0430 \u043d\u0435 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0431\u0443\u0434\u0443\u0449\u0435\u0435.<\/p>\n<p>\u0412 \u0442\u0440\u0435\u0442\u044c\u0435\u0439, \u0437\u0430\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0441\u0442\u0430\u0442\u044c\u0438 \u044f \u0434\u0430\u043c \u043e\u0442\u0432\u0435\u0442\u044b \u043f\u043e \u0440\u0438\u0441\u0443\u043d\u043a\u0430\u043c \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438. \u0418 \u0434\u043b\u044f \u0434\u0430\u0442\u0430-\u0441\u0430\u0439\u0435\u043d\u0442\u0438\u0441\u0442\u043e\u0432 \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u043e\u0431\u0449\u0438\u0439 \u043a\u043e\u0434 Python, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u043d\u0438\u0436\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/fda\/c32\/8b6\/fdac328b6c9cfd5b985d931585e8010a.png\" width=\"750\" height=\"429\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fda\/c32\/8b6\/fdac328b6c9cfd5b985d931585e8010a.png\"\/><\/figure>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0434\u043b\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\"># \u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u0438 from PIL import Image import numpy as np from tqdm import tqdm import os import pandas as pd import matplotlib.pyplot as plt from matplotlib.gridspec import GridSpec plt.rcParams['figure.figsize'] = (18,7)  def im_centralized(img):         \"\"\"\u041e\u0431\u0440\u0435\u0437\u0430\u0435\u0442 \u0440\u0438\u0441\u0443\u043d\u043e\u043a \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442     \u043f\u043e \u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u0435\"\"\"              width, height = img.size      # \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u0442\u043e\u0447\u043a\u0438 \u0434\u043b\u044f \u043e\u0431\u0440\u0435\u0437\u043a\u0438 \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442      # \u043f\u043e \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u0435     if height > width:         left = 0         top = int((height - width) \/ 2)         right = width         bottom = width + int((height - width) \/ 2)     else:         left = int((width - height) \/ 2)         top = 0         right = height + int((width - height) \/ 2)         bottom = height      # \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u043e\u0431\u0440\u0435\u0437\u0430\u043d\u043d\u043e\u0435 \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442      # \u043f\u043e \u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u0435     return img.crop((left, top, right, bottom)) <\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<h3>\u0420\u0438\u0441\u0443\u043d\u043a\u0438, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445<\/h3>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0430\u0445-\u043e\u0442\u0432\u0435\u0442\u0430\u0445 \u0440\u043e\u0437\u043e\u0432\u044b\u043c \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u044b \u0442\u0435 \u0442\u043e\u0447\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0430\u0445-\u0437\u0430\u0433\u0430\u0434\u043a\u0430\u0445 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0431\u0435\u043b\u044b\u043c\u0438. \u041d\u0430 \u0433\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u0441\u043f\u0440\u0430\u0432\u0430 \u043e\u0442 \u0440\u0438\u0441\u0443\u043d\u043a\u0430 \u043a\u0440\u0430\u0441\u043d\u043e\u0439 \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u043b\u0438\u043d\u0438\u0435\u0439 \u043e\u0442\u043c\u0435\u0447\u0435\u043d \u043f\u043e\u0440\u043e\u0433 \u043c\u0435\u0436\u0434\u0443 \u0442\u0435\u043c\u0438 \u0442\u043e\u0447\u043a\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0442\u0441\u044f \u043a\u0430\u043a \u0431\u0435\u043b\u044b\u0435, \u0438 \u0442\u0435\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0442\u0441\u044f \u043a\u0430\u043a \u0447\u0435\u0440\u043d\u044b\u0435.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0440\u0438\u0441\u0443\u043d\u043a\u043e\u0432<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">def show_images(im_path, share, nw_size):        \"\"\"\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043f\u0443\u0442\u044c \u043a \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044e, \u043e\u0431\u0440\u0435\u0437\u0430\u0435\u0442 \u0435\u0433\u043e \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442     \u043f\u043e \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u0435. \u041f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0440\u0430\u0437\u043c\u0435\u0440\u0443     nw_size * nw_size \u0442\u043e\u0447\u0435\u043a.     share \u0442\u043e\u0447\u0435\u043a \u0434\u0435\u043b\u0430\u0435\u0442 \u0447\u0435\u0440\u043d\u044b\u043c\u0438, \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0431\u0435\u043b\u044b\u043c\u0438.     \u0412\u044b\u0432\u043e\u0434\u0438\u0442 \u0434\u0432\u0443\u0445\u0446\u0432\u0435\u0442\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0438 \u0440\u044f\u0434\u043e\u043c \u0441 \u043d\u0438\u043c -      \u0433\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0446\u0432\u0435\u0442\u043e\u0432.     \u0422\u0430\u043a\u0436\u0435 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0441\u0435\u0440\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u043a\u0440\u0430\u0441\u0438\u0442 \u0442\u043e\u0447\u043a\u0438,     \u043e\u043a\u0430\u0437\u0430\u0432\u0448\u0438\u0435\u0441\u044f \u0431\u0435\u043b\u044b\u043c\u0438, \u0432 \u0440\u043e\u0437\u043e\u0432\u044b\u0439; \u0440\u044f\u0434\u043e\u043c \u0441 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c \u0440\u0438\u0441\u0443\u0435\u0442      \u0433\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043e\u0442\u0442\u0435\u043d\u043a\u043e\u0432 \u0441\u0435\u0440\u043e\u0433\u043e, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0440\u043e\u0433,     \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u044e\u0449\u0438\u0439 \u0442\u043e\u0447\u043a\u0438, \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u043d\u044b\u0435 \u043d\u0430 \u043f\u0435\u0440\u0432\u043e\u043c \u0440\u0438\u0441\u0443\u043d\u043a\u0435     \u0431\u0435\u043b\u044b\u043c\u0438 \u0438 \u0447\u0435\u0440\u043d\u044b\u043c\u0438\"\"\"          # \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435     im = Image.open(im_path)      # \u043e\u0431\u0440\u0435\u0437\u0430\u0435\u043c \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442 \u043f\u043e \u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u0435     im_croped = im_centralized(im)      # \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u043c \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442 nw_size * nw_size \u0442\u043e\u0447\u0435\u043a     im_resized = im_croped.resize((nw_size, nw_size))          # \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u0442\u043e\u043d\u0430 \u0441\u0435\u0440\u043e\u0433\u043e \u0446\u0432\u0435\u0442\u0430      im_grey = im_resized.convert(\"L\")          # \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u043c \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 numpy     im_grey = np.array(im_grey)      # \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u043c \u0442\u0440\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0446\u0432\u0435\u0442\u0430     im_red = im_grey.copy()     im_green = im_grey.copy()     im_blue = im_grey.copy()      # \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0432 \u043e\u0434\u043d\u043e\u043c\u0435\u0440\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432     ravel_points = im_grey.copy().ravel()      # \u0441\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445     ravel_points.sort()      # \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u043f\u043e\u0440\u043e\u0433, \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0449\u0438\u0439 \u0431\u0435\u043b\u044b\u0445 \u043e\u0442 \u0447\u0435\u0440\u043d\u044b\u0445     threshold = ravel_points[int(share * len(ravel_points))]      # \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0434\u0432\u0443\u0445\u0446\u0432\u0435\u0442\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435     im_2_colors = im_grey.copy()     im_2_colors[im_2_colors &lt;= threshold] = 0     im_2_colors[im_2_colors > threshold] = 255      # \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u0441\u0435\u0440\u044b\u0445 \u0442\u043e\u043d\u0430\u0445,     # \u043f\u043e\u0434\u0441\u0432\u0435\u0447\u0438\u0432\u0430\u0435\u043c \u0431\u0435\u043b\u044b\u0435 \u0442\u043e\u0447\u043a\u0438 (\u043d\u0430 \u0434\u0432\u0443\u0445\u0446\u0432\u0435\u0442\u043d\u043e\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438)     # \u0440\u043e\u0437\u043e\u0432\u044b\u043c \u0446\u0432\u0435\u0442\u043e\u043c     im_red[im_red > threshold] = 255     im_green[im_green > threshold] = 190     im_blue[im_blue > threshold] = 190      # \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u043e\u0441\u044c     im_red = im_red[:,:,np.newaxis]     im_green = im_green[:,:,np.newaxis]     im_blue = im_blue[:,:,np.newaxis]      # \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0446\u0432\u0435\u0442\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435     im_marked = np.concatenate([im_red, im_green, im_blue],                                 axis=2) \/ 255      # \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0433\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c\u044b     hist_height, _ = np.histogram(im_grey.ravel(), 64)      # \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0444\u0438\u0433\u0443\u0440\u0443     fig = plt.figure(figsize=(18,12))      # \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u0435\u0442\u043a\u0443 \u0434\u043b\u044f \u0434\u0432\u0443\u0445 \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432     gs = GridSpec(1, 3, figure=fig)     axs0 = fig.add_subplot(gs[0, :-1])     axs1 = fig.add_subplot(gs[0, -1])          # \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u0441\u0435\u0440\u044b\u0445 \u0442\u043e\u043d\u0430\u0445,     # \u043f\u043e\u0434\u043a\u0440\u0430\u0448\u0435\u043d\u043d\u043e\u0435 \u0440\u043e\u0437\u043e\u0432\u044b\u043c     axs0.imshow(im_marked)     # \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f     axs0.set_title('\u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435', fontsize=16)     # \u0448\u0440\u0438\u0444\u0442 \u043c\u0435\u0442\u043e\u043a \u043e\u0441\u0438     axs0.tick_params(labelsize=14)     # \u0433\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0434\u043b\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u0441\u0435\u0440\u044b\u0445 \u0442\u043e\u043d\u0430\u0445     axs1.hist(im_grey.ravel(), 64, color='gray');     axs1.set_title('\u0420\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445',                     fontsize=16);     # \u0440\u0438\u0441\u0443\u0435\u043c \u043f\u043e\u0440\u043e\u0433     axs1.plot([threshold, threshold], [0, max(hist_height)], 'r',                label='\u041f\u043e\u0440\u043e\u0433, \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u044e\u0449\u0438\u0439 \u0447\u0435\u0440\u043d\u044b\u0435 \u0438 \u0431\u0435\u043b\u044b\u0435 \u0442\u043e\u0447\u043a\u0438')     # \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u043b\u0435\u0433\u0435\u043d\u0434\u0443     axs1.legend(fontsize=14);       axs1.tick_params(labelsize=14)          # \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0434\u043b\u044f \u0434\u0432\u0443\u0445\u0446\u0432\u0435\u0442\u043d\u043e\u0433\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f     fig = plt.figure(figsize=(18,12))      gs = GridSpec(1, 3, figure=fig)     axs0 = fig.add_subplot(gs[0, :-1])     axs1 = fig.add_subplot(gs[0, -1])          axs0.imshow(im_2_colors, cmap='gray')     axs0.set_title('\u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435', fontsize=16)     axs0.tick_params(labelsize=14)     axs1.hist(im_2_colors.ravel(), 64, color='k');     axs1.set_title('\u0420\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445',                     fontsize=16);     axs1.tick_params(labelsize=14)   im_path = '\u043f\u0443\u0442\u044c \u043a \u0444\u0430\u0439\u043b\u0443 \u0441 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c' # \u0437\u0430\u0434\u0430\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0440 \u0440\u0438\u0441\u0443\u043d\u043a\u0430 NW_SIZE = 100  # \u0437\u0430\u0434\u0430\u0435\u043c \u0434\u043e\u043b\u044e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0447\u0435\u0440\u043d\u043e\u0433\u043e \u0446\u0432\u0435\u0442\u0430 SHARE = .95  # \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 show_images(im_path, SHARE, NW_SIZE)<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041e\u0442\u0432\u0435\u0442 \u043a \u0440\u0438\u0441\u0443\u043d\u043a\u0443 3 \u2014 \u0432\u0435\u0440\u0442\u043e\u043b\u0435\u0442. 1 024 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 95%:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/874\/f53\/fc3\/874f53fc32b3c54f8cfb9de3b058f4e3.png\" width=\"1059\" height=\"705\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/874\/f53\/fc3\/874f53fc32b3c54f8cfb9de3b058f4e3.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/7e9\/f1d\/f71\/7e9f1df71ca7302f7e39c7ca5d2e3919.png\" width=\"1059\" height=\"705\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7e9\/f1d\/f71\/7e9f1df71ca7302f7e39c7ca5d2e3919.png\"\/><\/figure>\n<p>\u041e\u0442\u0432\u0435\u0442 \u043a \u0440\u0438\u0441\u0443\u043d\u043a\u0443 4 \u2014 \u043b\u043e\u0448\u0430\u0434\u044c. 2 500 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 95%:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/8ea\/cb1\/53d\/8eacb153daf911b5854f0caa4c25ea28.png\" width=\"1059\" height=\"705\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8ea\/cb1\/53d\/8eacb153daf911b5854f0caa4c25ea28.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/29a\/544\/fe4\/29a544fe461ddfaf27ef9697bf9c05f7.png\" width=\"1059\" height=\"705\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/29a\/544\/fe4\/29a544fe461ddfaf27ef9697bf9c05f7.png\"\/><\/figure>\n<p>\u041e\u0442\u0432\u0435\u0442 \u043a \u0440\u0438\u0441\u0443\u043d\u043a\u0443 5 \u2014 \u0441\u0430\u043c\u043e\u043b\u0435\u0442. 5 000 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 95%:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/52b\/b5f\/c60\/52bb5fc60ecd6a037b28e90cbad31dab.png\" width=\"1059\" height=\"705\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/52b\/b5f\/c60\/52bb5fc60ecd6a037b28e90cbad31dab.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/77e\/34c\/766\/77e34c7665ea2f653a733689d5d026a3.png\" width=\"1059\" height=\"705\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/77e\/34c\/766\/77e34c7665ea2f653a733689d5d026a3.png\"\/><\/figure>\n<p>\u041e\u0442\u0432\u0435\u0442 \u043a \u0440\u0438\u0441\u0443\u043d\u043a\u0443 6 \u2014\u00a0\u0430\u0432\u0442\u043e\u0431\u0443\u0441. 10 000 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 95%:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1d8\/6b7\/518\/1d86b7518940c3fef05a084d0a407bf2.png\" width=\"1059\" height=\"705\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1d8\/6b7\/518\/1d86b7518940c3fef05a084d0a407bf2.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/500\/812\/bf9\/500812bf9bd0e997091f78ff9e50098b.png\" width=\"1059\" height=\"705\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/500\/812\/bf9\/500812bf9bd0e997091f78ff9e50098b.png\"\/><\/figure>\n<p>\u041e\u0442\u0432\u0435\u0442 \u043a \u0440\u0438\u0441\u0443\u043d\u043a\u0443 7 \u2014 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u043d\u043e\u0439 \u043f\u043e\u0435\u0437\u0434. 20 000 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 95%:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/89e\/c31\/c2f\/89ec31c2f620e740d18b2c8dbaa0d313.png\" width=\"1068\" height=\"705\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/89e\/c31\/c2f\/89ec31c2f620e740d18b2c8dbaa0d313.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/09a\/f84\/85b\/09af8485b0d060861d051ae2b5c31717.png\" width=\"1068\" height=\"705\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/09a\/f84\/85b\/09af8485b0d060861d051ae2b5c31717.png\"\/><\/figure>\n<p>\u041e\u0442\u0432\u0435\u0442 \u043a \u0440\u0438\u0441\u0443\u043d\u043a\u0443 8 \u2014 \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434. 40 000 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 95%:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b7b\/9ce\/9e1\/b7b9ce9e11b4d2492634f9244da00b3b.png\" width=\"1068\" height=\"705\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b7b\/9ce\/9e1\/b7b9ce9e11b4d2492634f9244da00b3b.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/5d9\/a82\/337\/5d9a823376c060cbc3aa4060f057328e.png\" width=\"1068\" height=\"705\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5d9\/a82\/337\/5d9a823376c060cbc3aa4060f057328e.png\"\/><\/figure>\n<p>\u041e\u0442\u0432\u0435\u0442 \u043a \u0440\u0438\u0441\u0443\u043d\u043a\u0443 9 \u2014 \u0441\u043b\u043e\u043d. 100 000 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 95%:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a4a\/629\/f1d\/a4a629f1de9c6a99bdee06a1d97ed734.png\" width=\"1068\" height=\"705\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a4a\/629\/f1d\/a4a629f1de9c6a99bdee06a1d97ed734.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/374\/cac\/f43\/374cacf43924289994c1a3a66917e740.png\" width=\"1068\" height=\"705\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/374\/cac\/f43\/374cacf43924289994c1a3a66917e740.png\"\/><\/figure>\n<p>\u041e\u0442\u0432\u0435\u0442 \u043a \u0440\u0438\u0441\u0443\u043d\u043a\u0443 10 \u2014\u00a0\u0440\u044b\u0431\u0430. 250 000 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 95%:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/84d\/30d\/18a\/84d30d18ae39d8815f9786f1110cf087.png\" width=\"1068\" height=\"705\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/84d\/30d\/18a\/84d30d18ae39d8815f9786f1110cf087.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b5e\/e4f\/248\/b5ee4f2488467817cb7d65bb5ee75c12.png\" width=\"1068\" height=\"705\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b5e\/e4f\/248\/b5ee4f2488467817cb7d65bb5ee75c12.png\"\/><\/figure>\n<h3>\u0420\u0438\u0441\u0443\u043d\u043a\u0438, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u0447\u0430\u0441\u0442\u043e\u0442\u043e\u0439 \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f<\/h3>\n<p>\u0414\u043b\u044f \u0438\u0445 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u0442\u043e\u0442 \u0436\u0435 \u043a\u043e\u0434, \u0447\u0442\u043e \u044f \u0434\u043b\u044f \u0440\u0438\u0441\u0443\u043d\u043a\u043e\u0432, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u0447\u0438\u0441\u043b\u043e\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445.<\/p>\n<p>\u041e\u0442\u0432\u0435\u0442 \u043a \u0440\u0438\u0441\u0443\u043d\u043a\u0443 11 \u2014 \u043b\u044f\u0433\u0443\u0448\u043a\u0430. 10 000 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 95%:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/167\/84b\/8c1\/16784b8c112a2f23f99c1cb25dd27ed0.png\" width=\"1059\" height=\"705\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/167\/84b\/8c1\/16784b8c112a2f23f99c1cb25dd27ed0.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/bc6\/6d3\/601\/bc66d3601cbf76b2b84fa218c8ebd567.png\" width=\"1059\" height=\"705\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/bc6\/6d3\/601\/bc66d3601cbf76b2b84fa218c8ebd567.png\"\/><\/figure>\n<p>\u041e\u0442\u0432\u0435\u0442 \u043a \u0440\u0438\u0441\u0443\u043d\u043a\u0443 12 \u2014 \u043f\u0430\u0440\u0443\u0441\u043d\u044b\u0439 \u043a\u043e\u0440\u0430\u0431\u043b\u044c. 10 000 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 90%:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/53c\/169\/223\/53c169223a46bd41604fbc3c60d77389.png\" width=\"1059\" height=\"705\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/53c\/169\/223\/53c169223a46bd41604fbc3c60d77389.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a73\/8b0\/a77\/a738b0a774edd1a22674adb8555f09cc.png\" width=\"1059\" height=\"705\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a73\/8b0\/a77\/a738b0a774edd1a22674adb8555f09cc.png\"\/><\/figure>\n<p>\u041e\u0442\u0432\u0435\u0442 \u043a \u0440\u0438\u0441\u0443\u043d\u043a\u0443 13 \u2014 \u0430\u0432\u0442\u043e\u043c\u043e\u0431\u0438\u043b\u044c. 10 000 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 80%:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/26b\/4c6\/4ed\/26b4c64ed64196641913062c20c49c6d.png\" width=\"1059\" height=\"705\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/26b\/4c6\/4ed\/26b4c64ed64196641913062c20c49c6d.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/917\/262\/e3d\/917262e3d1c8f264e9d92d584b9becd4.png\" width=\"1059\" height=\"705\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/917\/262\/e3d\/917262e3d1c8f264e9d92d584b9becd4.png\"\/><\/figure>\n<p>\u041e\u0442\u0432\u0435\u0442 \u043a \u0440\u0438\u0441. 14 \u2014 \u0442\u0438\u0433\u0440. 10 000 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 70%.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/771\/4ae\/697\/7714ae697ecf5ab38538710bb90884e8.png\" width=\"1059\" height=\"705\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/771\/4ae\/697\/7714ae697ecf5ab38538710bb90884e8.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/cb5\/f9b\/3da\/cb5f9b3da977e740d07d347a156213fc.png\" width=\"1059\" height=\"705\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cb5\/f9b\/3da\/cb5f9b3da977e740d07d347a156213fc.png\"\/><\/figure>\n<p>\u041e\u0442\u0432\u0435\u0442 \u043a \u0440\u0438\u0441. 15 \u2014\u00a0\u0442\u0440\u0430\u043a\u0442\u043e\u0440. 10 000 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 60%:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a2e\/913\/baf\/a2e913baf25217bab63727f16dfa4719.png\" width=\"1059\" height=\"705\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a2e\/913\/baf\/a2e913baf25217bab63727f16dfa4719.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/7d8\/099\/cfa\/7d8099cfae3f714ec6089f277744cd0e.png\" width=\"1059\" height=\"705\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7d8\/099\/cfa\/7d8099cfae3f714ec6089f277744cd0e.png\"\/><\/figure>\n<p>\u041e\u0442\u0432\u0435\u0442 \u043a \u0440\u0438\u0441\u0443\u043d\u043a\u0443 16 \u2014 \u043f\u0442\u0438\u0446\u0430. 10 000 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 50%:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a91\/bd8\/30c\/a91bd830c9d1733010ea1d4ea836feba.png\" width=\"1059\" height=\"705\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a91\/bd8\/30c\/a91bd830c9d1733010ea1d4ea836feba.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/0c3\/594\/5fc\/0c35945fcb1b2c7f23d5a1aa96e86d79.png\" width=\"1059\" height=\"705\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0c3\/594\/5fc\/0c35945fcb1b2c7f23d5a1aa96e86d79.png\"\/><\/figure>\n<p>\u041e\u0442\u0432\u0435\u0442 \u043a \u0440\u0438\u0441\u0443\u043d\u043a\u0443 17 \u2014 \u0437\u043c\u0435\u044f. 10 000 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 95%:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f9b\/ef2\/72d\/f9bef272db403a79ece30674fe615565.png\" width=\"1059\" height=\"705\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f9b\/ef2\/72d\/f9bef272db403a79ece30674fe615565.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c1a\/0a5\/1b3\/c1a0a51b3ccc64df122c6ec001ba2771.png\" width=\"1059\" height=\"705\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c1a\/0a5\/1b3\/c1a0a51b3ccc64df122c6ec001ba2771.png\"\/><\/figure>\n<h3>\u0420\u0438\u0441\u0443\u043d\u043e\u043a \u0434\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0442\u0440\u0435\u0445 \u0433\u0440\u0430\u0434\u0430\u0446\u0438\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445<\/h3>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0441\u043f\u0440\u0430\u0432\u0430 \u043e\u0442 \u0440\u0438\u0441\u0443\u043d\u043a\u0430 \u044f \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u0433\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c\u0443. \u041d\u0430 \u043d\u0435\u0439 \u0441\u0438\u043d\u0435\u0439 \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0447\u0435\u0440\u0442\u043e\u0439 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0430 \u0433\u0440\u0430\u043d\u0438\u0446\u0430 \u043c\u0435\u0436\u0434\u0443 \u0442\u043e\u0447\u043a\u0430\u043c\u0438, \u0440\u0430\u0441\u043a\u0440\u0430\u0448\u0435\u043d\u043d\u044b\u043c\u0438 \u0447\u0435\u0440\u043d\u044b\u043c \u0438 \u0441\u0435\u0440\u044b\u043c \u0446\u0432\u0435\u0442\u043e\u043c. \u041a\u0440\u0430\u0441\u043d\u043e\u0439 \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0447\u0435\u0440\u0442\u043e\u0439 \u2013 \u043c\u0435\u0436\u0434\u0443 \u0440\u0430\u0441\u043a\u0440\u0430\u0448\u0435\u043d\u043d\u044b\u043c\u0438 \u0441\u0435\u0440\u044b\u043c \u0438 \u0431\u0435\u043b\u044b\u043c \u0446\u0432\u0435\u0442\u043e\u043c.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">def images_3_colors(im_path, nw_size):          \"\"\"\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043f\u0443\u0442\u044c \u043a \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044e, \u043e\u0431\u0440\u0435\u0437\u0430\u0435\u0442 \u0435\u0433\u043e \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442     \u043f\u043e \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u0435. \u041f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0440\u0430\u0437\u043c\u0435\u0440\u0443     nw_size * nw_size \u0442\u043e\u0447\u0435\u043a.     \u0414\u0435\u043b\u0430\u0435\u0442 1\/3 \u0442\u043e\u0447\u0435\u043a \u0447\u0435\u0440\u043d\u044b\u043c\u0438, 1\/3 \u0441\u0435\u0440\u044b\u043c\u0438, 1\/3 \u0431\u0435\u043b\u044b\u043c\u0438.     \u0412\u044b\u0432\u043e\u0434\u0438\u0442 \u0442\u0440\u0435\u0445\u0446\u0432\u0435\u0442\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0438 \u0440\u044f\u0434\u043e\u043c \u0441 \u043d\u0438\u043c     \u0433\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0446\u0432\u0435\u0442\u043e\u0432.     \"\"\"          # \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435     im = Image.open(im_path)      # \u043e\u0431\u0440\u0435\u0437\u0430\u0435\u043c \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442 \u043f\u043e \u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u0435     im_croped = im_centralized(im)      # \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u043c \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442 nw_size * nw_size \u0442\u043e\u0447\u0435\u043a     im_resized = im_croped.resize((nw_size, nw_size))          # \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u0442\u043e\u043d\u0430 \u0441\u0435\u0440\u043e\u0433\u043e \u0446\u0432\u0435\u0442\u0430      im_grey = im_resized.convert(\"L\")          # \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u043c \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 numpy     im_grey = np.array(im_grey)      # \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0432 \u043e\u0434\u043d\u043e\u043c\u0435\u0440\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432     ravel_points = im_grey.copy().ravel()      # \u0441\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445     ravel_points.sort()      # \u043d\u0430\u0445\u043e\u0434\u0438\u043c 2 \u043f\u043e\u0440\u043e\u0433\u0430, \u0434\u0435\u043b\u044f\u0449\u0438\u0435 \u0433\u0440\u0430\u0434\u0430\u0446\u0438\u0438 \u0446\u0432\u0435\u0442\u0430     # \u043d\u0430 3 \u0447\u0430\u0441\u0442\u0438     threshold1 = ravel_points[int(1\/3 * len(ravel_points))]     threshold2 = ravel_points[int(2\/3 * len(ravel_points))]               # \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0442\u0440\u0435\u0445\u0446\u0432\u0435\u0442\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435     im_3_colors = im_grey.copy()      im_3_colors[im_3_colors &lt;= threshold1] = 0     im_3_colors[im_3_colors > threshold2] = 255     im_3_colors[(im_3_colors > 0)&amp;(         im_3_colors &lt;255)] = 127      # \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0433\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c\u044b     hist_height, _ = np.histogram(im_grey.ravel(), 64)               # \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0444\u0438\u0433\u0443\u0440\u0443     fig = plt.figure(figsize=(18,12))      # \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u0435\u0442\u043a\u0443 \u0434\u043b\u044f \u0434\u0432\u0443\u0445 \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432     gs = GridSpec(1, 3, figure=fig)     axs0 = fig.add_subplot(gs[0, :-1])     axs1 = fig.add_subplot(gs[0, -1])          # \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u0441\u0435\u0440\u044b\u0445 \u0442\u043e\u043d\u0430\u0445     axs0.imshow(im_grey, cmap='gray')     # \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f     axs0.set_title('\u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435', fontsize=16)     # \u0448\u0440\u0438\u0444\u0442 \u043c\u0435\u0442\u043e\u043a \u043e\u0441\u0438     axs0.tick_params(labelsize=14)     # \u0433\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0434\u043b\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u0441\u0435\u0440\u044b\u0445 \u0442\u043e\u043d\u0430\u0445     axs1.hist(im_grey.ravel(), 64, color='gray');     axs1.set_title('\u0420\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445',                     fontsize=16);     # \u0440\u0438\u0441\u0443\u0435\u043c \u043f\u043e\u0440\u043e\u0433\u0438     axs1.plot([threshold1, threshold1], [0, max(hist_height)], 'b',                label='\u041f\u043e\u0440\u043e\u0433, \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u044e\u0449\u0438\u0439 \u0447\u0435\u0440\u043d\u044b\u0435 \u0438 \u0441\u0435\u0440\u044b\u0435 \u0442\u043e\u0447\u043a\u0438')     axs1.plot([threshold2, threshold2], [0, max(hist_height)], 'r',                label='\u041f\u043e\u0440\u043e\u0433, \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u044e\u0449\u0438\u0439 \u0441\u0435\u0440\u044b\u0435 \u0438 \u0431\u0435\u043b\u044b\u0435 \u0442\u043e\u0447\u043a\u0438')     # \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u043b\u0435\u0433\u0435\u043d\u0434\u0443     axs1.legend(fontsize=14);       axs1.tick_params(labelsize=14)          # \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0444\u0438\u0433\u0443\u0440\u0443     fig = plt.figure(figsize=(18,12))      # \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u0435\u0442\u043a\u0443 \u0434\u043b\u044f \u0434\u0432\u0443\u0445 \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432     gs = GridSpec(1, 3, figure=fig)     axs0 = fig.add_subplot(gs[0, :-1])     axs1 = fig.add_subplot(gs[0, -1])      # \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0442\u0440\u0435\u0445\u0446\u0432\u0435\u0442\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435     axs0.imshow(im_3_colors, cmap='gray')     # \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f     axs0.set_title('\u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435', fontsize=16)     # \u0448\u0440\u0438\u0444\u0442 \u043c\u0435\u0442\u043e\u043a \u043e\u0441\u0438     axs0.tick_params(labelsize=14)     # \u0433\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0434\u043b\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u0441\u0435\u0440\u044b\u0445 \u0442\u043e\u043d\u0430\u0445     axs1.hist(im_3_colors.ravel(), 64, color='gray');     axs1.set_title('\u0420\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445',                     fontsize=16);     axs1.tick_params(labelsize=14) im_path = '\u043f\u0443\u0442\u044c \u043a \u0444\u0430\u0439\u043b\u0443 \u0441 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c' # \u0437\u0430\u0434\u0430\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0440 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f NW_SIZE = 100 # \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 images_3_colors(im_path, NW_SIZE)<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041e\u0442\u0432\u0435\u0442 \u043a \u0440\u0438\u0441\u0443\u043d\u043a\u0443 18 \u2014 \u043e\u0432\u0446\u0430. 10 000 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0442\u0440\u0438 \u0433\u0440\u0430\u0434\u0430\u0446\u0438\u0438 \u0441 \u0447\u0430\u0441\u0442\u043e\u0442\u043e\u0439 \u043f\u043e 33% \u043a\u0430\u0436\u0434\u0430\u044f:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c4e\/efd\/0fc\/c4eefd0fc919368d0af252e573a7c7e3.png\" width=\"1059\" height=\"705\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c4e\/efd\/0fc\/c4eefd0fc919368d0af252e573a7c7e3.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/948\/1d6\/7d3\/9481d67d370811508a52394aa6183c3d.png\" width=\"1059\" height=\"705\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/948\/1d6\/7d3\/9481d67d370811508a52394aa6183c3d.png\"\/><\/figure>\n<h3>\u0420\u0438\u0441\u0443\u043d\u043a\u0438 \u0441 \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u043c\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445<\/h3>\n<p>\u0421\u043f\u0440\u0430\u0432\u0430 \u043e\u0442 \u0440\u0438\u0441\u0443\u043d\u043a\u0430 \u043d\u0438\u0436\u0435 \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u0433\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c\u0430. \u0421\u0430\u043c\u044b\u0439 \u0432\u044b\u0441\u043e\u043a\u0438\u0439 \u0441\u0442\u043e\u043b\u0431\u0438\u043a \u043d\u0430 \u043d\u0435\u0439 \u2014 \u0447\u0438\u0441\u043b\u043e \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043e\u0432, \u0437\u0430\u043c\u0435\u043d\u0435\u043d\u043d\u044b\u0445 \u0441\u0440\u0435\u0434\u043d\u0438\u043c \u0444\u043e\u043d\u043e\u043c \u0440\u0438\u0441\u0443\u043d\u043a\u0430. \u0427\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043e\u0432, \u0442\u0435\u043c \u0432\u044b\u0448\u0435 \u044d\u0442\u043e\u0442 \u0441\u0442\u043e\u043b\u0431\u0438\u043a \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u043c\u0438.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">def show_noised(im_path, share, nw_size):     \"\"\"\u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 im_path \u043e\u0431\u0440\u0435\u0437\u0430\u0435\u0442     \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442 \u043f\u043e \u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u0435, \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442      \u0432 \u0433\u0440\u0430\u0434\u0430\u0446\u0438\u0438 \u0441\u0435\u0440\u043e\u0433\u043e, \u0430 \u0437\u0430\u0442\u0435\u043c \u0443\u0434\u0430\u043b\u044f\u0435\u0442 \u0438\u0437 \u043d\u0435\u0433\u043e      \u0434\u043e\u043b\u044e \u0442\u043e\u0447\u0435\u043a, \u0440\u0430\u0432\u043d\u0443\u044e share, \u043f\u0443\u0442\u0435\u043c \u0437\u0430\u043c\u0435\u043d\u044b \u0438\u0445      \u0438\u0441\u0442\u0438\u043d\u043d\u043e\u0433\u043e \u0446\u0432\u0435\u0442\u0430 \u043d\u0430 \u0441\u0440\u0435\u0434\u043d\u0438\u0439 \u0446\u0432\u0435\u0442 \u0432\u0441\u0435\u0433\u043e \u0440\u0438\u0441\u0443\u043d\u043a\u0430     \u0421\u043b\u0435\u0432\u0430 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0437\u0430\u0448\u0443\u043c\u043b\u0435\u043d\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435,      \u0441\u043f\u0440\u0430\u0432\u0430 - \u0433\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0446\u0432\u0435\u0442\u043e\u0432\"\"\"              im = Image.open(im_path)          # \u043e\u0431\u0440\u0435\u0437\u0430\u0435\u043c \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442 \u043f\u043e \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u0435     im_croped = im_centralized(im)          # \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u043c \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442 nw_size * nw_size \u0442\u043e\u0447\u0435\u043a     im_resized = im_croped.resize((nw_size, nw_size))      # \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0444\u0430\u0439\u043b \u0432 \u0442\u043e\u043d\u0430 \u0441\u0435\u0440\u043e\u0433\u043e     im_grey = im_resized.convert(\"L\")              # \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0444\u0430\u0439\u043b \u0432 numpy     im_grey = np.array(im_grey)      # \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0444\u0430\u0439\u043b \u0448\u0443\u043c\u0430 \u0442\u043e\u0433\u043e \u0436\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u0430,     # \u0447\u0442\u043e \u0438 \u0442\u0435\u043a\u0443\u0449\u0438\u0439     noise = np.random.rand(         im_grey.shape[0], im_grey.shape[1])      # \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0437\u0430\u0448\u0443\u043c\u043b\u0435\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b     im_noised = im_grey.copy()      # \u0434\u043b\u044f \u0442\u043e\u0447\u0435\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f     # \u0432 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435, \u043f\u0440\u0435\u0432\u043e\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0435 1 - share, \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c      # \u0438\u0441\u0442\u0438\u043d\u043d\u044b\u0439 \u0446\u0432\u0435\u0442 \u043d\u0430 \u0446\u0432\u0435\u0442 \u0444\u043e\u043d\u0430     im_noised[noise > 1 - share] = im_grey.mean()      # \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0438\u0433\u0443\u0440\u0443     fig = plt.figure(figsize=(18,12))      # \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u0435\u0442\u043a\u0443 \u0434\u043b\u044f \u0434\u0432\u0443\u0445 \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432     gs = GridSpec(1, 3, figure=fig)     axs0 = fig.add_subplot(gs[0, :-1])     axs1 = fig.add_subplot(gs[0, -1])      # \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u0441\u0435\u0440\u044b\u0445 \u0442\u043e\u043d\u0430\u0445,     # \u043f\u043e\u0434\u043a\u0440\u0430\u0448\u0435\u043d\u043d\u043e\u0435 \u0440\u043e\u0437\u043e\u0432\u044b\u043c     axs0.imshow(im_noised, cmap='gray')     # \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f     axs0.set_title('\u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435', fontsize=16)     # \u0448\u0440\u0438\u0444\u0442 \u043c\u0435\u0442\u043e\u043a \u043e\u0441\u0438     axs0.tick_params(labelsize=14)     # \u0433\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0434\u043b\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u0441\u0435\u0440\u044b\u0445 \u0442\u043e\u043d\u0430\u0445     axs1.hist(im_noised.ravel(), 64, color='gray');     axs1.set_title('\u0420\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445',                     fontsize=16);      axs1.tick_params(labelsize=14)  im_path = '\u043f\u0443\u0442\u044c \u043a \u0444\u0430\u0439\u043b\u0443 \u0441 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c' # \u0437\u0430\u0434\u0430\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0440 \u0440\u0438\u0441\u0443\u043d\u043a\u0430 NW_SIZE = 100  # \u0437\u0430\u0434\u0430\u0435\u043c \u0434\u043e\u043b\u044e \u0448\u0443\u043c\u0430 SHARE = .5  # \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 show_noised(im_path, SHARE, NW_SIZE)<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041e\u0442\u0432\u0435\u0442 \u043a \u0440\u0438\u0441\u0443\u043d\u043a\u0443 19 \u2014 \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434\u0438\u0441\u0442\u043a\u0430. 10 000 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0434\u043e\u043b\u044f \u043d\u0435\u0441\u043a\u043e\u0440\u0440\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043e\u0432 20%:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f4d\/288\/f74\/f4d288f74ec8a30423bb11a7ee5891e5.png\" width=\"1059\" height=\"705\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f4d\/288\/f74\/f4d288f74ec8a30423bb11a7ee5891e5.png\"\/><\/figure>\n<p>\u041e\u0442\u0432\u0435\u0442 \u043a \u0440\u0438\u0441\u0443\u043d\u043a\u0443 20 \u2014\u00a0\u043e\u0431\u0435\u0437\u044c\u044f\u043d\u0430. 10 000 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0434\u043e\u043b\u044f \u043d\u0435\u0441\u043a\u043e\u0440\u0440\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043e\u0432 40%:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/3cf\/115\/5ef\/3cf1155effda04b24a73e2fb349b74c0.png\" width=\"1059\" height=\"705\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3cf\/115\/5ef\/3cf1155effda04b24a73e2fb349b74c0.png\"\/><\/figure>\n<p>\u041e\u0442\u0432\u0435\u0442 \u043a \u0440\u0438\u0441\u0443\u043d\u043a\u0443 21 \u2014\u00a0\u0441\u0442\u0438\u0440\u0430\u043b\u044c\u043d\u0430\u044f \u043c\u0430\u0448\u0438\u043d\u0430. 10 000 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0434\u043e\u043b\u044f \u043d\u0435\u0441\u043a\u043e\u0440\u0440\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043e\u0432 50%:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/3f0\/8fe\/79e\/3f08fe79e8bed28499287b3de022d930.png\" width=\"1059\" height=\"705\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3f0\/8fe\/79e\/3f08fe79e8bed28499287b3de022d930.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a2e\/928\/b30\/a2e928b301937bb761f1caf081b3cc22.png\" width=\"1059\" height=\"705\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a2e\/928\/b30\/a2e928b301937bb761f1caf081b3cc22.png\"\/><\/figure>\n<p>\u041e\u0442\u0432\u0435\u0442 \u043a \u0440\u0438\u0441\u0443\u043d\u043a\u0443 22 \u2014 \u043b\u0435\u0432. 10 000 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0434\u043e\u043b\u044f \u043d\u0435\u0441\u043a\u043e\u0440\u0440\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043e\u0432 60%:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/0e0\/00d\/eb3\/0e000deb37179be88a0eb44b0c6e4919.png\" width=\"1059\" height=\"705\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0e0\/00d\/eb3\/0e000deb37179be88a0eb44b0c6e4919.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/24a\/6b1\/845\/24a6b1845137abdd24f769bb42358aad.png\" width=\"1059\" height=\"705\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/24a\/6b1\/845\/24a6b1845137abdd24f769bb42358aad.png\"\/><\/figure>\n<p>\u041e\u0442\u0432\u0435\u0442 \u043a \u0440\u0438\u0441. 23 \u2014 \u0442\u0430\u043d\u043a. 10 000 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0434\u043e\u043b\u044f \u043d\u0435\u0441\u043a\u043e\u0440\u0440\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043e\u0432 70%:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/94f\/737\/3da\/94f7373da198c3773dc445ef89648c1e.png\" width=\"1059\" height=\"705\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/94f\/737\/3da\/94f7373da198c3773dc445ef89648c1e.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1f6\/506\/10d\/1f650610d9857367a0758b4e84457710.png\" width=\"1059\" height=\"705\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1f6\/506\/10d\/1f650610d9857367a0758b4e84457710.png\"\/><\/figure>\n<p>\u041e\u0442\u0432\u0435\u0442 \u043a \u0440\u0438\u0441\u0443\u043d\u043a\u0443 24 \u2014 \u0447\u0430\u0448\u043a\u0430 \u043a\u043e\u0444\u0435. 10 000 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0434\u043e\u043b\u044f \u043d\u0435\u0441\u043a\u043e\u0440\u0440\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043e\u0432 80%:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f7a\/434\/56a\/f7a43456a2c0ce1182f5f95925b9c3ff.png\" width=\"1059\" height=\"705\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f7a\/434\/56a\/f7a43456a2c0ce1182f5f95925b9c3ff.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/4aa\/15e\/bea\/4aa15ebea48cbd1be5834efc5ccf3f0e.png\" width=\"1059\" height=\"705\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/4aa\/15e\/bea\/4aa15ebea48cbd1be5834efc5ccf3f0e.png\"\/><\/figure>\n<p>\u041e\u0442\u0432\u0435\u0442 \u043a \u0440\u0438\u0441\u0443\u043d\u043a\u0443 25 \u2014 \u0447\u0430\u0439\u043d\u0438\u043a. 10 000 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0434\u043e\u043b\u044f \u043d\u0435\u0441\u043a\u043e\u0440\u0440\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043e\u0432 90%:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/de8\/385\/ea6\/de8385ea642622be0de714a4a4e652cc.png\" width=\"1059\" height=\"705\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/de8\/385\/ea6\/de8385ea642622be0de714a4a4e652cc.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6bd\/e55\/8a7\/6bde558a76565dcd32c86c2fada6d1a1.png\" width=\"1059\" height=\"705\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6bd\/e55\/8a7\/6bde558a76565dcd32c86c2fada6d1a1.png\"\/><\/figure>\n<h3>\u0420\u0438\u0441\u0443\u043d\u043a\u0438 \u0441\u043e \u0441\u043a\u043e\u0440\u0440\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u043c\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445<\/h3>\n<p>\u0421\u043b\u0435\u0432\u0430 \u043f\u043e\u043a\u0430\u0437\u0430\u043d \u0437\u0430\u0448\u0443\u043c\u043b\u0435\u043d\u043d\u044b\u0439 \u0440\u0438\u0441\u0443\u043d\u043e\u043a, \u0441\u043f\u0440\u0430\u0432\u0430 \u2014 \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u0448\u0443\u043c\u0430. \u041e\u043d\u0438 \u0438\u043c\u0435\u044e\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440. \u041c\u0430\u0442\u0440\u0438\u0446\u0430 \u0448\u0443\u043c\u0430 \u043d\u0430\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0440\u0438\u0441\u0443\u043d\u043e\u043a. \u0422\u0430\u043c, \u0433\u0434\u0435 \u0432 \u043c\u0430\u0442\u0440\u0438\u0446\u0435 \u0448\u0443\u043c\u0430 \u0431\u0435\u043b\u044b\u0435 \u0442\u043e\u0447\u043a\u0438, \u043d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0437\u0430\u043c\u0435\u043d\u0435\u043d\u043e \u0441\u0435\u0440\u044b\u043c \u0446\u0432\u0435\u0442\u043e\u043c. \u0422\u0430\u043c, \u0433\u0434\u0435 \u0432 \u043c\u0430\u0442\u0440\u0438\u0446\u0435 \u0448\u0443\u043c\u0430 \u0447\u0435\u0440\u043d\u044b\u0435 \u0442\u043e\u0447\u043a\u0438, \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043e \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">def show_correlated_noise(im_path, nw_size, only_left=True):     \"\"\"\u041e\u0431\u0440\u0435\u0437\u0430\u0435\u0442 \u0440\u0438\u0441\u0443\u043d\u043e\u043a \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442 \u043f\u043e \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u043c\u0443     \u0440\u0430\u0437\u043c\u0435\u0440\u0443, \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u0432 \u0433\u0440\u0430\u0434\u0430\u0446\u0438\u0438 \u0441\u0435\u0440\u043e\u0433\u043e \u0446\u0432\u0435\u0442\u0430,     \u0435\u0441\u043b\u0438 only_left=True \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435     \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435.     \u0415\u0441\u043b\u0438 only_left=False, \u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f     \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0441\u043b\u0435\u0432\u0430 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u0440\u0438\u0441\u0443\u043d\u043e\u043a \u0441 \u0441\u0435\u0442\u043a\u043e\u0439,      \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0447\u0438\u0441\u043b\u0443 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u0441\u043f\u0440\u0430\u0432\u0430,     \u0430 \u0441\u043f\u0440\u0430\u0432\u0430 - \u043f\u0438\u043a\u0441\u0435\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\"\"\"                    # \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435     im = Image.open(im_path)      # \u043e\u0431\u0440\u0435\u0437\u0430\u0435\u043c \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442 \u043f\u043e \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u0435     im_croped = im_centralized(im)      # \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u0442\u043e\u043d\u0430 \u0441\u0435\u0440\u043e\u0433\u043e \u0446\u0432\u0435\u0442\u0430      im_grey = im_croped.convert(\"L\")      # \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u043c \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442 nw_size * nw_size \u0442\u043e\u0447\u0435\u043a     im_resized = im_grey.resize((nw_size, nw_size))          # \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0444\u0430\u0439\u043b \u0432 numpy     im_grey1 = np.array(im_resized)      # \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0444\u0430\u0439\u043b \u0448\u0443\u043c\u0430 \u0442\u043e\u0433\u043e \u0436\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u0430,     # \u0447\u0442\u043e \u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435     noise = np.random.rand(         im_grey1.shape[0], im_grey1.shape[1])          # \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435      # \u0446\u0432\u0435\u0442\u0430 \u0432\u0441\u0435\u0433\u043e \u0441\u0435\u0440\u043e\u043c\u0443 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044e     gray_mean = im_grey1.mean()            # \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0444\u0430\u0439\u043b \u0441\u043e \u0441\u043a\u043e\u0440\u0440\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0448\u0443\u043c\u043e\u043c     noise_correlated = 0 * noise              # \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u0448\u0443\u043c\u0430 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0432\u0434\u043e\u043b\u044c     # \u0448\u0438\u0440\u0438\u043d\u044b \u0440\u0438\u0441\u0443\u043d\u043a\u0430 \u043f\u043e \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u043c\u0443      # \u0437\u0430\u043a\u043e\u043d\u0443: \u0441\u043b\u0435\u0432\u0430 \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435 \u0442\u043e\u0447\u043a\u0438 \u0437\u0430\u0448\u0443\u043c\u043b\u0435\u043d\u044b,     # \u0441\u043f\u0440\u0430\u0432\u0430 \u0448\u0443\u043c\u0430 \u043f\u043e\u0447\u0442\u0438 \u043d\u0435\u0442     for i in tqdm(range(im_grey1.shape[1])):         # noise_column - \u043e\u0434\u043d\u043e\u043c\u0435\u0440\u043d\u044b\u0439 \u0432\u0435\u043a\u0442\u043e\u0440         # \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0437\u0430\u0448\u0443\u043c\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u0438         # \u0432\u0441\u0435\u0445 \u0442\u043e\u0447\u0435\u043a \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0439 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u043e\u0439 \u043f\u043e \u0448\u0438\u0440\u0438\u043d\u0435          # \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u043d\u0435\u0441\u043a\u043e\u0440\u0440\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0448\u0443\u043c          # \u0441 \u0434\u0430\u043d\u043d\u043e\u0439 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u043e\u0439 \u043f\u043e \u0448\u0438\u0440\u0438\u043d\u0435         noise_column = noise[:, i].copy()          # \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043f\u043e \u0448\u0438\u0440\u0438\u043d\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e         # \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043a\u0440\u0438\u0432\u043e\u0439 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0442\u043e\u0447\u043a\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445          # \u0448\u0443\u043c \u0440\u0430\u0432\u0435\u043d 1: \u0447\u0435\u043c \u043b\u0435\u0432\u0435\u0435, \u0442\u0435\u043c \u0442\u0430\u043a\u0438\u0445 \u0442\u043e\u0447\u0435\u043a \u0431\u043e\u043b\u044c\u0448\u0435          noise_column[noise_column &lt; 1 \/ (             1 + np.exp((i \/ im_grey1.shape[1] - .5)\/.05)) ] = 1          # \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0441\u0442\u043e\u043b\u0431\u0435\u0446 \u0434\u043b\u044f \u0441\u043a\u043e\u0440\u0440\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0448\u0443\u043c\u0430         noise_correlated[:, i] = noise_column                     # \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0437\u0430\u0448\u0443\u043c\u043b\u0435\u043d\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435         im_grey_noised = im_grey1.copy()         im_grey_noised[noise_correlated == 1] = gray_mean                            if only_left == True:         # \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0438\u0433\u0443\u0440\u0443         fig = plt.figure(figsize=(8, 8))         plt.imshow(im_grey1, cmap='gray');                  plt.title('\u0418\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435'.format(             nw_size, nw_size),                        fontsize=16);          plt.tick_params(labelsize=14)                  else:          # \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0438\u0433\u0443\u0440\u0443         fig = plt.figure(figsize=(18, 9))          # \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u0435\u0442\u043a\u0443 \u0434\u043b\u044f \u0434\u0432\u0443\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439         gs = GridSpec(1, 2, figure=fig)         axs0 = fig.add_subplot(gs[0, 0])         axs1 = fig.add_subplot(gs[0, 1])          # \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0437\u0430\u0448\u0443\u043c\u043b\u0435\u043d\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u0441\u0435\u0440\u044b\u0445 \u0442\u043e\u043d\u0430\u0445         axs0.imshow(im_grey_noised, cmap='gray')          # \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f         axs0.set_title('\u0417\u0430\u0448\u0443\u043c\u043b\u0435\u043d\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435', fontsize=16)         # \u0448\u0440\u0438\u0444\u0442 \u043c\u0435\u0442\u043e\u043a \u043e\u0441\u0438         axs0.tick_params(labelsize=14)                  # \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0444\u0430\u0439\u043b \u0441\u043a\u043e\u0440\u0440\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0448\u0443\u043c\u0430         axs1.imshow(noise_correlated == 1, cmap='gray');          axs1.set_title('\u0428\u0443\u043c: \u0437\u0430\u0448\u0443\u043c\u043b\u0435\u043d\u043d\u044b\u0435 \u0442\u043e\u0447\u043a\u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u044b \u0431\u0435\u043b\u044b\u043c \u0446\u0432\u0435\u0442\u043e\u043c'.format(             nw_size, nw_size),                         fontsize=16);          axs1.tick_params(labelsize=14)   im_path = '\u043f\u0443\u0442\u044c \u043a \u0444\u0430\u0439\u043b\u0443 \u0441 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c' # \u0437\u0430\u0434\u0430\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0440 \u0440\u0438\u0441\u0443\u043d\u043a\u0430 NW_SIZE = 100  # \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0437\u0430\u0448\u0443\u043c\u043b\u0435\u043d\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 show_correlated_noise(im_path, NW_SIZE, only_left=False)  # \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 show_correlated_noise(im_path, NW_SIZE, only_left=True)<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041e\u0442\u0432\u0435\u0442 \u043a \u0440\u0438\u0441\u0443\u043d\u043a\u0443 26 \u2014 \u0434\u0432\u0435 \u0434\u0435\u0432\u0443\u0448\u043a\u0438. 10 000 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0434\u043e\u043b\u044f \u0441\u043a\u043e\u0440\u0440\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043e\u0432 50%:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c27\/5a9\/547\/c275a954717757201d52c7a6b4f3bbed.png\" width=\"1043\" height=\"511\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c27\/5a9\/547\/c275a954717757201d52c7a6b4f3bbed.png\"\/><\/figure>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/fb9\/f30\/a37\/fb9f30a37fffde0d540f7897c0c098ff.png\" width=\"473\" height=\"489\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fb9\/f30\/a37\/fb9f30a37fffde0d540f7897c0c098ff.png\"\/><\/figure>\n<p>\u041e\u0442\u0432\u0435\u0442 \u043a \u0440\u0438\u0441\u0443\u043d\u043a\u0443 27 \u2014\u00a0\u0434\u0432\u0435 \u0434\u0435\u0432\u0443\u0448\u043a\u0438. 1 000 000 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0434\u043e\u043b\u044f \u0441\u043a\u043e\u0440\u0440\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043e\u0432 50%:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/273\/fbd\/202\/273fbd202e4a7bb1d4434a15c99771ae.png\" width=\"1052\" height=\"511\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/273\/fbd\/202\/273fbd202e4a7bb1d4434a15c99771ae.png\"\/><\/figure>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c78\/8b4\/23c\/c788b423cead3925042741c404cbb8b3.png\" width=\"482\" height=\"489\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c78\/8b4\/23c\/c788b423cead3925042741c404cbb8b3.png\"\/><\/figure>\n<h3>\u0412\u043e\u0442 \u0438 \u0432\u0441\u0451!<\/h3>\n<p>\u0412 \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u0436\u0435\u043b\u0430\u0435\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u0435\u043b\u044f\u043c \u0431\u0438\u0437\u043d\u0435\u0441-\u043f\u043e\u0434\u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0439 \u0441\u043d\u0430\u0431\u0436\u0430\u0442\u044c \u0434\u0430\u0442\u0430-\u0441\u0430\u0439\u0435\u043d\u0442\u0438\u0441\u0442\u043e\u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u0430 \u0434\u0430\u0442\u0430-\u0441\u0430\u0439\u0435\u043d\u0442\u0438\u0441\u0442\u0430\u043c \u2014 \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043d\u0430 \u043d\u0438\u0445 \u043c\u043e\u0434\u0435\u043b\u0438 \u0441 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e 100 \u0438 \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 (\u043d\u0443 \u044d\u0442\u043e \u044f \u043f\u043e\u0433\u043e\u0440\u044f\u0447\u0438\u043b\u0441\u044f :)). \u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u2014 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 <a href=\"https:\/\/habr.com\/ru\/companies\/rosbank\/articles\/750176\/\">\u043f\u0435\u0440\u0432\u0443\u044e<\/a> \u0438 <a href=\"https:\/\/habr.com\/ru\/companies\/rosbank\/articles\/750492\/\">\u0432\u0442\u043e\u0440\u0443\u044e<\/a> \u0447\u0430\u0441\u0442\u044c \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/750810\/\"> https:\/\/habr.com\/ru\/articles\/750810\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 <a href=\"https:\/\/habr.com\/ru\/companies\/rosbank\/articles\/750492\/\">\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438<\/a> \u0432\u044b \u0443\u0437\u043d\u0430\u043b\u0438, \u0447\u0442\u043e \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u043c\u043e\u0434\u0435\u043b\u0438 Data Science \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445: \u0440\u0430\u0441\u0442\u0435\u0442, \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0438 \u0443\u0440\u043e\u0432\u043d\u0435\u0439 \u0433\u0440\u0430\u0434\u0430\u0446\u0438\u0438 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437 \u043d\u0438\u0445, \u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445; \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u043c\u0435\u043d\u044c\u0448\u0435 \u043f\u0440\u043e\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0438 \u043e\u043d\u0438 \u043c\u0435\u043d\u0435\u0435 \u0441\u043a\u043e\u0440\u0440\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c. \u0418 \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u0435\u0441\u043b\u0438 \u0432\u0430\u0448\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0435\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0438\u0437 \u043f\u0440\u043e\u0448\u043b\u043e\u0433\u043e, \u0430 \u043d\u0435 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0431\u0443\u0434\u0443\u0449\u0435\u0435.<\/p>\n<p>\u0412 \u0442\u0440\u0435\u0442\u044c\u0435\u0439, \u0437\u0430\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0441\u0442\u0430\u0442\u044c\u0438 \u044f \u0434\u0430\u043c \u043e\u0442\u0432\u0435\u0442\u044b \u043f\u043e \u0440\u0438\u0441\u0443\u043d\u043a\u0430\u043c \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438. \u0418 \u0434\u043b\u044f \u0434\u0430\u0442\u0430-\u0441\u0430\u0439\u0435\u043d\u0442\u0438\u0441\u0442\u043e\u0432 \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u043e\u0431\u0449\u0438\u0439 \u043a\u043e\u0434 Python, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u043d\u0438\u0436\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439.<\/p>\n<figure class=\"full-width\"><\/figure>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0434\u043b\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\"># \u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u0438 from PIL import Image import numpy as np from tqdm import tqdm import os import pandas as pd import matplotlib.pyplot as plt from matplotlib.gridspec import GridSpec plt.rcParams['figure.figsize'] = (18,7)  def im_centralized(img):         \"\"\"\u041e\u0431\u0440\u0435\u0437\u0430\u0435\u0442 \u0440\u0438\u0441\u0443\u043d\u043e\u043a \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442     \u043f\u043e \u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u0435\"\"\"              width, height = img.size      # \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u0442\u043e\u0447\u043a\u0438 \u0434\u043b\u044f \u043e\u0431\u0440\u0435\u0437\u043a\u0438 \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442      # \u043f\u043e \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u0435     if height > width:         left = 0         top = int((height - width) \/ 2)         right = width         bottom = width + int((height - width) \/ 2)     else:         left = int((width - height) \/ 2)         top = 0         right = height + int((width - height) \/ 2)         bottom = height      # \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u043e\u0431\u0440\u0435\u0437\u0430\u043d\u043d\u043e\u0435 \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442      # \u043f\u043e \u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u0435     return img.crop((left, top, right, bottom)) <\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<h3>\u0420\u0438\u0441\u0443\u043d\u043a\u0438, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445<\/h3>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0430\u0445-\u043e\u0442\u0432\u0435\u0442\u0430\u0445 \u0440\u043e\u0437\u043e\u0432\u044b\u043c \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u044b \u0442\u0435 \u0442\u043e\u0447\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0430\u0445-\u0437\u0430\u0433\u0430\u0434\u043a\u0430\u0445 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0431\u0435\u043b\u044b\u043c\u0438. \u041d\u0430 \u0433\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u0441\u043f\u0440\u0430\u0432\u0430 \u043e\u0442 \u0440\u0438\u0441\u0443\u043d\u043a\u0430 \u043a\u0440\u0430\u0441\u043d\u043e\u0439 \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u043b\u0438\u043d\u0438\u0435\u0439 \u043e\u0442\u043c\u0435\u0447\u0435\u043d \u043f\u043e\u0440\u043e\u0433 \u043c\u0435\u0436\u0434\u0443 \u0442\u0435\u043c\u0438 \u0442\u043e\u0447\u043a\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0442\u0441\u044f \u043a\u0430\u043a \u0431\u0435\u043b\u044b\u0435, \u0438 \u0442\u0435\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0442\u0441\u044f \u043a\u0430\u043a \u0447\u0435\u0440\u043d\u044b\u0435.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0440\u0438\u0441\u0443\u043d\u043a\u043e\u0432<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">def show_images(im_path, share, nw_size):        \"\"\"\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043f\u0443\u0442\u044c \u043a \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044e, \u043e\u0431\u0440\u0435\u0437\u0430\u0435\u0442 \u0435\u0433\u043e \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442     \u043f\u043e \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u0435. \u041f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0440\u0430\u0437\u043c\u0435\u0440\u0443     nw_size * nw_size \u0442\u043e\u0447\u0435\u043a.     share \u0442\u043e\u0447\u0435\u043a \u0434\u0435\u043b\u0430\u0435\u0442 \u0447\u0435\u0440\u043d\u044b\u043c\u0438, \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0431\u0435\u043b\u044b\u043c\u0438.     \u0412\u044b\u0432\u043e\u0434\u0438\u0442 \u0434\u0432\u0443\u0445\u0446\u0432\u0435\u0442\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0438 \u0440\u044f\u0434\u043e\u043c \u0441 \u043d\u0438\u043c -      \u0433\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0446\u0432\u0435\u0442\u043e\u0432.     \u0422\u0430\u043a\u0436\u0435 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0441\u0435\u0440\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u043a\u0440\u0430\u0441\u0438\u0442 \u0442\u043e\u0447\u043a\u0438,     \u043e\u043a\u0430\u0437\u0430\u0432\u0448\u0438\u0435\u0441\u044f \u0431\u0435\u043b\u044b\u043c\u0438, \u0432 \u0440\u043e\u0437\u043e\u0432\u044b\u0439; \u0440\u044f\u0434\u043e\u043c \u0441 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c \u0440\u0438\u0441\u0443\u0435\u0442      \u0433\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043e\u0442\u0442\u0435\u043d\u043a\u043e\u0432 \u0441\u0435\u0440\u043e\u0433\u043e, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0440\u043e\u0433,     \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u044e\u0449\u0438\u0439 \u0442\u043e\u0447\u043a\u0438, \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u043d\u044b\u0435 \u043d\u0430 \u043f\u0435\u0440\u0432\u043e\u043c \u0440\u0438\u0441\u0443\u043d\u043a\u0435     \u0431\u0435\u043b\u044b\u043c\u0438 \u0438 \u0447\u0435\u0440\u043d\u044b\u043c\u0438\"\"\"          # \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435     im = Image.open(im_path)      # \u043e\u0431\u0440\u0435\u0437\u0430\u0435\u043c \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442 \u043f\u043e \u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u0435     im_croped = im_centralized(im)      # \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u043c \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442 nw_size * nw_size \u0442\u043e\u0447\u0435\u043a     im_resized = im_croped.resize((nw_size, nw_size))          # \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u0442\u043e\u043d\u0430 \u0441\u0435\u0440\u043e\u0433\u043e \u0446\u0432\u0435\u0442\u0430      im_grey = im_resized.convert(\"L\")          # \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u043c \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 numpy     im_grey = np.array(im_grey)      # \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u043c \u0442\u0440\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0446\u0432\u0435\u0442\u0430     im_red = im_grey.copy()     im_green = im_grey.copy()     im_blue = im_grey.copy()      # \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0432 \u043e\u0434\u043d\u043e\u043c\u0435\u0440\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432     ravel_points = im_grey.copy().ravel()      # \u0441\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445     ravel_points.sort()      # \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u043f\u043e\u0440\u043e\u0433, \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0449\u0438\u0439 \u0431\u0435\u043b\u044b\u0445 \u043e\u0442 \u0447\u0435\u0440\u043d\u044b\u0445     threshold = ravel_points[int(share * len(ravel_points))]      # \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0434\u0432\u0443\u0445\u0446\u0432\u0435\u0442\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435     im_2_colors = im_grey.copy()     im_2_colors[im_2_colors &lt;= threshold] = 0     im_2_colors[im_2_colors > threshold] = 255      # \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u0441\u0435\u0440\u044b\u0445 \u0442\u043e\u043d\u0430\u0445,     # \u043f\u043e\u0434\u0441\u0432\u0435\u0447\u0438\u0432\u0430\u0435\u043c \u0431\u0435\u043b\u044b\u0435 \u0442\u043e\u0447\u043a\u0438 (\u043d\u0430 \u0434\u0432\u0443\u0445\u0446\u0432\u0435\u0442\u043d\u043e\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438)     # \u0440\u043e\u0437\u043e\u0432\u044b\u043c \u0446\u0432\u0435\u0442\u043e\u043c     im_red[im_red > threshold] = 255     im_green[im_green > threshold] = 190     im_blue[im_blue > threshold] = 190      # \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u043e\u0441\u044c     im_red = im_red[:,:,np.newaxis]     im_green = im_green[:,:,np.newaxis]     im_blue = im_blue[:,:,np.newaxis]      # \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0446\u0432\u0435\u0442\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435     im_marked = np.concatenate([im_red, im_green, im_blue],                                 axis=2) \/ 255      # \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0433\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c\u044b     hist_height, _ = np.histogram(im_grey.ravel(), 64)      # \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0444\u0438\u0433\u0443\u0440\u0443     fig = plt.figure(figsize=(18,12))      # \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u0435\u0442\u043a\u0443 \u0434\u043b\u044f \u0434\u0432\u0443\u0445 \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432     gs = GridSpec(1, 3, figure=fig)     axs0 = fig.add_subplot(gs[0, :-1])     axs1 = fig.add_subplot(gs[0, -1])          # \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u0441\u0435\u0440\u044b\u0445 \u0442\u043e\u043d\u0430\u0445,     # \u043f\u043e\u0434\u043a\u0440\u0430\u0448\u0435\u043d\u043d\u043e\u0435 \u0440\u043e\u0437\u043e\u0432\u044b\u043c     axs0.imshow(im_marked)     # \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f     axs0.set_title('\u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435', fontsize=16)     # \u0448\u0440\u0438\u0444\u0442 \u043c\u0435\u0442\u043e\u043a \u043e\u0441\u0438     axs0.tick_params(labelsize=14)     # \u0433\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0434\u043b\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u0441\u0435\u0440\u044b\u0445 \u0442\u043e\u043d\u0430\u0445     axs1.hist(im_grey.ravel(), 64, color='gray');     axs1.set_title('\u0420\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445',                     fontsize=16);     # \u0440\u0438\u0441\u0443\u0435\u043c \u043f\u043e\u0440\u043e\u0433     axs1.plot([threshold, threshold], [0, max(hist_height)], 'r',                label='\u041f\u043e\u0440\u043e\u0433, \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u044e\u0449\u0438\u0439 \u0447\u0435\u0440\u043d\u044b\u0435 \u0438 \u0431\u0435\u043b\u044b\u0435 \u0442\u043e\u0447\u043a\u0438')     # \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u043b\u0435\u0433\u0435\u043d\u0434\u0443     axs1.legend(fontsize=14);       axs1.tick_params(labelsize=14)          # \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0434\u043b\u044f \u0434\u0432\u0443\u0445\u0446\u0432\u0435\u0442\u043d\u043e\u0433\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f     fig = plt.figure(figsize=(18,12))      gs = GridSpec(1, 3, figure=fig)     axs0 = fig.add_subplot(gs[0, :-1])     axs1 = fig.add_subplot(gs[0, -1])          axs0.imshow(im_2_colors, cmap='gray')     axs0.set_title('\u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435', fontsize=16)     axs0.tick_params(labelsize=14)     axs1.hist(im_2_colors.ravel(), 64, color='k');     axs1.set_title('\u0420\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445',                     fontsize=16);     axs1.tick_params(labelsize=14)   im_path = '\u043f\u0443\u0442\u044c \u043a \u0444\u0430\u0439\u043b\u0443 \u0441 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c' # \u0437\u0430\u0434\u0430\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0440 \u0440\u0438\u0441\u0443\u043d\u043a\u0430 NW_SIZE = 100  # \u0437\u0430\u0434\u0430\u0435\u043c \u0434\u043e\u043b\u044e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0447\u0435\u0440\u043d\u043e\u0433\u043e \u0446\u0432\u0435\u0442\u0430 SHARE = .95  # \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 show_images(im_path, SHARE, NW_SIZE)<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041e\u0442\u0432\u0435\u0442 \u043a \u0440\u0438\u0441\u0443\u043d\u043a\u0443 3 \u2014 \u0432\u0435\u0440\u0442\u043e\u043b\u0435\u0442. 1 024 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 95%:<\/p>\n<figure class=\"full-width\"><\/figure>\n<figure class=\"full-width\"><\/figure>\n<p>\u041e\u0442\u0432\u0435\u0442 \u043a \u0440\u0438\u0441\u0443\u043d\u043a\u0443 4 \u2014 \u043b\u043e\u0448\u0430\u0434\u044c. 2 500 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 95%:<\/p>\n<figure class=\"full-width\"><\/figure>\n<figure class=\"full-width\"><\/figure>\n<p>\u041e\u0442\u0432\u0435\u0442 \u043a \u0440\u0438\u0441\u0443\u043d\u043a\u0443 5 \u2014 \u0441\u0430\u043c\u043e\u043b\u0435\u0442. 5 000 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 95%:<\/p>\n<figure class=\"full-width\"><\/figure>\n<figure class=\"full-width\"><\/figure>\n<p>\u041e\u0442\u0432\u0435\u0442 \u043a \u0440\u0438\u0441\u0443\u043d\u043a\u0443 6 \u2014\u00a0\u0430\u0432\u0442\u043e\u0431\u0443\u0441. 10 000 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 95%:<\/p>\n<figure class=\"full-width\"><\/figure>\n<figure class=\"full-width\"><\/figure>\n<p>\u041e\u0442\u0432\u0435\u0442 \u043a \u0440\u0438\u0441\u0443\u043d\u043a\u0443 7 \u2014 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u043d\u043e\u0439 \u043f\u043e\u0435\u0437\u0434. 20 000 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 95%:<\/p>\n<figure class=\"full-width\"><\/figure>\n<figure class=\"full-width\"><\/figure>\n<p>\u041e\u0442\u0432\u0435\u0442 \u043a \u0440\u0438\u0441\u0443\u043d\u043a\u0443 8 \u2014 \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434. 40 000 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 95%:<\/p>\n<figure class=\"full-width\"><\/figure>\n<figure class=\"full-width\"><\/figure>\n<p>\u041e\u0442\u0432\u0435\u0442 \u043a \u0440\u0438\u0441\u0443\u043d\u043a\u0443 9 \u2014 \u0441\u043b\u043e\u043d. 100 000 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 95%:<\/p>\n<figure class=\"full-width\"><\/figure>\n<figure class=\"full-width\"><\/figure>\n<p>\u041e\u0442\u0432\u0435\u0442 \u043a \u0440\u0438\u0441\u0443\u043d\u043a\u0443 10 \u2014\u00a0\u0440\u044b\u0431\u0430. 250 000 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 95%:<\/p>\n<figure class=\"full-width\"><\/figure>\n<figure class=\"full-width\"><\/figure>\n<h3>\u0420\u0438\u0441\u0443\u043d\u043a\u0438, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u0447\u0430\u0441\u0442\u043e\u0442\u043e\u0439 \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f<\/h3>\n<p>\u0414\u043b\u044f \u0438\u0445 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u0442\u043e\u0442 \u0436\u0435 \u043a\u043e\u0434, \u0447\u0442\u043e \u044f \u0434\u043b\u044f \u0440\u0438\u0441\u0443\u043d\u043a\u043e\u0432, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u0447\u0438\u0441\u043b\u043e\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445.<\/p>\n<p>\u041e\u0442\u0432\u0435\u0442 \u043a \u0440\u0438\u0441\u0443\u043d\u043a\u0443 11 \u2014 \u043b\u044f\u0433\u0443\u0448\u043a\u0430. 10 000 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 95%:<\/p>\n<figure class=\"full-width\"><\/figure>\n<figure class=\"full-width\"><\/figure>\n<p>\u041e\u0442\u0432\u0435\u0442 \u043a \u0440\u0438\u0441\u0443\u043d\u043a\u0443 12 \u2014 \u043f\u0430\u0440\u0443\u0441\u043d\u044b\u0439 \u043a\u043e\u0440\u0430\u0431\u043b\u044c. 10 000 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 90%:<\/p>\n<figure class=\"full-width\"><\/figure>\n<figure class=\"full-width\"><\/figure>\n<p>\u041e\u0442\u0432\u0435\u0442 \u043a \u0440\u0438\u0441\u0443\u043d\u043a\u0443 13 \u2014 \u0430\u0432\u0442\u043e\u043c\u043e\u0431\u0438\u043b\u044c. 10 000 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 80%:<\/p>\n<figure class=\"full-width\"><\/figure>\n<figure class=\"full-width\"><\/figure>\n<p>\u041e\u0442\u0432\u0435\u0442 \u043a \u0440\u0438\u0441. 14 \u2014 \u0442\u0438\u0433\u0440. 10 000 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 70%.<\/p>\n<figure class=\"full-width\"><\/figure>\n<figure class=\"full-width\"><\/figure>\n<p>\u041e\u0442\u0432\u0435\u0442 \u043a \u0440\u0438\u0441. 15 \u2014\u00a0\u0442\u0440\u0430\u043a\u0442\u043e\u0440. 10 000 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 60%:<\/p>\n<figure class=\"full-width\"><\/figure>\n<figure class=\"full-width\"><\/figure>\n<p>\u041e\u0442\u0432\u0435\u0442 \u043a \u0440\u0438\u0441\u0443\u043d\u043a\u0443 16 \u2014 \u043f\u0442\u0438\u0446\u0430. 10 000 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 50%:<\/p>\n<figure class=\"full-width\"><\/figure>\n<figure class=\"full-width\"><\/figure>\n<p>\u041e\u0442\u0432\u0435\u0442 \u043a \u0440\u0438\u0441\u0443\u043d\u043a\u0443 17 \u2014 \u0437\u043c\u0435\u044f. 10 000 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 95%:<\/p>\n<figure class=\"full-width\"><\/figure>\n<figure class=\"full-width\"><\/figure>\n<h3>\u0420\u0438\u0441\u0443\u043d\u043e\u043a \u0434\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0442\u0440\u0435\u0445 \u0433\u0440\u0430\u0434\u0430\u0446\u0438\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445<\/h3>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0441\u043f\u0440\u0430\u0432\u0430 \u043e\u0442 \u0440\u0438\u0441\u0443\u043d\u043a\u0430 \u044f \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u0433\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c\u0443. \u041d\u0430 \u043d\u0435\u0439 \u0441\u0438\u043d\u0435\u0439 \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0447\u0435\u0440\u0442\u043e\u0439 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0430 \u0433\u0440\u0430\u043d\u0438\u0446\u0430 \u043c\u0435\u0436\u0434\u0443 \u0442\u043e\u0447\u043a\u0430\u043c\u0438, \u0440\u0430\u0441\u043a\u0440\u0430\u0448\u0435\u043d\u043d\u044b\u043c\u0438 \u0447\u0435\u0440\u043d\u044b\u043c \u0438 \u0441\u0435\u0440\u044b\u043c \u0446\u0432\u0435\u0442\u043e\u043c. \u041a\u0440\u0430\u0441\u043d\u043e\u0439 \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0447\u0435\u0440\u0442\u043e\u0439 \u2013 \u043c\u0435\u0436\u0434\u0443 \u0440\u0430\u0441\u043a\u0440\u0430\u0448\u0435\u043d\u043d\u044b\u043c\u0438 \u0441\u0435\u0440\u044b\u043c \u0438 \u0431\u0435\u043b\u044b\u043c \u0446\u0432\u0435\u0442\u043e\u043c.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">def images_3_colors(im_path, nw_size):          \"\"\"\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043f\u0443\u0442\u044c \u043a \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044e, \u043e\u0431\u0440\u0435\u0437\u0430\u0435\u0442 \u0435\u0433\u043e \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442     \u043f\u043e \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u0435. \u041f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0440\u0430\u0437\u043c\u0435\u0440\u0443     nw_size * nw_size \u0442\u043e\u0447\u0435\u043a.     \u0414\u0435\u043b\u0430\u0435\u0442 1\/3 \u0442\u043e\u0447\u0435\u043a \u0447\u0435\u0440\u043d\u044b\u043c\u0438, 1\/3 \u0441\u0435\u0440\u044b\u043c\u0438, 1\/3 \u0431\u0435\u043b\u044b\u043c\u0438.     \u0412\u044b\u0432\u043e\u0434\u0438\u0442 \u0442\u0440\u0435\u0445\u0446\u0432\u0435\u0442\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0438 \u0440\u044f\u0434\u043e\u043c \u0441 \u043d\u0438\u043c     \u0433\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0446\u0432\u0435\u0442\u043e\u0432.     \"\"\"          # \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435     im = Image.open(im_path)      # \u043e\u0431\u0440\u0435\u0437\u0430\u0435\u043c \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442 \u043f\u043e \u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u0435     im_croped = im_centralized(im)      # \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u043c \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442 nw_size * nw_size \u0442\u043e\u0447\u0435\u043a     im_resized = im_croped.resize((nw_size, nw_size))          # \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u0442\u043e\u043d\u0430 \u0441\u0435\u0440\u043e\u0433\u043e \u0446\u0432\u0435\u0442\u0430      im_grey = im_resized.convert(\"L\")          # \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u043c \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 numpy     im_grey = np.array(im_grey)      # \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0432 \u043e\u0434\u043d\u043e\u043c\u0435\u0440\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432     ravel_points = im_grey.copy().ravel()      # \u0441\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445     ravel_points.sort()      # \u043d\u0430\u0445\u043e\u0434\u0438\u043c 2 \u043f\u043e\u0440\u043e\u0433\u0430, \u0434\u0435\u043b\u044f\u0449\u0438\u0435 \u0433\u0440\u0430\u0434\u0430\u0446\u0438\u0438 \u0446\u0432\u0435\u0442\u0430     # \u043d\u0430 3 \u0447\u0430\u0441\u0442\u0438     threshold1 = ravel_points[int(1\/3 * len(ravel_points))]     threshold2 = ravel_points[int(2\/3 * len(ravel_points))]               # \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0442\u0440\u0435\u0445\u0446\u0432\u0435\u0442\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435     im_3_colors = im_grey.copy()      im_3_colors[im_3_colors &lt;= threshold1] = 0     im_3_colors[im_3_colors > threshold2] = 255     im_3_colors[(im_3_colors > 0)&amp;(         im_3_colors &lt;255)] = 127      # \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0433\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c\u044b     hist_height, _ = np.histogram(im_grey.ravel(), 64)               # \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0444\u0438\u0433\u0443\u0440\u0443     fig = plt.figure(figsize=(18,12))      # \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u0435\u0442\u043a\u0443 \u0434\u043b\u044f \u0434\u0432\u0443\u0445 \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432     gs = GridSpec(1, 3, figure=fig)     axs0 = fig.add_subplot(gs[0, :-1])     axs1 = fig.add_subplot(gs[0, -1])          # \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u0441\u0435\u0440\u044b\u0445 \u0442\u043e\u043d\u0430\u0445     axs0.imshow(im_grey, cmap='gray')     # \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f     axs0.set_title('\u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435', fontsize=16)     # \u0448\u0440\u0438\u0444\u0442 \u043c\u0435\u0442\u043e\u043a \u043e\u0441\u0438     axs0.tick_params(labelsize=14)     # \u0433\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0434\u043b\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u0441\u0435\u0440\u044b\u0445 \u0442\u043e\u043d\u0430\u0445     axs1.hist(im_grey.ravel(), 64, color='gray');     axs1.set_title('\u0420\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445',                     fontsize=16);     # \u0440\u0438\u0441\u0443\u0435\u043c \u043f\u043e\u0440\u043e\u0433\u0438     axs1.plot([threshold1, threshold1], [0, max(hist_height)], 'b',                label='\u041f\u043e\u0440\u043e\u0433, \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u044e\u0449\u0438\u0439 \u0447\u0435\u0440\u043d\u044b\u0435 \u0438 \u0441\u0435\u0440\u044b\u0435 \u0442\u043e\u0447\u043a\u0438')     axs1.plot([threshold2, threshold2], [0, max(hist_height)], 'r',                label='\u041f\u043e\u0440\u043e\u0433, \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u044e\u0449\u0438\u0439 \u0441\u0435\u0440\u044b\u0435 \u0438 \u0431\u0435\u043b\u044b\u0435 \u0442\u043e\u0447\u043a\u0438')     # \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u043b\u0435\u0433\u0435\u043d\u0434\u0443     axs1.legend(fontsize=14);       axs1.tick_params(labelsize=14)          # \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c<\/code><\/pre>\n<\/div>\n<\/details>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-415319","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/415319","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=415319"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/415319\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=415319"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=415319"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=415319"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}