{"id":330845,"date":"2022-03-19T21:00:27","date_gmt":"2022-03-19T21:00:27","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=330845"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=330845","title":{"rendered":"<span>\u0423\u0440\u043e\u043a\u0438 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u043d\u043e\u0433\u043e \u0437\u0440\u0435\u043d\u0438\u044f \u043d\u0430 Python + OpenCV \u0441 \u0441\u0430\u043c\u044b\u0445 \u0430\u0437\u043e\u0432. \u0427\u0430\u0441\u0442\u044c 4<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041d\u0430 <a href=\"https:\/\/habr.com\/ru\/post\/654663\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u043e\u0448\u043b\u043e\u043c \u0443\u0440\u043e\u043a\u0435<\/a> \u043c\u044b \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043b\u0438\u0441\u044c \u0441 \u043c\u0435\u0434\u0438\u0430\u043d\u043d\u043e\u0439 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0435\u0439, \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u043c\u0438 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u043c\u0438 \u0438 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u043a\u043e\u043d\u0442\u0443\u0440\u043e\u0432. \u041d\u0430\u043f\u043e\u043c\u043d\u044e, \u0447\u0442\u043e \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0443\u0440 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432 \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u0438 \u0434\u043b\u044f \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0444\u0438\u0447. \u0412 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u0432\u043e\u0442 \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0434\u0430\u043b\u0435\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043a\u043e\u043d\u0442\u0443\u0440\u043e\u043c:<\/p>\n<ul>\n<li>\n<p>\u0412\u044b\u044f\u0432\u0438\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u044b (\u043f\u0440\u044f\u043c\u044b\u0435, \u043e\u043a\u0440\u0443\u0436\u043d\u043e\u0441\u0442\u0438).<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u0432 \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u0442\u043e\u0447\u0435\u043a \u0438 \u0443\u0436\u0435 \u0438\u0445 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c. <\/p>\n<\/li>\n<li>\n<p>\u041e\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u0430\u043a \u0433\u0440\u0430\u0444 \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u043a \u043d\u0435\u043c\u0443 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u043d\u0430 \u0433\u0440\u0430\u0444\u0430\u0445. <\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u043c \u0438\u0437\u0443\u0447\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u043f\u0440\u0435\u0434\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u0430\u0441\u0442\u043d\u044b\u043c:<\/p>\n<pre><code class=\"python\">import cv2  img = cv2.imread('MyPhoto.jpg', 1) cv2.imshow(\"Original image\",img)  # CLAHE (Contrast Limited Adaptive Histogram Equalization) clahe = cv2.createCLAHE(clipLimit=3., tileGridSize=(8,8))  lab = cv2.cvtColor(img, cv2.COLOR_BGR2LAB)  # convert from BGR to LAB color space l, a, b = cv2.split(lab)  # split on 3 different channels  l2 = clahe.apply(l)  # apply CLAHE to the L-channel  lab = cv2.merge((l2,a,b))  # merge channels img2 = cv2.cvtColor(lab, cv2.COLOR_LAB2BGR)  # convert from LAB to BGR cv2.imshow('Increased contrast', img2)  cv2.waitKey(0) cv2.destroyAllWindows() <\/code><\/pre>\n<p>\u0418\u0441\u043f\u044b\u0442\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u0443\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u043d\u0430 \u0432\u0441\u0435 \u0442\u043e\u0439 \u0436\u0435 \u0434\u043e \u0431\u043e\u043b\u0438 \u0437\u043d\u0430\u043a\u043e\u043c\u043e\u0439 \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0443\u0440\u043e\u043a\u043e\u0432 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435 \u0441 \u043f\u0430\u043b\u044c\u043c\u0430\u043c\u0438:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c6a\/95c\/ac2\/c6a95cac2434750474b63a593761c113.png\" width=\"693\" height=\"275\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c6a\/95c\/ac2\/c6a95cac2434750474b63a593761c113.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0418\u043b\u0438, \u0432\u043e\u0442, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0444\u043e\u0442\u043e, \u0441\u0434\u0435\u043b\u0430\u043d\u043d\u043e\u0435 \u0432 \u0442\u0435\u043c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0441\u0443\u0442\u043e\u043a:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/afb\/11f\/682\/afb11f6829a56d689dc910eb1270f38f.png\" width=\"693\" height=\"277\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/afb\/11f\/682\/afb11f6829a56d689dc910eb1270f38f.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0417\u0430\u043c\u0435\u0447\u0443, \u0447\u0442\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u0430\u0434\u0430\u043f\u0442\u0438\u0432\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0442\u0440\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438. \u0422\u0443\u0442, \u0434\u0443\u043c\u0430\u044e, \u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u044f \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0430\u0434\u0430\u043f\u0442\u0438\u0432\u043d\u0443\u044e \u0433\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c\u0443. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u0431\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0431\u043b\u043e\u043a\u0438 8 \u043d\u0430 8 \u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0433\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e:<\/p>\n<pre><code class=\"python\"># CLAHE (Contrast Limited Adaptive Histogram Equalization) clahe = cv2.createCLAHE(clipLimit=3., tileGridSize=(8,8))<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435, \u0434\u043b\u044f \u043d\u0430\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432\u044b\u0440\u043e\u0432\u043d\u0435\u043d\u043d\u044b\u0445 \u0433\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043e\u043d\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442\u0441\u044f\u00a0 \u0444\u043e\u0440\u043c\u0430\u0442 LAB, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043e\u0434\u0438\u043d \u043a\u0430\u043d\u0430\u043b \u0441\u0432\u0435\u0442\u043b\u043e\u0442\u044b L \u0438 \u0434\u0432\u0430 \u043a\u0430\u043d\u0430\u043b\u0430 \u0446\u0432\u0435\u0442\u0430 A \u0438 B:<\/p>\n<pre><code class=\"python\">lab = cv2.cvtColor(img, cv2.COLOR_BGR2LAB)  # convert from BGR to LAB color space l, a, b = cv2.split(lab)  # split on 3 different channels<\/code><\/pre>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0432\u044b\u0440\u043e\u0432\u043d\u0435\u043d\u043d\u044b\u0435 \u0433\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c\u044b (\u0442\u043e\u043b\u044c\u043a\u043e \u043a \u043a\u0430\u043d\u0430\u043b\u0443 L \u2013 \u0441\u0432\u0435\u0442\u043b\u043e\u0442\u0430):<\/p>\n<pre><code class=\"python\">l2 = clahe.apply(l)  # apply CLAHE to the L-channel<\/code><\/pre>\n<p>\u0417\u0430\u0442\u0435\u043c \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u043c \u044d\u0442\u0438 \u043a\u0430\u043d\u0430\u043b\u044b \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043c \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435:<\/p>\n<pre><code class=\"python\">lab = cv2.merge((l2,a,b))  # merge channels img2 = cv2.cvtColor(lab, cv2.COLOR_LAB2BGR)  # convert from LAB to BGR cv2.imshow('Increased contrast', img2)<\/code><\/pre>\n<p>\u041e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0441\u0442\u043e\u0438\u0442 \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0435 clipLimit. \u041e\u043d \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043d\u0442\u0440\u0430\u0441\u0442\u043d\u0435\u0435 \u0441\u0442\u0430\u043d\u0435\u0442 \u0444\u043e\u0442\u043e. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043c \u0435\u0433\u043e 10 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0432\u043e\u0442 \u044d\u0442\u043e:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/634\/9c7\/c65\/6349c7c65a36b683f663fd6f55cce34d.png\" width=\"693\" height=\"276\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/634\/9c7\/c65\/6349c7c65a36b683f663fd6f55cce34d.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u0442\u0443\u0442 \u043f\u0440\u043e\u0441\u0442\u0443\u043f\u0438\u043b\u0438 \u0434\u0430\u0436\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0435\u0442\u0430\u043b\u0438 \u0432\u0434\u0430\u043b\u0438. \u041f\u0440\u0430\u0432\u0434\u0430, \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440, \u0435\u0441\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u0435\u0434\u0435\u043b, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0448\u0443\u043c\u044b \u0438\u0441\u043f\u043e\u0440\u0442\u044f\u0442 \u0444\u043e\u0442\u043e\u0447\u043a\u0443. \u0412\u043e\u0442 \u0447\u0442\u043e \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c, \u0435\u0441\u043b\u0438 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043c \u0435\u0433\u043e 100:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b9c\/a29\/35d\/b9ca2935d594f527c65b182f7a7ce6a3.png\" width=\"693\" height=\"276\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b9c\/a29\/35d\/b9ca2935d594f527c65b182f7a7ce6a3.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0443 \u0442\u043e\u0439 \u0436\u0435 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u043a\u043e\u043d\u0442\u0443\u0440 (\u0431\u0435\u0437 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0442\u0440\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438):<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/617\/112\/6da\/6171126da76118890dc240f9d38c073c.png\" width=\"631\" height=\"498\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/617\/112\/6da\/6171126da76118890dc240f9d38c073c.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0410 \u0435\u0441\u043b\u0438 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u044c:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/847\/1f4\/a8a\/8471f4a8a7f7a37362ff786cc77a8be2.png\" width=\"571\" height=\"453\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/847\/1f4\/a8a\/8471f4a8a7f7a37362ff786cc77a8be2.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u0442\u0443\u0442 \u0431\u043e\u043b\u0435\u0435 \u043e\u0442\u0447\u0435\u0442\u043b\u0438\u0432\u043e \u043f\u0440\u043e\u0441\u0442\u0443\u043f\u0438\u043b\u0438 \u0441\u0438\u043b\u0443\u044d\u0442\u044b \u043b\u044e\u0434\u0435\u0439. <\/p>\n<p>\u041b\u0430\u0434\u043d\u043e, \u0440\u0430\u0437 \u0443\u0436 \u043c\u044b \u0437\u0430\u0433\u043e\u0432\u043e\u0440\u0438\u043b\u0438 \u043e \u043a\u043e\u043d\u0442\u0443\u0440\u0430\u0445, \u0442\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0444\u0438\u0447. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u0441\u043e\u0431\u044b\u0435 \u0442\u043e\u0447\u043a\u0438, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e, \u0443\u0433\u043b\u044b, \u0438\u0437\u0433\u0438\u0431\u044b, \u0430 \u0442\u0430\u043a \u0436\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0440\u043e\u0441\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0432 \u0433\u043b\u0430\u0437\u0430 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430 \u0447\u0435\u043b\u043e\u0432\u0435\u0447\u0435\u0441\u043a\u043e\u043c \u043b\u0438\u0446\u0435 \u043e\u0441\u043e\u0431\u044b\u043c\u0438 \u0442\u043e\u0447\u043a\u0430\u043c\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0433\u043b\u0430\u0437\u0430, \u043d\u043e\u0441, \u0443\u0433\u043e\u043b\u043a\u0438 \u0440\u0442\u0430. \u041f\u043e\u0438\u0441\u043a \u043e\u0441\u043e\u0431\u044b\u0445 \u0442\u043e\u0447\u0435\u043a, \u043f\u043e \u0441\u0443\u0442\u0438, \u0442\u043e\u0436\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0433\u0434\u0435-\u0442\u043e \u043d\u0430 \u0433\u0440\u0430\u043d\u0438\u0446\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0439 \u0432 <a href=\"https:\/\/habr.com\/ru\/post\/540166\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0435\u0440\u0432\u043e\u043c \u0443\u0440\u043e\u043a\u0435<\/a> \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u044d\u0442\u0430\u043f\u043e\u0432 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u043d\u043e\u0433\u043e \u0437\u0440\u0435\u043d\u0438\u044f. <\/p>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c, \u043f\u043e\u0436\u0430\u043b\u0443\u0439, \u0441 \u0434\u0435\u0442\u0435\u043a\u0442\u043e\u0440\u0430 \u0425\u0430\u0440\u0440\u0438\u0441\u0430. \u0414\u0435\u0442\u0435\u043a\u0442\u043e\u0440 \u0425\u0430\u0440\u0440\u0438\u0441\u0430 \u2013 \u044d\u0442\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u043e\u0438\u0441\u043a\u0430 \u0443\u0433\u043b\u043e\u0432 \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438. \u0412 OpenCV \u0435\u0441\u0442\u044c \u0442\u0430\u043a\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f cornerHarris. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u0441\u043f\u044b\u0442\u0430\u0435\u043c \u0435\u0435:<\/p>\n<pre><code class=\"python\"># Python \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0434\u043b\u044f \u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0430\u0446\u0438\u0438 # \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0443\u0433\u043b\u0430 \u0441 # \u041c\u0435\u0442\u043e\u0434 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0443\u0433\u043b\u0430 \u0425\u0430\u0440\u0440\u0438\u0441\u0430  import cv2 import numpy as np  # \u043f\u0443\u0442\u044c \u043a \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c\u0443 \u0432\u0445\u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044e \u0438 # \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u044b imread image = cv2.imread('DSCN1311.jpg')  # \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0445\u043e\u0434\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u0426\u0432\u0435\u0442\u043e\u0432\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0432 \u043e\u0442\u0442\u0435\u043d\u043a\u0430\u0445 \u0441\u0435\u0440\u043e\u0433\u043e operatedImage = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)  # \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 # \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 32-\u0431\u0438\u0442\u043d\u043e\u0439 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0437\u0430\u043f\u044f\u0442\u043e\u0439 operatedImage = np.float32(operatedImage)  # \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u043c\u0435\u0442\u043e\u0434 cv2.cornerHarris # \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0443\u0433\u043b\u043e\u0432 \u0441 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c\u0438 # \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 dest = cv2.cornerHarris(operatedImage, 2, 5, 0.07)  # \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043e\u0442\u043c\u0435\u0447\u0435\u043d\u044b \u0447\u0435\u0440\u0435\u0437 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u044b\u0435 \u0443\u0433\u043b\u044b dest = cv2.dilate(dest, None)  # \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044f\u0441\u044c \u043a \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044e, # \u0441 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u043f\u043e\u0440\u043e\u0433\u043e\u0432\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c image[dest > 0.01 * dest.max()] = [0, 0, 255]  # \u043e\u043a\u043d\u043e \u0441 \u0432\u044b\u0432\u043e\u0434\u0438\u043c\u044b\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c \u0441 \u0443\u0433\u043b\u0430\u043c\u0438 cv2.imshow('Image with Borders', image)  if cv2.waitKey(0) &amp; 0xff == 27:     cv2.destroyAllWindows()<\/code><\/pre>\n<p>\u0418 \u0432\u043e\u0442 \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f, \u0435\u0441\u043b\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0435\u0433\u043e \u043a \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044e:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/359\/ad0\/893\/359ad08937632d5ee96b173814f35a49.png\" width=\"626\" height=\"495\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/359\/ad0\/893\/359ad08937632d5ee96b173814f35a49.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b \u0443\u0433\u043b\u044b \u043e\u043a\u043e\u043d, \u0434\u0432\u0435\u0440\u0435\u0439 \u0438 \u0441\u0442\u0435\u043d. \u0410 \u0435\u0449\u0435, \u043f\u0440\u0430\u0432\u0434\u0430, \u043e\u043d \u043f\u0440\u0438\u043d\u044f\u043b \u0437\u0430 \u0443\u0433\u043b\u044b \u0442\u0430\u043c, \u0433\u0434\u0435 \u043d\u0435\u0442 \u0443\u0433\u043b\u043e\u0432. \u041d\u0443 \u0447\u0442\u043e \u0436, \u0431\u044b\u0432\u0430\u0435\u0442, \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u044e \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e. <\/p>\n<p>\u041b\u0430\u0434\u043d\u043e, \u0432\u044b\u0434\u0435\u043b\u0438\u043b\u0438 \u043c\u044b \u043e\u0441\u043e\u0431\u044b\u0435 \u0442\u043e\u0447\u043a\u0438. \u0410 \u0447\u0442\u043e \u0434\u0430\u043b\u044c\u0448\u0435? \u0410 \u0434\u0430\u043b\u044c\u0448\u0435, \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u043e \u0436\u0435, \u0447\u0442\u043e \u0438 \u0441 \u043a\u043e\u043d\u0442\u0443\u0440\u0430\u043c\u0438:<\/p>\n<ul>\n<li>\n<p>\u0421\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0438\u0437 \u0442\u043e\u0447\u0435\u043a \u0440\u0430\u0437\u043b\u0438\u0447\u0435\u043d\u044b\u0435 \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0444\u0438\u0433\u0443\u0440\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u0432 \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u0442\u043e\u0447\u0435\u043a \u0438 \u0443\u0436\u0435 \u0438\u0445 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c. <\/p>\n<\/li>\n<li>\n<p>\u041e\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u0430\u043a \u0433\u0440\u0430\u0444 \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u043a \u043d\u0435\u043c\u0443 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u043d\u0430 \u0433\u0440\u0430\u0444\u0430\u0445. <\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0445 \u043a \u043f\u0440\u043e\u0448\u043b\u043e\u043c\u0443 \u0443\u0440\u043e\u043a\u0443 \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438: \u00ab\u041d\u0430\u0434\u0435\u044e\u0441\u044c \u043d\u0430 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435, \u0442\u0430\u043a \u043a\u0430\u043a \u0432\u043e\u0442 \u044d\u0442\u043e: &#171;\u041e\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u0430\u043a \u0433\u0440\u0430\u0444 \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u043a \u043d\u0435\u043c\u0443 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u043d\u0430 \u0433\u0440\u0430\u0444\u0430\u0445.&#187; \u043e\u0447\u0435\u043d\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442\u00bb. \u041d\u0443 \u0447\u0442\u043e \u0436, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c. \u041f\u0440\u043e\u0449\u0435 \u0432\u0441\u0435\u0433\u043e, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u0432 \u0433\u0440\u0430\u0444 \u043d\u0430\u0431\u043e\u0440 \u043e\u0441\u043e\u0431\u044b\u0445 \u0442\u043e\u0447\u0435\u043a (\u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u043a\u043e\u043d\u0442\u0443\u0440\u043e\u043c \u0442\u043e\u0447\u0435\u043a \u0431\u043e\u043b\u044c\u0448\u0435 \u0438 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043d\u0438\u043c \u0441\u043b\u043e\u0436\u043d\u0435\u0435). \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u043e\u0447\u0435\u043a, \u043f\u043e\u0432\u044b\u0441\u0438\u0432 \u043f\u043e\u0440\u043e\u0433:<\/p>\n<pre><code class=\"python\"># \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044f\u0441\u044c \u043a \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044e, # \u0441 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u043f\u043e\u0440\u043e\u0433\u043e\u0432\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c image[dest > 0.05 * dest.max()] = [0, 0, 255]<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/030\/a92\/5bb\/030a925bb8529d947f0e02e9c64c8bd0.png\" width=\"615\" height=\"486\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/030\/a92\/5bb\/030a925bb8529d947f0e02e9c64c8bd0.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u0434\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438, \u0443\u0431\u0435\u0440\u0435\u043c \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443, \u043e\u0441\u0442\u0430\u0432\u0438\u0432 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0438 \u0442\u043e\u0447\u043a\u0438:<\/p>\n<pre><code class=\"python\"># \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044f\u0441\u044c \u043a \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044e, # \u0441 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u043f\u043e\u0440\u043e\u0433\u043e\u0432\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c img_blank = np.zeros(image.shape) img_blank[dest > 0.05 * dest.max()] = [0, 0, 255]  # \u043e\u043a\u043d\u043e \u0441 \u0432\u044b\u0432\u043e\u0434\u0438\u043c\u044b\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c \u0441 \u0443\u0433\u043b\u0430\u043c\u0438 cv2.imshow('Image with Borders', img_blank)<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/bf8\/e34\/8a7\/bf8e348a78dc5286af97a03f81c0a4e2.png\" width=\"607\" height=\"480\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/bf8\/e34\/8a7\/bf8e348a78dc5286af97a03f81c0a4e2.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041a\u0430\u043a \u043d\u0430\u043c \u044d\u0442\u0438 \u0442\u043e\u0447\u043a\u0438 \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u0432 \u0433\u0440\u0430\u0444? \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0442\u0430\u043a\u0438\u043c\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c\u0438, \u043a\u0430\u043a \u0433\u0440\u0430\u0444. \u041e\u0431 \u044d\u0442\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0432 \u0441\u0442\u0430\u0442\u044c\u0435: <a href=\"https:\/\/wiki.programstore.ru\/algoritmy-obxoda-grafov-na-python-i-c\/\" rel=\"noopener noreferrer nofollow\">\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u043e\u0431\u0445\u043e\u0434\u0430 \u0433\u0440\u0430\u0444\u043e\u0432 \u043d\u0430 Python \u0438 C# &#8212; \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 Programming Store (programstore.ru)<\/a>. \u0415\u0441\u043b\u0438 \u043a\u0440\u0430\u0442\u043a\u043e, \u0442\u043e \u0433\u0440\u0430\u0444 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432 \u0432\u0438\u0434\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u0432\u0435\u0440\u0448\u0438\u043d (\u0442\u043e\u0447\u0435\u043a) \u0438 \u0438\u0445 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439 (\u0440\u0435\u0431\u0435\u0440). \u0415\u0449\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0433\u0440\u0430\u0444 \u0432 \u0432\u0438\u0434\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439. \u041a\u0430\u043a \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0433\u0440\u0430\u0444 \u043c\u044b, \u0440\u0435\u0448\u0438\u043c \u043f\u043e\u043f\u043e\u0437\u0436\u0435, \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u0435\u0440\u0435\u0431\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u0442\u043e\u0447\u043a\u0438 \u0438 \u0441\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0438\u0445 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e:<\/p>\n<pre><code class=\"python\">heigh=img_blank.shape[0] width=img_blank.shape[1] count=0 for x in range(0,width):     for y in range(0,heigh):         if img_blank[y,x,2]==255:             print(x,y)             count+=1 print(\"\u0412\u0441\u0435\u0433\u043e\",count,\"\u0442\u043e\u0447\u0435\u043a\")<\/code><\/pre>\n<p>\u0423 \u043c\u0435\u043d\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c 2829, \u043f\u0440\u0438\u0447\u0435\u043c, \u043c\u043d\u043e\u0433\u0438\u0435 \u0442\u043e\u0447\u043a\u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0440\u044f\u0434\u043e\u043c, \u0441 \u0440\u0430\u0437\u043d\u0438\u0446\u0435\u0439 \u0432\u0441\u0435\u0433\u043e \u0432 \u043e\u0434\u0438\u043d \u043f\u0438\u043a\u0441\u0435\u043b\u044c (\u0434\u0430 \u044d\u0442\u043e \u0438 \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438):<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1da\/e77\/bde\/1dae77bdeaaa3a6438e97d41b9136a52.png\" width=\"394\" height=\"274\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1da\/e77\/bde\/1dae77bdeaaa3a6438e97d41b9136a52.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041a\u0430\u043a \u044d\u0442\u043e \u0442\u043e\u0447\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0440\u0435\u0434\u0438\u0442\u044c? \u041e\u0434\u0438\u043d \u0438\u0437 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u2013 \u044d\u0442\u043e \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0431\u043b\u0438\u0437\u043a\u0438\u0435 \u0442\u043e\u0447\u043a\u0438 \u0432 \u043e\u0434\u043d\u0443, \u0446\u0435\u043d\u0442\u0440 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u043a\u0438\u043c \u0441\u0440\u0435\u0434\u043d\u0438\u043c \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0432\u043e\u0442 \u044d\u0442\u0438\u0445 \u0432\u043e\u0442 \u0431\u043b\u0438\u0437\u043a\u0438\u0445 \u0442\u043e\u0447\u0435\u043a. \u041d\u043e \u0442\u0443\u0442 \u043e\u0434\u043d\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430. \u0415\u0441\u043b\u0438 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043a\u0430\u0436\u0434\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u0441 \u043a\u0430\u0436\u0434\u043e\u0439, \u0442\u043e \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u043e\u0447\u0435\u043a \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0435. \u0427\u0438\u0441\u043b\u043e 2829 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 2 \u2013 \u044d\u0442\u043e \u0447\u0443\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 8 \u043c\u043b\u043d. \u0410 \u0435\u0441\u043b\u0438 \u0442\u043e\u0447\u0435\u043a \u0431\u0443\u0434\u0435\u0442 \u0435\u0449\u0435 \u0431\u043e\u043b\u044c\u0448\u0435? \u042f\u0432\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434 \u043d\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439. \u041a\u0430\u043a \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438 \u043e\u0431\u0445\u043e\u0434\u0435 \u0441\u0440\u0430\u0437\u0443 \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0431\u043b\u0438\u0437\u043a\u0438\u0435 \u0442\u043e\u0447\u043a\u0438 \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440, \u0430 \u0443\u0436\u0435 \u043f\u043e\u0442\u043e\u043c \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0438\u0445 \u0441\u0440\u0435\u0434\u043d\u0438\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b.<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430, \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u0447\u043a\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439:<\/p>\n<pre><code class=\"python\">#\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0442\u043e\u0447\u043a\u0443 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u0441\u043f\u0438\u0441\u043e\u0447\u043a\u043e\u0432 \u0438 \u043e\u0434\u0438\u043d\u043e\u0447\u043d\u044b\u0445 \u0442\u043e\u0447\u0435\u043a def get_last_point(ls):     lls = len(ls)     if lls>0:         item=ls[lls - 1]         if type(item)==list:             if len(item)>0:                 x,y=item[len(item)-1]             else:                 return 0, 0, False         else:             x,y=item         return x,y,True     return 0,0,False  #\u0412\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0442\u043e\u0447\u043a\u0430\u043c\u0438 def get_distance(p1,p2):     x1,y1=p1     x2,y2=p2     l = math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2))  # \u0415\u0432\u043a\u043b\u0438\u0434\u043e\u0432\u043e \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0442\u043e\u0447\u043a\u0430\u043c\u0438     return l  #\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0442\u043e\u0447\u043a\u0443 \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440  def add_point_to_claster(x,y,ls):     lls = len(ls)     item = ls[lls - 1]     if type(item) == list:         item.append((x,y))     else:         x1,y1=item         item=[(x1,y1)]         item.append((x,y))         ls[lls-1]=item<\/code><\/pre>\n<p>\u0418\u0434\u0435\u044f \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0442\u043e\u0447\u043a\u0430 \u0443 \u043d\u0430\u0441 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u0432 \u0432\u0438\u0434\u0435 \u043a\u043e\u0440\u0442\u0435\u0436\u0430 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0447\u0438\u0441\u0435\u043b (\u0435\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442). \u041c\u044b \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c \u043f\u043e \u0440\u0430\u0441\u0442\u0440\u0443, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c, \u0435\u0441\u043b\u0438 \u0442\u0430\u043c \u0442\u043e\u0447\u043a\u0430 \u0438 \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0442\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0435\u0435 \u0432 \u0441\u043f\u0438\u0441\u043e\u043a. \u041d\u043e \u0435\u0441\u043b\u0438 \u044d\u0442\u0430 \u0442\u043e\u0447\u043a\u0430 \u0431\u043b\u0438\u0437\u043a\u0430 \u043a \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0442\u043e\u0447\u043a\u0435 \u0441\u043f\u0438\u0441\u043a\u0430, \u0442\u043e \u043c\u044b \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u044d\u0442\u0443 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0442\u043e\u0447\u043a\u0443 \u0432 \u0441\u043f\u0438\u0441\u043e\u043a, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0438 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u0438. \u0414\u0430\u043b\u0435\u0435, \u0435\u0441\u043b\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0442\u043e\u0447\u043a\u0430 \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0431\u043b\u0438\u0437\u043a\u043e\u0439, \u043c\u044b \u0442\u043e\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0435\u0435 \u0432 \u044d\u0442\u043e\u0442 \u0441\u043f\u0438\u0441\u043e\u043a. \u0415\u0441\u043b\u0438 \u043d\u0435\u0442 \u2013 \u043d\u0430\u0447\u043d\u0435\u043c \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a. \u0412 \u0438\u0442\u043e\u0433\u0435 \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043f\u0438\u0441\u043a\u043e\u0432 \u0438 \u043e\u0434\u0438\u043d\u043e\u0447\u043d\u044b\u0445 \u0442\u043e\u0447\u0435\u043a (\u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442). \u041c\u043e\u0436\u043d\u043e, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0431\u044b\u043b\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0449\u0435, \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043f\u0438\u0441\u043a\u043e\u0432, \u0430 \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u043e\u0434\u0438\u043d\u043e\u0447\u043d\u0430\u044f \u0442\u043e\u0447\u043a\u0430 \u0442\u043e \u043f\u043e\u0434\u043f\u0441\u043f\u0438\u0441\u043e\u043a \u0438\u043c\u0435\u0435\u0442 \u0434\u043b\u0438\u043d\u0443 1. \u041d\u043e, \u0441 \u0434\u0443\u0440\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043c\u044b \u0435\u0449\u0435 \u043d\u0430\u0443\u0447\u0438\u043c\u0441\u044f, \u043a\u0430\u043a \u0432 Python \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u0442\u0438\u043f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439. <\/p>\n<p>\u041a\u0430\u043a \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u0447\u0442\u043e \u0442\u043e\u0447\u043a\u0438 \u0431\u043b\u0438\u0437\u043a\u0438 \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0443? \u041d\u0430\u0434\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0435\u0432\u043a\u043b\u0438\u0434\u043e\u0432 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u0438 \u0435\u0441\u043b\u0438 \u043e\u043d\u043e \u043c\u0435\u043d\u044c\u0448\u0435 \u043f\u043e\u0440\u043e\u0433\u0430, \u0442\u043e \u0442\u043e\u0447\u043a\u0438 \u0431\u043b\u0438\u0437\u043a\u0438. \u041f\u043e\u0440\u043e\u0433 \u044f \u0442\u0443\u0442 \u0432\u0437\u044f\u043b \u00ab\u0441 \u043f\u043e\u0442\u043e\u043b\u043a\u0430\u00bb, \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043b \u0440\u0430\u0432\u043d\u044b\u0439 3.<\/p>\n<p>\u0412\u043e\u0442 \u043a\u0430\u043a \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u044d\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<pre><code class=\"python\">heigh=img_blank.shape[0] width=img_blank.shape[1] points=[] for x in range(0,width):     for y in range(0,heigh):         if img_blank[y,x,2]==255:             x1, y1, point_is = get_last_point(points)             if point_is:                 l=get_distance((x1,y1),(x,y))                 if l&lt;3:                     add_point_to_claster(x,y,points)                     continue             points.append((x,y)) for point in points:     print(point)<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0447\u0442\u043e \u0432 \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/04b\/6a0\/daf\/04b6a0daf3c4ef3785b872852ce8e535.png\" width=\"629\" height=\"232\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/04b\/6a0\/daf\/04b6a0daf3c4ef3785b872852ce8e535.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435, \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u0441\u0442\u0430\u043b\u043e 591. \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u0438\u0445 \u0432 \u0442\u043e\u0447\u043a\u0438:<\/p>\n<pre><code class=\"python\"> def calk_center(ls):     ix=0     iy=0     l=float(len(ls))     for point in ls:         x,y=point         ix+=x         iy+=y     return round(ix\/l),round(iy\/l)<\/code><\/pre>\n<p>\u0412\u044b\u0432\u0435\u0434\u0435\u043c \u044d\u0442\u0438 \u0442\u043e\u0447\u043a\u0438 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d:<\/p>\n<pre><code class=\"python\">centers=[] for point in points:     if type(point)==list:         centers.append(calk_center(point))     else:         centers.append(point)  img_blank1 = np.zeros(image.shape) for point in centers:     print(point)     x,y=point     img_blank1[y,x,2]=255<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0447\u0442\u043e \u0432 \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/af3\/089\/358\/af30893581a2dbca5af34fa54beb226f.png\" width=\"617\" height=\"488\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/af3\/089\/358\/af30893581a2dbca5af34fa54beb226f.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c, \u043f\u0440\u0430\u0432\u0434\u0430, \u043d\u0435 \u043e\u0447\u0435\u043d\u044c. \u0427\u0442\u043e \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u043d\u043e, \u0434\u0430\u0436\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u0440\u043e\u0433\u0430 \u043d\u0435 \u0443\u043b\u0443\u0447\u0448\u0430\u0435\u0442 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0442\u043e\u0447\u0435\u043a. \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u043e\u0431\u0445\u043e\u0434\u0438\u0442\u044c \u0442\u043e\u0447\u043a\u0438 \u0447\u0435\u0440\u0435\u0437 \u0440\u0430\u0437\u0432\u0435\u0440\u0442\u043a\u0443 \u0431\u044b\u043b\u0430 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u0435\u0439 \u0438\u0434\u0435\u0435\u0439, \u0438\u043c\u0435\u043d\u043d\u043e \u0432 \u044d\u0442\u043e\u043c \u0438 \u043e\u0448\u0438\u0431\u043a\u0430: \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0435 \u0442\u043e\u0447\u043a\u0438, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0438\u0435\u0441\u044f \u0440\u044f\u0434\u043e\u043c, \u043c\u043e\u0433\u043b\u0438 \u043f\u043e\u043f\u0430\u0441\u0442\u044c \u0432 \u0440\u0430\u0437\u043d\u044b\u0435 \u0441\u043f\u0438\u0441\u043a\u0438. \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0443\u0440\u043e\u043a\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u0432\u0430\u043c, \u043a\u0430\u043a \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u043d\u0435\u0434\u043e\u0447\u0435\u0442. <\/p>\n<p>\u041d\u0443, \u0438 \u0432 \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u0443\u0440\u043e\u043a\u0430 \u043f\u043e\u043b\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043f\u043e \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0438 \u043f\u0440\u043e\u0440\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044e \u043e\u0441\u043e\u0431\u044b\u0445 \u0442\u043e\u0447\u0435\u043a:<\/p>\n<pre><code class=\"python\"># Python \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0434\u043b\u044f \u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0430\u0446\u0438\u0438 # \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0443\u0433\u043b\u0430 \u0441 # \u041c\u0435\u0442\u043e\u0434 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0443\u0433\u043b\u0430 \u0425\u0430\u0440\u0440\u0438\u0441\u0430  import cv2 import numpy as np import math  #\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0442\u043e\u0447\u043a\u0443 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u0441\u043f\u0438\u0441\u043e\u043a\u043e\u0432 \u0438 \u043e\u0434\u0438\u043d\u043e\u0447\u043d\u044b\u0445 \u0442\u043e\u0447\u0435\u043a def get_last_point(ls):     lls = len(ls)     if lls>0:         item=ls[lls - 1]         if type(item)==list:             if len(item)>0:                 x,y=item[len(item)-1]             else:                 return 0, 0, False         else:             x,y=item         return x,y,True     return 0,0,False  #\u0412\u044b\u0447\u0441\u043b\u0438\u0442\u044c \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0442\u043e\u0447\u043a\u0430\u043c\u0438 def get_distance(p1,p2):     x1,y1=p1     x2,y2=p2     l = math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2))  # \u0415\u0432\u043a\u043b\u0438\u0434\u043e\u0432\u043e \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0438 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439     return l  #\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0442\u043e\u0447\u043a\u0443 \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440 def add_point_to_claster(x,y,ls):     lls = len(ls)     item = ls[lls - 1]     if type(item) == list:         item.append((x,y))     else:         x1,y1=item         item=[(x1,y1)]         item.append((x,y))         ls[lls-1]=item  def calk_center(ls):     ix=0     iy=0     l=float(len(ls))     for point in ls:         x,y=point         ix+=x         iy+=y     return round(ix\/l),round(iy\/l)  # \u043f\u0443\u0442\u044c \u043a \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c\u0443 \u0432\u0445\u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044e \u0438 # \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u044b imread image = cv2.imread('DSCN1311.jpg')  # \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0445\u043e\u0434\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u0426\u0432\u0435\u0442\u043e\u0432\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0432 \u043e\u0442\u0442\u0435\u043d\u043a\u0430\u0445\u0441\u0435\u0440\u043e\u0433\u043e operatedImage = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)  # \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 # \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 32-\u0431\u0438\u0442\u043d\u043e\u0439 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0437\u0430\u043f\u044f\u0442\u043e\u0439 operatedImage = np.float32(operatedImage)  # \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u043c\u0435\u0442\u043e\u0434 cv2.cornerHarris # \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0443\u0433\u043b\u043e\u0432 \u0441 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c\u0438 # \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 dest = cv2.cornerHarris(operatedImage, 2, 5, 0.07)  # \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043e\u0442\u043c\u0435\u0447\u0435\u043d\u044b \u0447\u0435\u0440\u0435\u0437 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u044b\u0435 \u0443\u0433\u043b\u044b dest = cv2.dilate(dest, None)  # \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044f\u0441\u044c \u043a \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044e, # \u0441 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u043f\u043e\u0440\u043e\u0433\u043e\u0432\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c img_blank = np.zeros(image.shape) img_blank[dest > 0.05 * dest.max()] = [0, 0, 255]  heigh=img_blank.shape[0] width=img_blank.shape[1] points=[] for x in range(0,width):     for y in range(0,heigh):         if img_blank[y,x,2]==255:             x1, y1, point_is = get_last_point(points)             if point_is:                 l=get_distance((x1,y1),(x,y))                 if l&lt;3:                     add_point_to_claster(x,y,points)                     continue             points.append((x,y)) centers=[] for point in points:     if type(point)==list:         centers.append(calk_center(point))     else:         centers.append(point)  img_blank1 = np.zeros(image.shape) for point in centers:     print(point)     x,y=point     img_blank1[y,x,2]=255  # \u043e\u043a\u043d\u043e \u0441 \u0432\u044b\u0432\u043e\u0434\u0438\u043c\u044b\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c \u0441 \u0443\u0433\u043b\u0430\u043c\u0438 cv2.imshow('Image with Borders', img_blank1)  if cv2.waitKey(0) &amp; 0xff == 27:     cv2.destroyAllWindows() <\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/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\/post\/656489\/\"> https:\/\/habr.com\/ru\/post\/656489\/<\/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_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041d\u0430 <a href=\"https:\/\/habr.com\/ru\/post\/654663\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u043e\u0448\u043b\u043e\u043c \u0443\u0440\u043e\u043a\u0435<\/a> \u043c\u044b \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043b\u0438\u0441\u044c \u0441 \u043c\u0435\u0434\u0438\u0430\u043d\u043d\u043e\u0439 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0435\u0439, \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u043c\u0438 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u043c\u0438 \u0438 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u043a\u043e\u043d\u0442\u0443\u0440\u043e\u0432. \u041d\u0430\u043f\u043e\u043c\u043d\u044e, \u0447\u0442\u043e \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0443\u0440 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432 \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u0438 \u0434\u043b\u044f \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0444\u0438\u0447. \u0412 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u0432\u043e\u0442 \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0434\u0430\u043b\u0435\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043a\u043e\u043d\u0442\u0443\u0440\u043e\u043c:<\/p>\n<ul>\n<li>\n<p>\u0412\u044b\u044f\u0432\u0438\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u044b (\u043f\u0440\u044f\u043c\u044b\u0435, \u043e\u043a\u0440\u0443\u0436\u043d\u043e\u0441\u0442\u0438).<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u0432 \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u0442\u043e\u0447\u0435\u043a \u0438 \u0443\u0436\u0435 \u0438\u0445 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c. <\/p>\n<\/li>\n<li>\n<p>\u041e\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u0430\u043a \u0433\u0440\u0430\u0444 \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u043a \u043d\u0435\u043c\u0443 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u043d\u0430 \u0433\u0440\u0430\u0444\u0430\u0445. <\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u043c \u0438\u0437\u0443\u0447\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u043f\u0440\u0435\u0434\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u0430\u0441\u0442\u043d\u044b\u043c:<\/p>\n<pre><code class=\"python\">import cv2  img = cv2.imread('MyPhoto.jpg', 1) cv2.imshow(\"Original image\",img)  # CLAHE (Contrast Limited Adaptive Histogram Equalization) clahe = cv2.createCLAHE(clipLimit=3., tileGridSize=(8,8))  lab = cv2.cvtColor(img, cv2.COLOR_BGR2LAB)  # convert from BGR to LAB color space l, a, b = cv2.split(lab)  # split on 3 different channels  l2 = clahe.apply(l)  # apply CLAHE to the L-channel  lab = cv2.merge((l2,a,b))  # merge channels img2 = cv2.cvtColor(lab, cv2.COLOR_LAB2BGR)  # convert from LAB to BGR cv2.imshow('Increased contrast', img2)  cv2.waitKey(0) cv2.destroyAllWindows() <\/code><\/pre>\n<p>\u0418\u0441\u043f\u044b\u0442\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u0443\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u043d\u0430 \u0432\u0441\u0435 \u0442\u043e\u0439 \u0436\u0435 \u0434\u043e \u0431\u043e\u043b\u0438 \u0437\u043d\u0430\u043a\u043e\u043c\u043e\u0439 \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0443\u0440\u043e\u043a\u043e\u0432 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435 \u0441 \u043f\u0430\u043b\u044c\u043c\u0430\u043c\u0438:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0418\u043b\u0438, \u0432\u043e\u0442, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0444\u043e\u0442\u043e, \u0441\u0434\u0435\u043b\u0430\u043d\u043d\u043e\u0435 \u0432 \u0442\u0435\u043c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0441\u0443\u0442\u043e\u043a:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0417\u0430\u043c\u0435\u0447\u0443, \u0447\u0442\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u0430\u0434\u0430\u043f\u0442\u0438\u0432\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0442\u0440\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438. \u0422\u0443\u0442, \u0434\u0443\u043c\u0430\u044e, \u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u044f \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0430\u0434\u0430\u043f\u0442\u0438\u0432\u043d\u0443\u044e \u0433\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c\u0443. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u0431\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0431\u043b\u043e\u043a\u0438 8 \u043d\u0430 8 \u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0433\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e:<\/p>\n<pre><code class=\"python\"># CLAHE (Contrast Limited Adaptive Histogram Equalization) clahe = cv2.createCLAHE(clipLimit=3., tileGridSize=(8,8))<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435, \u0434\u043b\u044f \u043d\u0430\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432\u044b\u0440\u043e\u0432\u043d\u0435\u043d\u043d\u044b\u0445 \u0433\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043e\u043d\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442\u0441\u044f\u00a0 \u0444\u043e\u0440\u043c\u0430\u0442 LAB, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043e\u0434\u0438\u043d \u043a\u0430\u043d\u0430\u043b \u0441\u0432\u0435\u0442\u043b\u043e\u0442\u044b L \u0438 \u0434\u0432\u0430 \u043a\u0430\u043d\u0430\u043b\u0430 \u0446\u0432\u0435\u0442\u0430 A \u0438 B:<\/p>\n<pre><code class=\"python\">lab = cv2.cvtColor(img, cv2.COLOR_BGR2LAB)  # convert from BGR to LAB color space l, a, b = cv2.split(lab)  # split on 3 different channels<\/code><\/pre>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0432\u044b\u0440\u043e\u0432\u043d\u0435\u043d\u043d\u044b\u0435 \u0433\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c\u044b (\u0442\u043e\u043b\u044c\u043a\u043e \u043a \u043a\u0430\u043d\u0430\u043b\u0443 L \u2013 \u0441\u0432\u0435\u0442\u043b\u043e\u0442\u0430):<\/p>\n<pre><code class=\"python\">l2 = clahe.apply(l)  # apply CLAHE to the L-channel<\/code><\/pre>\n<p>\u0417\u0430\u0442\u0435\u043c \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u043c \u044d\u0442\u0438 \u043a\u0430\u043d\u0430\u043b\u044b \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043c \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435:<\/p>\n<pre><code class=\"python\">lab = cv2.merge((l2,a,b))  # merge channels img2 = cv2.cvtColor(lab, cv2.COLOR_LAB2BGR)  # convert from LAB to BGR cv2.imshow('Increased contrast', img2)<\/code><\/pre>\n<p>\u041e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0441\u0442\u043e\u0438\u0442 \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0435 clipLimit. \u041e\u043d \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043d\u0442\u0440\u0430\u0441\u0442\u043d\u0435\u0435 \u0441\u0442\u0430\u043d\u0435\u0442 \u0444\u043e\u0442\u043e. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043c \u0435\u0433\u043e 10 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0432\u043e\u0442 \u044d\u0442\u043e:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u0442\u0443\u0442 \u043f\u0440\u043e\u0441\u0442\u0443\u043f\u0438\u043b\u0438 \u0434\u0430\u0436\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0435\u0442\u0430\u043b\u0438 \u0432\u0434\u0430\u043b\u0438. \u041f\u0440\u0430\u0432\u0434\u0430, \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440, \u0435\u0441\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u0435\u0434\u0435\u043b, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0448\u0443\u043c\u044b \u0438\u0441\u043f\u043e\u0440\u0442\u044f\u0442 \u0444\u043e\u0442\u043e\u0447\u043a\u0443. \u0412\u043e\u0442 \u0447\u0442\u043e \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c, \u0435\u0441\u043b\u0438 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043c \u0435\u0433\u043e 100:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0443 \u0442\u043e\u0439 \u0436\u0435 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u043a\u043e\u043d\u0442\u0443\u0440 (\u0431\u0435\u0437 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0442\u0440\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438):<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0410 \u0435\u0441\u043b\u0438 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u044c:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u0442\u0443\u0442 \u0431\u043e\u043b\u0435\u0435 \u043e\u0442\u0447\u0435\u0442\u043b\u0438\u0432\u043e \u043f\u0440\u043e\u0441\u0442\u0443\u043f\u0438\u043b\u0438 \u0441\u0438\u043b\u0443\u044d\u0442\u044b \u043b\u044e\u0434\u0435\u0439. <\/p>\n<p>\u041b\u0430\u0434\u043d\u043e, \u0440\u0430\u0437 \u0443\u0436 \u043c\u044b \u0437\u0430\u0433\u043e\u0432\u043e\u0440\u0438\u043b\u0438 \u043e \u043a\u043e\u043d\u0442\u0443\u0440\u0430\u0445, \u0442\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0444\u0438\u0447. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u0441\u043e\u0431\u044b\u0435 \u0442\u043e\u0447\u043a\u0438, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e, \u0443\u0433\u043b\u044b, \u0438\u0437\u0433\u0438\u0431\u044b, \u0430 \u0442\u0430\u043a \u0436\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0440\u043e\u0441\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0432 \u0433\u043b\u0430\u0437\u0430 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430 \u0447\u0435\u043b\u043e\u0432\u0435\u0447\u0435\u0441\u043a\u043e\u043c \u043b\u0438\u0446\u0435 \u043e\u0441\u043e\u0431\u044b\u043c\u0438 \u0442\u043e\u0447\u043a\u0430\u043c\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0433\u043b\u0430\u0437\u0430, \u043d\u043e\u0441, \u0443\u0433\u043e\u043b\u043a\u0438 \u0440\u0442\u0430. \u041f\u043e\u0438\u0441\u043a \u043e\u0441\u043e\u0431\u044b\u0445 \u0442\u043e\u0447\u0435\u043a, \u043f\u043e \u0441\u0443\u0442\u0438, \u0442\u043e\u0436\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0433\u0434\u0435-\u0442\u043e \u043d\u0430 \u0433\u0440\u0430\u043d\u0438\u0446\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u0439 \u0432 <a href=\"https:\/\/habr.com\/ru\/post\/540166\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0435\u0440\u0432\u043e\u043c \u0443\u0440\u043e\u043a\u0435<\/a> \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u044d\u0442\u0430\u043f\u043e\u0432 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u043d\u043e\u0433\u043e \u0437\u0440\u0435\u043d\u0438\u044f. <\/p>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c, \u043f\u043e\u0436\u0430\u043b\u0443\u0439, \u0441 \u0434\u0435\u0442\u0435\u043a\u0442\u043e\u0440\u0430 \u0425\u0430\u0440\u0440\u0438\u0441\u0430. \u0414\u0435\u0442\u0435\u043a\u0442\u043e\u0440 \u0425\u0430\u0440\u0440\u0438\u0441\u0430 \u2013 \u044d\u0442\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u043e\u0438\u0441\u043a\u0430 \u0443\u0433\u043b\u043e\u0432 \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438. \u0412 OpenCV \u0435\u0441\u0442\u044c \u0442\u0430\u043a\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f cornerHarris. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u0441\u043f\u044b\u0442\u0430\u0435\u043c \u0435\u0435:<\/p>\n<pre><code class=\"python\"># Python \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0434\u043b\u044f \u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0430\u0446\u0438\u0438 # \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0443\u0433\u043b\u0430 \u0441 # \u041c\u0435\u0442\u043e\u0434 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0443\u0433\u043b\u0430 \u0425\u0430\u0440\u0440\u0438\u0441\u0430  import cv2 import numpy as np  # \u043f\u0443\u0442\u044c \u043a \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c\u0443 \u0432\u0445\u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044e \u0438 # \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u044b imread image = cv2.imread('DSCN1311.jpg')  # \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0445\u043e\u0434\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u0426\u0432\u0435\u0442\u043e\u0432\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0432 \u043e\u0442\u0442\u0435\u043d\u043a\u0430\u0445 \u0441\u0435\u0440\u043e\u0433\u043e operatedImage = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)  # \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 # \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 32-\u0431\u0438\u0442\u043d\u043e\u0439 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0437\u0430\u043f\u044f\u0442\u043e\u0439 operatedImage = np.float32(operatedImage)  # \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u043c\u0435\u0442\u043e\u0434 cv2.cornerHarris # \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0443\u0433\u043b\u043e\u0432 \u0441 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c\u0438 # \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 dest = cv2.cornerHarris(operatedImage, 2, 5, 0.07)  # \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043e\u0442\u043c\u0435\u0447\u0435\u043d\u044b \u0447\u0435\u0440\u0435\u0437 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u044b\u0435 \u0443\u0433\u043b\u044b dest = cv2.dilate(dest, None)  # \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044f\u0441\u044c \u043a \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044e, # \u0441 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u043f\u043e\u0440\u043e\u0433\u043e\u0432\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c image[dest > 0.01 * dest.max()] = [0, 0, 255]  # \u043e\u043a\u043d\u043e \u0441 \u0432\u044b\u0432\u043e\u0434\u0438\u043c\u044b\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c \u0441 \u0443\u0433\u043b\u0430\u043c\u0438 cv2.imshow('Image with Borders', image)  if cv2.waitKey(0) &amp; 0xff == 27:     cv2.destroyAllWindows()<\/code><\/pre>\n<p>\u0418 \u0432\u043e\u0442 \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f, \u0435\u0441\u043b\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0435\u0433\u043e \u043a \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044e:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b \u0443\u0433\u043b\u044b \u043e\u043a\u043e\u043d, \u0434\u0432\u0435\u0440\u0435\u0439 \u0438 \u0441\u0442\u0435\u043d. \u0410 \u0435\u0449\u0435, \u043f\u0440\u0430\u0432\u0434\u0430, \u043e\u043d \u043f\u0440\u0438\u043d\u044f\u043b \u0437\u0430 \u0443\u0433\u043b\u044b \u0442\u0430\u043c, \u0433\u0434\u0435 \u043d\u0435\u0442 \u0443\u0433\u043b\u043e\u0432. \u041d\u0443 \u0447\u0442\u043e \u0436, \u0431\u044b\u0432\u0430\u0435\u0442, \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u044e \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e. <\/p>\n<p>\u041b\u0430\u0434\u043d\u043e, \u0432\u044b\u0434\u0435\u043b\u0438\u043b\u0438 \u043c\u044b \u043e\u0441\u043e\u0431\u044b\u0435 \u0442\u043e\u0447\u043a\u0438. \u0410 \u0447\u0442\u043e \u0434\u0430\u043b\u044c\u0448\u0435? \u0410 \u0434\u0430\u043b\u044c\u0448\u0435, \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u043e \u0436\u0435, \u0447\u0442\u043e \u0438 \u0441 \u043a\u043e\u043d\u0442\u0443\u0440\u0430\u043c\u0438:<\/p>\n<ul>\n<li>\n<p>\u0421\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0438\u0437 \u0442\u043e\u0447\u0435\u043a \u0440\u0430\u0437\u043b\u0438\u0447\u0435\u043d\u044b\u0435 \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0444\u0438\u0433\u0443\u0440\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u0432 \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u0442\u043e\u0447\u0435\u043a \u0438 \u0443\u0436\u0435 \u0438\u0445 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c. <\/p>\n<\/li>\n<li>\n<p>\u041e\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u0430\u043a \u0433\u0440\u0430\u0444 \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u043a \u043d\u0435\u043c\u0443 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u043d\u0430 \u0433\u0440\u0430\u0444\u0430\u0445. <\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0445 \u043a \u043f\u0440\u043e\u0448\u043b\u043e\u043c\u0443 \u0443\u0440\u043e\u043a\u0443 \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438: \u00ab\u041d\u0430\u0434\u0435\u044e\u0441\u044c \u043d\u0430 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435, \u0442\u0430\u043a \u043a\u0430\u043a \u0432\u043e\u0442 \u044d\u0442\u043e: &#171;\u041e\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u0430\u043a \u0433\u0440\u0430\u0444 \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u043a \u043d\u0435\u043c\u0443 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u043d\u0430 \u0433\u0440\u0430\u0444\u0430\u0445.&#187; \u043e\u0447\u0435\u043d\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442\u00bb. \u041d\u0443 \u0447\u0442\u043e \u0436, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c. \u041f\u0440\u043e\u0449\u0435 \u0432\u0441\u0435\u0433\u043e, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u0432 \u0433\u0440\u0430\u0444 \u043d\u0430\u0431\u043e\u0440 \u043e\u0441\u043e\u0431\u044b\u0445 \u0442\u043e\u0447\u0435\u043a (\u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u043a\u043e\u043d\u0442\u0443\u0440\u043e\u043c \u0442\u043e\u0447\u0435\u043a \u0431\u043e\u043b\u044c\u0448\u0435 \u0438 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043d\u0438\u043c \u0441\u043b\u043e\u0436\u043d\u0435\u0435). \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u043e\u0447\u0435\u043a, \u043f\u043e\u0432\u044b\u0441\u0438\u0432 \u043f\u043e\u0440\u043e\u0433:<\/p>\n<pre><code class=\"python\"># \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044f\u0441\u044c \u043a \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044e, # \u0441 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u043f\u043e\u0440\u043e\u0433\u043e\u0432\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c image[dest > 0.05 * dest.max()] = [0, 0, 255]<\/code><\/pre>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u0434\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438, \u0443\u0431\u0435\u0440\u0435\u043c \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443, \u043e\u0441\u0442\u0430\u0432\u0438\u0432 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0438 \u0442\u043e\u0447\u043a\u0438:<\/p>\n<pre><code class=\"python\"># \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044f\u0441\u044c \u043a \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044e, # \u0441 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u043f\u043e\u0440\u043e\u0433\u043e\u0432\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c img_blank = np.zeros(image.shape) img_blank[dest > 0.05 * dest.max()] = [0, 0, 255]  # \u043e\u043a\u043d\u043e \u0441 \u0432\u044b\u0432\u043e\u0434\u0438\u043c\u044b\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c \u0441 \u0443\u0433\u043b\u0430\u043c\u0438 cv2.imshow('Image with Borders', img_blank)<\/code><\/pre>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041a\u0430\u043a \u043d\u0430\u043c \u044d\u0442\u0438 \u0442\u043e\u0447\u043a\u0438 \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u0432 \u0433\u0440\u0430\u0444? \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0442\u0430\u043a\u0438\u043c\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c\u0438, \u043a\u0430\u043a \u0433\u0440\u0430\u0444. \u041e\u0431 \u044d\u0442\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0432 \u0441\u0442\u0430\u0442\u044c\u0435: <a href=\"https:\/\/wiki.programstore.ru\/algoritmy-obxoda-grafov-na-python-i-c\/\" rel=\"noopener noreferrer nofollow\">\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u043e\u0431\u0445\u043e\u0434\u0430 \u0433\u0440\u0430\u0444\u043e\u0432 \u043d\u0430 Python \u0438 C# &#8212; \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 Programming Store (programstore.ru)<\/a>. \u0415\u0441\u043b\u0438 \u043a\u0440\u0430\u0442\u043a\u043e, \u0442\u043e \u0433\u0440\u0430\u0444 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432 \u0432\u0438\u0434\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u0432\u0435\u0440\u0448\u0438\u043d (\u0442\u043e\u0447\u0435\u043a) \u0438 \u0438\u0445 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439 (\u0440\u0435\u0431\u0435\u0440). \u0415\u0449\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0433\u0440\u0430\u0444 \u0432 \u0432\u0438\u0434\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439. \u041a\u0430\u043a \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0433\u0440\u0430\u0444 \u043c\u044b, \u0440\u0435\u0448\u0438\u043c \u043f\u043e\u043f\u043e\u0437\u0436\u0435, \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u0435\u0440\u0435\u0431\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u0442\u043e\u0447\u043a\u0438 \u0438 \u0441\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0438\u0445 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e:<\/p>\n<pre><code class=\"python\">heigh=img_blank.shape[0] width=img_blank.shape[1] count=0 for x in range(0,width):     for y in range(0,heigh):         if img_blank[y,x,2]==255:             print(x,y)             count+=1 print(\"\u0412\u0441\u0435\u0433\u043e\",count,\"\u0442\u043e\u0447\u0435\u043a\")<\/code><\/pre>\n<p>\u0423 \u043c\u0435\u043d\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c 2829, \u043f\u0440\u0438\u0447\u0435\u043c, \u043c\u043d\u043e\u0433\u0438\u0435 \u0442\u043e\u0447\u043a\u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0440\u044f\u0434\u043e\u043c, \u0441 \u0440\u0430\u0437\u043d\u0438\u0446\u0435\u0439 \u0432\u0441\u0435\u0433\u043e \u0432 \u043e\u0434\u0438\u043d \u043f\u0438\u043a\u0441\u0435\u043b\u044c (\u0434\u0430 \u044d\u0442\u043e \u0438 \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438):<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u041a\u0430\u043a \u044d\u0442\u043e \u0442\u043e\u0447\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0440\u0435\u0434\u0438\u0442\u044c? \u041e\u0434\u0438\u043d \u0438\u0437 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u2013 \u044d\u0442\u043e \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0431\u043b\u0438\u0437\u043a\u0438\u0435 \u0442\u043e\u0447\u043a\u0438 \u0432 \u043e\u0434\u043d\u0443, \u0446\u0435\u043d\u0442\u0440 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u043a\u0438\u043c \u0441\u0440\u0435\u0434\u043d\u0438\u043c \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0432\u043e\u0442 \u044d\u0442\u0438\u0445 \u0432\u043e\u0442 \u0431\u043b\u0438\u0437\u043a\u0438\u0445 \u0442\u043e\u0447\u0435\u043a. \u041d\u043e \u0442\u0443\u0442 \u043e\u0434\u043d\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430. \u0415\u0441\u043b\u0438 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043a\u0430\u0436\u0434\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u0441 \u043a\u0430\u0436\u0434\u043e\u0439, \u0442\u043e \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u043e\u0447\u0435\u043a \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0435. \u0427\u0438\u0441\u043b\u043e 2829 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 2 \u2013 \u044d\u0442\u043e \u0447\u0443\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 8 \u043c\u043b\u043d. \u0410 \u0435\u0441\u043b\u0438 \u0442\u043e\u0447\u0435\u043a \u0431\u0443\u0434\u0435\u0442 \u0435\u0449\u0435 \u0431\u043e\u043b\u044c\u0448\u0435? \u042f\u0432\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434 \u043d\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439. \u041a\u0430\u043a \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438 \u043e\u0431\u0445\u043e\u0434\u0435 \u0441\u0440\u0430\u0437\u0443 \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0431\u043b\u0438\u0437\u043a\u0438\u0435 \u0442\u043e\u0447\u043a\u0438 \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440, \u0430 \u0443\u0436\u0435 \u043f\u043e\u0442\u043e\u043c \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0438\u0445 \u0441\u0440\u0435\u0434\u043d\u0438\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b.<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430, \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u0447\u043a\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439:<\/p>\n<pre><code class=\"python\">#\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0442\u043e\u0447\u043a\u0443 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u0441\u043f\u0438\u0441\u043e\u0447\u043a\u043e\u0432 \u0438 \u043e\u0434\u0438\u043d\u043e\u0447\u043d\u044b\u0445 \u0442\u043e\u0447\u0435\u043a def get_last_point(ls):     lls = len(ls)     if lls>0:         item=ls[lls - 1]         if type(item)==list:             if len(item)>0:                 x,y=item[len(item)-1]             else:                 return 0, 0, False         else:             x,y=item         return x,y,True     return 0,0,False  #\u0412\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0442\u043e\u0447\u043a\u0430\u043c\u0438 def get_distance(p1,p2):     x1,y1=p1     x2,y2=p2     l = math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2))  # \u0415\u0432\u043a\u043b\u0438\u0434\u043e\u0432\u043e \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0442\u043e\u0447\u043a\u0430\u043c\u0438     return l  #\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0442\u043e\u0447\u043a\u0443 \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440  def add_point_to_claster(x,y,ls):     lls = len(ls)     item = ls[lls - 1]     if type(item) == list:         item.append((x,y))     else:         x1,y1=item         item=[(x1,y1)]         item.append((x,y))         ls[lls-1]=item<\/code><\/pre>\n<p>\u0418\u0434\u0435\u044f \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0442\u043e\u0447\u043a\u0430 \u0443 \u043d\u0430\u0441 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u0432 \u0432\u0438\u0434\u0435 \u043a\u043e\u0440\u0442\u0435\u0436\u0430 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0447\u0438\u0441\u0435\u043b (\u0435\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442). \u041c\u044b \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c \u043f\u043e \u0440\u0430\u0441\u0442\u0440\u0443, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c, \u0435\u0441\u043b\u0438 \u0442\u0430\u043c \u0442\u043e\u0447\u043a\u0430 \u0438 \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0442\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0435\u0435 \u0432 \u0441\u043f\u0438\u0441\u043e\u043a. \u041d\u043e \u0435\u0441\u043b\u0438 \u044d\u0442\u0430 \u0442\u043e\u0447\u043a\u0430 \u0431\u043b\u0438\u0437\u043a\u0430 \u043a \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0442\u043e\u0447\u043a\u0435 \u0441\u043f\u0438\u0441\u043a\u0430, \u0442\u043e \u043c\u044b \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u044d\u0442\u0443 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0442\u043e\u0447\u043a\u0443 \u0432 \u0441\u043f\u0438\u0441\u043e\u043a, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0438 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u0438. \u0414\u0430\u043b\u0435\u0435, \u0435\u0441\u043b\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0442\u043e\u0447\u043a\u0430 \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0431\u043b\u0438\u0437\u043a\u043e\u0439, \u043c\u044b \u0442\u043e\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0435\u0435 \u0432 \u044d\u0442\u043e\u0442 \u0441\u043f\u0438\u0441\u043e\u043a. \u0415\u0441\u043b\u0438 \u043d\u0435\u0442 \u2013 \u043d\u0430\u0447\u043d\u0435\u043c \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a. \u0412 \u0438\u0442\u043e\u0433\u0435 \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043f\u0438\u0441\u043a\u043e\u0432 \u0438 \u043e\u0434\u0438\u043d\u043e\u0447\u043d\u044b\u0445 \u0442\u043e\u0447\u0435\u043a (\u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442). \u041c\u043e\u0436\u043d\u043e, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0431\u044b\u043b\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0449\u0435, \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043f\u0438\u0441\u043a\u043e\u0432, \u0430 \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u043e\u0434\u0438\u043d\u043e\u0447\u043d\u0430\u044f \u0442\u043e\u0447\u043a\u0430 \u0442\u043e \u043f\u043e\u0434\u043f\u0441\u043f\u0438\u0441\u043e\u043a \u0438\u043c\u0435\u0435\u0442 \u0434\u043b\u0438\u043d\u0443 1. \u041d\u043e, \u0441 \u0434\u0443\u0440\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043c\u044b \u0435\u0449\u0435 \u043d\u0430\u0443\u0447\u0438\u043c\u0441\u044f, \u043a\u0430\u043a \u0432 Python \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u0442\u0438\u043f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439. <\/p>\n<p>\u041a\u0430\u043a \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u0447\u0442\u043e \u0442\u043e\u0447\u043a\u0438 \u0431\u043b\u0438\u0437\u043a\u0438 \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0443? \u041d\u0430\u0434\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0435\u0432\u043a\u043b\u0438\u0434\u043e\u0432 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u0438 \u0435\u0441\u043b\u0438 \u043e\u043d\u043e \u043c\u0435\u043d\u044c\u0448\u0435 \u043f\u043e\u0440\u043e\u0433\u0430, \u0442\u043e \u0442\u043e\u0447\u043a\u0438 \u0431\u043b\u0438\u0437\u043a\u0438. \u041f\u043e\u0440\u043e\u0433 \u044f \u0442\u0443\u0442 \u0432\u0437\u044f\u043b \u00ab\u0441 \u043f\u043e\u0442\u043e\u043b\u043a\u0430\u00bb, \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043b \u0440\u0430\u0432\u043d\u044b\u0439 3.<\/p>\n<p>\u0412\u043e\u0442 \u043a\u0430\u043a \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u044d\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<pre><code class=\"python\">heigh=img_blank.shape[0] width=img_blank.shape[1] points=[] for x in range(0,width):     for y in range(0,heigh):         if img_blank[y,x,2]==255:             x1, y1, point_is = get_last_point(points)             if point_is:                 l=get_distance((x1,y1),(x,y))                 if l&lt;3:                     add_point_to_claster(x,y,points)                     continue             points.append((x,y)) for point in points:     print(point)<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0447\u0442\u043e \u0432 \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435, \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u0441\u0442\u0430\u043b\u043e 591. \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u0438\u0445 \u0432 \u0442\u043e\u0447\u043a\u0438:<\/p>\n<pre><code class=\"python\"> def calk_center(ls):     ix=0     iy=0     l=float(len(ls))     for point in ls:         x,y=point         ix+=x         iy+=y     return round(ix\/l),round(iy\/l)<\/code><\/pre>\n<p>\u0412\u044b\u0432\u0435\u0434\u0435\u043c \u044d\u0442\u0438 \u0442\u043e\u0447\u043a\u0438 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d:<\/p>\n<pre><code class=\"python\">centers=[] for point in points:     if type(point)==list:         centers.append(calk_center(point))     else:         centers.append(point)  img_blank1 =<\/code><\/pre>\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-330845","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/330845","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=330845"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/330845\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=330845"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=330845"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=330845"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}