{"id":330399,"date":"2022-03-07T21:00:30","date_gmt":"2022-03-07T21:00:30","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=330399"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=330399","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 3<\/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>\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u043c \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u043d\u043e\u0433\u043e \u0437\u0440\u0435\u043d\u0438\u044f. \u041d\u0430\u0447\u0430\u043b\u043e <a href=\"https:\/\/habr.com\/ru\/post\/540166\/\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>. \u041d\u0430\u043f\u043e\u043c\u043d\u044e \u043a\u0440\u0430\u0442\u043a\u043e\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0443\u0440\u043e\u043a\u043e\u0432. \u041c\u044b \u0438\u0437\u0443\u0447\u0438\u043b\u0438 \u044d\u0442\u0430\u043f\u044b \u0430\u043d\u0430\u043b\u0438\u0437 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 OpenCV, \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043d\u0430\u0434 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u0447\u0435\u0440\u043d\u043e-\u0431\u0435\u043b\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442, \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u0432, \u043d\u0430\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u043d\u0438\u0435 \u0444\u0438\u043b\u044c\u0442\u0440\u0430 \u0440\u0430\u0437\u043c\u044b\u0442\u0438\u044f. <\/p>\n<p>\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u043c \u0442\u0435\u043c\u0443 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439. \u041d\u0430 <a href=\"https:\/\/habr.com\/ru\/post\/651989\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u043e\u0448\u043b\u043e\u043c \u0443\u0440\u043e\u043a\u0435<\/a> \u043c\u044b \u043f\u044b\u0442\u0430\u043b\u0438\u0441\u044c \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0440\u0430\u0437\u043c\u044b\u0442\u0438\u044f \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0438\u0437 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u0438\u0435 \u0434\u0435\u0444\u0435\u043a\u0442\u044b, \u043a\u0430\u043a \u0433\u0430\u0443\u0441\u0441\u043e\u0432\u0441\u043a\u0438\u0439 \u0448\u0443\u043c \u0438 \u0446\u0430\u0440\u0430\u043f\u0438\u043d\u044b. \u0421 \u043f\u0435\u0440\u0432\u044b\u043c \u0447\u0442\u043e-\u0442\u043e \u0431\u043e\u043b\u0435\u0435-\u043c\u0435\u043d\u0435\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c, \u0430 \u0432\u043e\u0442 \u0441 \u0446\u0430\u0440\u0430\u043f\u0438\u043d\u0430\u043c\u0438 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0432\u044b\u0448\u043b\u043e. \u0414\u0430, \u043a\u0441\u0442\u0430\u0442\u0438, \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0445 \u043c\u043d\u0435 \u0431\u044b\u043b \u0437\u0430\u0434\u0430\u043d \u0432\u043e\u043f\u0440\u043e\u0441: \u00ab\u041e\u0442\u043a\u0443\u0434\u0430 \u0431\u0435\u0440\u0435\u0442\u0441\u044f \u0433\u0430\u0443\u0441\u0441\u043e\u0432\u043a\u0438\u0439 \u0448\u0443\u043c?\u00bb <\/p>\n<p>\u041e\u0442\u0432\u0435\u0447\u0430\u044e: <\/p>\n<p>\u0413\u0430\u0443\u0441\u0441\u043e\u0432\u0441\u043a\u0438\u0439 \u0448\u0443\u043c \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u0442 \u043f\u043e\u043c\u0435\u0445. \u0418\u043b\u0438, \u0435\u0441\u043b\u0438 \u0443 \u043d\u0430\u0441 \u0431\u044b\u043b\u043e \u043f\u043b\u043e\u0445\u043e\u0435 \u043e\u0441\u0432\u0435\u0449\u0435\u043d\u0438\u0435, \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430\u0441\u044c \u0442\u0435\u043c\u043d\u0430\u044f, \u0438 \u043c\u044b \u043f\u043e\u043f\u044b\u0442\u0430\u043b\u0438\u0441\u044c \u043a\u0430\u043a-\u0442\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u044c. \u0428\u0443\u043c\u044b \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0442\u043e\u0436\u0435 \u0443\u0441\u0438\u043b\u044f\u0442\u0441\u044f.<\/p>\n<p>\u041b\u0430\u0434\u043d\u043e. \u0418\u0434\u0435\u043c \u0434\u0430\u043b\u044c\u0448\u0435. \u041a\u0430\u043a \u0436\u0435 \u043d\u0430\u043c \u0431\u044b\u0442\u044c \u0441 \u0446\u0430\u0440\u0430\u043f\u0438\u043d\u0430\u043c\u0438? \u0410 \u0434\u043b\u044f \u0438\u0445 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043c\u0435\u0434\u0438\u0430\u043d\u043d\u044b\u043c \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u043c:<\/p>\n<pre><code class=\"python\">import cv2 my_photo = cv2.imread('MyPhoto1.jpg') median_image  = cv2.medianBlur(my_photo,3) cv2.imshow('MyPhoto', median_image ) cv2.waitKey(0) cv2.destroyAllWindows()<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0438\u0441\u0445\u043e\u0434\u043d\u0430\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/49b\/a00\/644\/49ba0064473d395835e72947ac533622.png\" width=\"627\" height=\"474\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/49b\/a00\/644\/49ba0064473d395835e72947ac533622.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0410 \u0432\u043e\u0442 \u043c\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043b\u0438 \u043a \u043d\u0435\u0439 \u0444\u0438\u043b\u044c\u0442\u0440 3 \u043d\u0430 3:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/19c\/93f\/6fe\/19c93f6fe02576ddc9fd4f73aa7edbb7.png\" width=\"651\" height=\"489\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/19c\/93f\/6fe\/19c93f6fe02576ddc9fd4f73aa7edbb7.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u0446\u0430\u0440\u0430\u043f\u0438\u043d\u044b \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u043b\u0438\u0441\u044c. \u041d\u043e \u043d\u0435 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e. \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0444\u0438\u043b\u044c\u0442\u0440 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 5 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/373\/ab1\/87c\/373ab187c1e52cdbaa81b1d2bfd1ae21.png\" width=\"653\" height=\"493\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/373\/ab1\/87c\/373ab187c1e52cdbaa81b1d2bfd1ae21.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u0441 \u0434\u0435\u0444\u0435\u043a\u0442\u0430\u043c\u0438 \u0442\u0438\u043f\u0430 \u0446\u0430\u0440\u0430\u043f\u0438\u043d \u0444\u0438\u043b\u044c\u0442\u0440 \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f, \u0445\u043e\u0442\u044f \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430. \u0410 \u0441 \u0433\u0430\u0443\u0441\u0441\u043e\u0432\u0441\u0438\u043a\u043c \u0448\u0443\u043c\u043e\u043c?<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c:<\/p>\n<p>\u0418\u0441\u0445\u043e\u0434\u043d\u0430\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a92\/ab2\/205\/a92ab22055991fbdbacb2a875e13f8c3.png\" width=\"631\" height=\"396\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a92\/ab2\/205\/a92ab22055991fbdbacb2a875e13f8c3.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u0430\u044f \u043c\u0435\u0434\u0438\u0430\u043d\u043d\u044b\u043c \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u043c 5:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d09\/7e2\/d18\/d097e2d18e8a0df8ff00fffcd5f3ced5.png\" width=\"693\" height=\"522\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d09\/7e2\/d18\/d097e2d18e8a0df8ff00fffcd5f3ced5.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u0441 \u0433\u0430\u0443\u0441\u0441\u043e\u0432\u0441\u043a\u0438\u043c \u0448\u0443\u043c\u043e\u043c \u043c\u0435\u0434\u0438\u0430\u043d\u043d\u044b\u0439 \u0444\u0438\u043b\u044c\u0442\u0440 \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043b\u043e\u0445\u043e. <\/p>\n<p>\u0424\u0438\u043b\u044c\u0442\u0440 \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043b\u043e\u0436\u0438\u0442\u044c \u0438 \u0432\u0438\u0434\u0435 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0441\u0432\u0435\u0440\u0442\u043a\u0438 \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u0435\u0439. \u0413\u0430\u0443\u0441\u0441\u043e\u0432\u0441\u043a\u0438\u0439 \u0444\u0438\u043b\u044c\u0442\u0440, \u043a\u0441\u0442\u0430\u0442\u0438, \u0447\u0430\u0441\u0442\u043d\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u0442\u0430\u043a\u043e\u0433\u043e \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0433\u043e \u0444\u0438\u043b\u044c\u0442\u0440\u0430. \u041a\u0430\u043a \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044f? \u041c\u044b \u0431\u0435\u0440\u0435\u043c \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0435 \u043e\u043a\u043d\u043e, \u043f\u043e\u043f\u0438\u043a\u0441\u0435\u043b\u044c\u043d\u043e \u0443\u043c\u043d\u043e\u0436\u0430\u0435\u043c \u044f\u0440\u043a\u043e\u0441\u0442\u044c \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043e\u043a\u043d\u0430 \u043d\u0430 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u0432 \u043c\u0430\u0442\u0440\u0438\u0446\u0435, \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u043c \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432 \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443 \u043e\u043a\u043d\u0430. \u041f\u043e\u0442\u043e\u043c \u043e\u043a\u043d\u043e \u0441\u0434\u0432\u0438\u0433\u0430\u0435\u043c \u043d\u0430 \u043e\u0434\u0438\u043d \u043f\u0438\u043a\u0441\u0435\u043b\u044c \u0438 \u0434\u0435\u043b\u0430\u0435\u043c \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435. \u0418 \u0442\u0430\u043a \u043f\u043e\u043a\u0430 \u043d\u0435 \u043f\u0440\u043e\u0439\u0434\u0435\u043c \u043f\u043e \u0432\u0441\u0435\u043c\u0443 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044e. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0444\u0438\u043b\u044c\u0442\u0440\u0430:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6ba\/fa8\/c9b\/6bafa8c9b4b50fd601c9f1c38f06270f.png\" width=\"85\" height=\"64\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6ba\/fa8\/c9b\/6bafa8c9b4b50fd601c9f1c38f06270f.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041c\u043e\u0436\u043d\u043e \u043f\u043e\u0432\u044b\u0441\u0438\u0442\u044c \u0440\u0435\u0437\u043a\u043e\u0441\u0442\u044c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"python\">import cv2 import numpy as np my_photo = cv2.imread('MyPhoto.jpg') kernel = np.array([[-1,-1,-1], [-1,9,-1], [-1,-1,-1]]) im = cv2.filter2D(my_photo, -1, kernel) cv2.imshow('MyPhoto', im ) cv2.waitKey(0) cv2.destroyAllWindows()<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u043a\u0430\u043a \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d5b\/2b3\/6c2\/d5b2b36c207814047de65577cc6983f9.png\" width=\"656\" height=\"494\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d5b\/2b3\/6c2\/d5b2b36c207814047de65577cc6983f9.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0421\u0440\u0435\u0434\u0438 \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432 \u0435\u0441\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u044b\u0435 \u0444\u0438\u043b\u044c\u0442\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0434\u0433\u043e\u0442\u0430\u0432\u043b\u0438\u0432\u0430\u044e\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u044d\u0442\u0430\u043f\u0443 \u2013 \u043f\u043e\u0438\u0441\u043a\u0443 \u0444\u0438\u0447\u044c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0444\u0438\u043b\u044c\u0442\u0440 \u0421\u043e\u0431\u0435\u043b\u044f:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/37d\/137\/0b5\/37d1370b55b887561cef728ae35512d8.png\" width=\"72\" height=\"64\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/37d\/137\/0b5\/37d1370b55b887561cef728ae35512d8.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412\u043e\u0442 \u044d\u0444\u0444\u0435\u043a\u0442 \u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0444\u0438\u043b\u044c\u0442\u0440\u0430:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/11b\/39d\/470\/11b39d47018e078f4fd021167d056f3e.png\" width=\"567\" height=\"427\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/11b\/39d\/470\/11b39d47018e078f4fd021167d056f3e.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041c\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043b\u0438 \u0435\u0433\u043e \u043a \u0446\u0432\u0435\u0442\u043d\u043e\u043c\u0443 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044e, \u043d\u043e \u043e\u0431\u044b\u0447\u043d\u043e \u0442\u0430\u043a\u0438\u0435 \u0444\u0438\u043b\u044c\u0442\u0440\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442 \u043a \u0447\u0435\u0440\u043d\u043e \u0431\u0435\u043b\u043e\u043c\u0443 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044e:<\/p>\n<pre><code class=\"python\">import cv2 import numpy as np my_photo = cv2.imread('MyPhoto.jpg',cv2.IMREAD_GRAYSCALE) kernel = np.array([[-1,0,1], [-2,0,2], [-1,0,1]]) im = cv2.filter2D(my_photo, -1, kernel) cv2.imshow('MyPhoto', im ) cv2.waitKey(0) cv2.destroyAllWindows()<\/code><\/pre>\n<p>\u0418 \u0432\u043e\u0442 \u043a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/80d\/526\/a5a\/80d526a5aac332d7a0f04535b1ef64ef.png\" width=\"635\" height=\"478\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/80d\/526\/a5a\/80d526a5aac332d7a0f04535b1ef64ef.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u0444\u0438\u043b\u044c\u0442\u0440 \u0421\u043e\u0431\u0435\u043b\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0438\u0442\u044c \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u043a\u043e\u043d\u0442\u0443\u0440\u044b. \u041f\u0440\u0430\u0432\u0430, \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0438\u0442\u044c, \u0430 \u043d\u0435 \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c. \u0414\u043b\u044f \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0442\u0443\u0440\u043e\u0432 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u043c, \u0438 \u0443\u0436\u0435 \u043d\u0430 \u043d\u0435\u043c \u043d\u0430\u0439\u0442\u0438 \u043a\u043e\u043d\u0442\u0443\u0440\u044b. \u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u044d\u0442\u0438\u043c\u0438 \u043a\u043e\u043d\u0442\u0443\u0440\u0430\u043c\u0438 \u0434\u0430\u043b\u044c\u0448\u0435 \u2013 \u0443\u0436\u0435 \u0434\u0440\u0443\u0433\u043e\u0439 \u0432\u043e\u043f\u0440\u043e\u0441, \u043c\u044b \u0434\u043e \u044d\u0442\u043e\u0433\u043e \u0435\u0449\u0435 \u0434\u043e\u0431\u0435\u0440\u0435\u043c\u0441\u044f. \u0410 \u043f\u043e\u043a\u0430 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0444\u0438\u043b\u044c\u0442\u0440 \u2013 \u043b\u0430\u043f\u043b\u0430\u0441\u0438\u0430\u043d:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/9b2\/0cd\/a2d\/9b20cda2de1a2a9eaccf6288d5392da2.png\" width=\"72\" height=\"64\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9b2\/0cd\/a2d\/9b20cda2de1a2a9eaccf6288d5392da2.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412\u043e\u0442 \u044d\u0444\u0444\u0435\u043a\u0442 \u043e\u0442 \u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f (\u043a \u0447\u0435\u0440\u043d\u043e \u0431\u0435\u043b\u043e\u043c\u0443 \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\/348\/234\/b8d\/348234b8d0c551acf6180df42848ccc7.png\" width=\"634\" height=\"476\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/348\/234\/b8d\/348234b8d0c551acf6180df42848ccc7.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u0442\u0443\u0442 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u044b \u043a\u043e\u043d\u0442\u0443\u0440\u044b \u0431\u043e\u043b\u0435\u0435 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e. \u041d\u043e, \u0442\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u044d\u0442\u043e \u0435\u0449\u0435 \u043d\u0435 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0443\u0440\u043e\u0432. \u042d\u0442\u043e \u043b\u0438\u0448\u044c \u0437\u0430\u0433\u043e\u0442\u043e\u0432\u043a\u0430, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u0430\u044f \u043a\u043e\u043d\u0442\u0443\u0440\u043d\u044b\u0439 \u043f\u0440\u0435\u043f\u0430\u0440\u0430\u0442. \u0418 \u0441 \u043d\u0438\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0442\u0430\u043a \u0436\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u0442\u043e, \u0447\u0442\u043e \u0431\u044b\u043b\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0432\u044b\u0448\u0435: \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0435 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u043c, \u0438 \u0443\u0436\u0435 \u043d\u0430 \u043d\u0435\u043c \u043d\u0430\u0439\u0442\u0438 \u043a\u043e\u043d\u0442\u0443\u0440\u044b.<\/p>\n<p>\u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u0432 OpenCV \u0435\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0442\u0443\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u0435\u043b\u0430\u0435\u0442 \u0432\u0441\u0435, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u043a\u043e\u043d\u0442\u0443\u0440. \u0412\u043e\u0442 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u0442 \u043a\u043e\u043d\u0442\u0443\u0440<\/p>\n<pre><code class=\"python\">import cv2 import numpy as np  my_photo = cv2.imread('MyPhoto.jpg') img_grey = cv2.cvtColor(my_photo,cv2.COLOR_BGR2GRAY)  #\u0437\u0430\u0434\u0430\u0434\u0438\u043c \u043f\u043e\u0440\u043e\u0433 thresh = 100  #\u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443, \u043e\u0431\u0440\u0435\u0437\u0430\u043d\u043d\u0443\u044e \u043f\u043e\u0440\u043e\u0433\u043e\u043c ret,thresh_img = cv2.threshold(img_grey, thresh, 255, cv2.THRESH_BINARY)  #\u043d\u0430\u0434\u0435\u043c \u043a\u043e\u043d\u0442\u0443\u0440\u044b contours, hierarchy = cv2.findContours(thresh_img, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)  #\u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0443\u0441\u0442\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 img_contours = np.zeros(my_photo.shape)  #\u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u043c \u043a\u043e\u043d\u0442\u0443\u0440\u044b cv2.drawContours(img_contours, contours, -1, (255,255,255), 1)  cv2.imshow('contours', img_contours) # \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u043e\u043a\u043d\u043e  cv2.waitKey() cv2.destroyAllWindows()<\/code><\/pre>\n<p>\u0418 \u0432\u043e\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/bab\/f22\/46e\/babf2246ecd4d39559a38fceb30cf5fa.png\" width=\"625\" height=\"491\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/bab\/f22\/46e\/babf2246ecd4d39559a38fceb30cf5fa.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0415\u0441\u043b\u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0442\u0443\u0440\u043e\u0432 \u043d\u0435 \u0443\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0438\u0433\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u043f\u043e\u0440\u043e\u0433\u043e\u043c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u043f\u043e\u0440\u043e\u0433 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c 50, \u0442\u043e \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0432\u043e\u0442 \u0442\u0430\u043a\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/37e\/f5a\/7a7\/37ef5a7a7dc013e8af79298116df2905.png\" width=\"634\" height=\"497\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/37e\/f5a\/7a7\/37ef5a7a7dc013e8af79298116df2905.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0410 \u0432\u043e\u0442 \u0442\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043a\u043e\u043d\u0442\u0443\u0440, \u0435\u0441\u043b\u0438 \u043f\u043e\u0440\u043e\u0433 \u0441\u0434\u0435\u043b\u0430\u0442\u044c 150:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/504\/811\/d9c\/504811d9c783650ba75bf5d7ceb0a4b6.png\" width=\"634\" height=\"498\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/504\/811\/d9c\/504811d9c783650ba75bf5d7ceb0a4b6.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0414\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0434\u0440\u0443\u0433\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b1f\/090\/dac\/b1f090dace93e1a52bd1afd7303a8b13.png\" width=\"694\" height=\"521\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b1f\/090\/dac\/b1f090dace93e1a52bd1afd7303a8b13.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412\u044b\u0434\u0435\u043b\u0438\u0432 \u043a\u043e\u043d\u0442\u0443\u0440 (\u043f\u043e\u0440\u043e\u0433 180), \u043c\u044b \u043e\u0447\u0435\u043d\u044c \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e \u0443\u0432\u0438\u0434\u0438\u043c \u043b\u0438\u043d\u0438\u0438 \u043a\u0440\u044b\u0448 \u0437\u0434\u0430\u043d\u0438\u0439 <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/278\/6e8\/8be\/2786e88be00541fdfba6c6e84418f58f.png\" width=\"665\" height=\"527\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/278\/6e8\/8be\/2786e88be00541fdfba6c6e84418f58f.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u043d\u043e\u0432\u0430 \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u043f\u0440\u0435\u0434\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435. \u0412\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043a \u043c\u0435\u0434\u0438\u0430\u043d\u043d\u043e\u0439 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438, \u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u043a \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044e \u044d\u0442\u043e\u0442 \u0444\u0438\u043b\u044c\u0442\u0440, \u0430 \u0443\u0436\u0435 \u043f\u043e\u0442\u043e\u043c \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u043a\u043e\u043d\u0442\u0443\u0440:<\/p>\n<pre><code class=\"python\">import cv2 import numpy as np  my_photo = cv2.imread('DSCN1311.jpg') median_image  = cv2.medianBlur(my_photo,5) img_grey = cv2.cvtColor(median_image,cv2.COLOR_BGR2GRAY)  #set a thresh thresh = 180  #get threshold image ret,thresh_img = cv2.threshold(img_grey, thresh, 255, cv2.THRESH_BINARY)  #find contours contours, hierarchy = cv2.findContours(thresh_img, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)  #create an empty image for contours img_contours = np.zeros(my_photo.shape)  # draw the contours on the empty image cv2.drawContours(img_contours, contours, -1, (255,255,255), 1)  cv2.imshow('contours', img_contours) # \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u043e\u043a\u043d\u043e  cv2.waitKey() cv2.destroyAllWindows()<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/842\/6a4\/6ce\/8426a46cef1d776ebcfd6308a4156229.png\" width=\"575\" height=\"458\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/842\/6a4\/6ce\/8426a46cef1d776ebcfd6308a4156229.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041f\u0440\u043e\u0438\u0433\u0440\u0430\u0435\u043c\u0441\u044f \u0441 \u043f\u043e\u0440\u043e\u0433\u043e\u043c, \u044f \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043b 100, \u0438 \u0432\u043e\u0442 \u043c\u044b \u0443\u0436\u0435 \u0432\u0438\u0434\u0438\u043c \u043d\u0430 r\u043e\u043d\u0442\u0443\u0440\u0435 \u0432\u043c\u0435\u043d\u044f\u0435\u043c\u043e\u0435 \u043e\u0447\u0435\u0440\u0442\u0430\u043d\u0438\u0435 \u0437\u0434\u0430\u043d\u0438\u044f:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d6e\/a04\/fba\/d6ea04fbaf627c5979b030243e08db8d.png\" width=\"604\" height=\"479\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d6e\/a04\/fba\/d6ea04fbaf627c5979b030243e08db8d.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041b\u0430\u0434\u043d\u043e. \u0412\u043e\u0442 \u0432\u044b\u0434\u0435\u043b\u0438\u043b\u0438 \u043c\u044b \u043a\u043e\u043d\u0442\u0443\u0440. \u0427\u0442\u043e \u0434\u0430\u043b\u044c\u0448\u0435? \u0410 \u0434\u0430\u043b\u044c\u0448\u0435 \u0443\u0436\u0435 \u0438\u0434\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u044d\u0442\u0430\u043f: \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u0430\u044f \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438. \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u0441\u0430\u043c\u043e \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0443\u0440\u0430 \u2013 \u044d\u0442\u043e \u0443\u0436\u0435 \u043d\u0430\u0447\u0430\u043b\u043e \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u044d\u0442\u0430\u043f\u0430, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u043e \u043a\u043e\u043d\u0442\u0443\u0440\u0443 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442\u044c \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0433\u0440\u0430\u043d\u0438\u0446\u044b, \u0443\u0433\u043b\u044b. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u0430\u0436\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043a\u043e\u043d\u0442\u0443\u0440, \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u043a \u0442\u0440\u0435\u0442\u044c\u0435\u043c\u0443 \u044d\u0442\u0430\u043f\u0443 \u2013 \u043f\u043e\u0438\u0441\u043a \u0444\u0438\u0447. <\/p>\n<p>\u0427\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043a\u043e\u043d\u0442\u0443\u0440\u043e\u043c? \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/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<\/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\/654663\/\"> https:\/\/habr.com\/ru\/post\/654663\/<\/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>\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u043c \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u043d\u043e\u0433\u043e \u0437\u0440\u0435\u043d\u0438\u044f. \u041d\u0430\u0447\u0430\u043b\u043e <a href=\"https:\/\/habr.com\/ru\/post\/540166\/\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>. \u041d\u0430\u043f\u043e\u043c\u043d\u044e \u043a\u0440\u0430\u0442\u043a\u043e\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0443\u0440\u043e\u043a\u043e\u0432. \u041c\u044b \u0438\u0437\u0443\u0447\u0438\u043b\u0438 \u044d\u0442\u0430\u043f\u044b \u0430\u043d\u0430\u043b\u0438\u0437 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 OpenCV, \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043d\u0430\u0434 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u0447\u0435\u0440\u043d\u043e-\u0431\u0435\u043b\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442, \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u0432, \u043d\u0430\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u043d\u0438\u0435 \u0444\u0438\u043b\u044c\u0442\u0440\u0430 \u0440\u0430\u0437\u043c\u044b\u0442\u0438\u044f. <\/p>\n<p>\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u043c \u0442\u0435\u043c\u0443 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439. \u041d\u0430 <a href=\"https:\/\/habr.com\/ru\/post\/651989\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u043e\u0448\u043b\u043e\u043c \u0443\u0440\u043e\u043a\u0435<\/a> \u043c\u044b \u043f\u044b\u0442\u0430\u043b\u0438\u0441\u044c \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0440\u0430\u0437\u043c\u044b\u0442\u0438\u044f \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0438\u0437 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u0438\u0435 \u0434\u0435\u0444\u0435\u043a\u0442\u044b, \u043a\u0430\u043a \u0433\u0430\u0443\u0441\u0441\u043e\u0432\u0441\u043a\u0438\u0439 \u0448\u0443\u043c \u0438 \u0446\u0430\u0440\u0430\u043f\u0438\u043d\u044b. \u0421 \u043f\u0435\u0440\u0432\u044b\u043c \u0447\u0442\u043e-\u0442\u043e \u0431\u043e\u043b\u0435\u0435-\u043c\u0435\u043d\u0435\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c, \u0430 \u0432\u043e\u0442 \u0441 \u0446\u0430\u0440\u0430\u043f\u0438\u043d\u0430\u043c\u0438 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0432\u044b\u0448\u043b\u043e. \u0414\u0430, \u043a\u0441\u0442\u0430\u0442\u0438, \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0445 \u043c\u043d\u0435 \u0431\u044b\u043b \u0437\u0430\u0434\u0430\u043d \u0432\u043e\u043f\u0440\u043e\u0441: \u00ab\u041e\u0442\u043a\u0443\u0434\u0430 \u0431\u0435\u0440\u0435\u0442\u0441\u044f \u0433\u0430\u0443\u0441\u0441\u043e\u0432\u043a\u0438\u0439 \u0448\u0443\u043c?\u00bb <\/p>\n<p>\u041e\u0442\u0432\u0435\u0447\u0430\u044e: <\/p>\n<p>\u0413\u0430\u0443\u0441\u0441\u043e\u0432\u0441\u043a\u0438\u0439 \u0448\u0443\u043c \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u0442 \u043f\u043e\u043c\u0435\u0445. \u0418\u043b\u0438, \u0435\u0441\u043b\u0438 \u0443 \u043d\u0430\u0441 \u0431\u044b\u043b\u043e \u043f\u043b\u043e\u0445\u043e\u0435 \u043e\u0441\u0432\u0435\u0449\u0435\u043d\u0438\u0435, \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430\u0441\u044c \u0442\u0435\u043c\u043d\u0430\u044f, \u0438 \u043c\u044b \u043f\u043e\u043f\u044b\u0442\u0430\u043b\u0438\u0441\u044c \u043a\u0430\u043a-\u0442\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u044c. \u0428\u0443\u043c\u044b \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0442\u043e\u0436\u0435 \u0443\u0441\u0438\u043b\u044f\u0442\u0441\u044f.<\/p>\n<p>\u041b\u0430\u0434\u043d\u043e. \u0418\u0434\u0435\u043c \u0434\u0430\u043b\u044c\u0448\u0435. \u041a\u0430\u043a \u0436\u0435 \u043d\u0430\u043c \u0431\u044b\u0442\u044c \u0441 \u0446\u0430\u0440\u0430\u043f\u0438\u043d\u0430\u043c\u0438? \u0410 \u0434\u043b\u044f \u0438\u0445 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043c\u0435\u0434\u0438\u0430\u043d\u043d\u044b\u043c \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u043c:<\/p>\n<pre><code class=\"python\">import cv2 my_photo = cv2.imread('MyPhoto1.jpg') median_image  = cv2.medianBlur(my_photo,3) cv2.imshow('MyPhoto', median_image ) cv2.waitKey(0) cv2.destroyAllWindows()<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0438\u0441\u0445\u043e\u0434\u043d\u0430\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0410 \u0432\u043e\u0442 \u043c\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043b\u0438 \u043a \u043d\u0435\u0439 \u0444\u0438\u043b\u044c\u0442\u0440 3 \u043d\u0430 3:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u0446\u0430\u0440\u0430\u043f\u0438\u043d\u044b \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u043b\u0438\u0441\u044c. \u041d\u043e \u043d\u0435 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e. \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0444\u0438\u043b\u044c\u0442\u0440 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 5 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u0441 \u0434\u0435\u0444\u0435\u043a\u0442\u0430\u043c\u0438 \u0442\u0438\u043f\u0430 \u0446\u0430\u0440\u0430\u043f\u0438\u043d \u0444\u0438\u043b\u044c\u0442\u0440 \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f, \u0445\u043e\u0442\u044f \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430. \u0410 \u0441 \u0433\u0430\u0443\u0441\u0441\u043e\u0432\u0441\u0438\u043a\u043c \u0448\u0443\u043c\u043e\u043c?<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c:<\/p>\n<p>\u0418\u0441\u0445\u043e\u0434\u043d\u0430\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u0430\u044f \u043c\u0435\u0434\u0438\u0430\u043d\u043d\u044b\u043c \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u043c 5:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u0441 \u0433\u0430\u0443\u0441\u0441\u043e\u0432\u0441\u043a\u0438\u043c \u0448\u0443\u043c\u043e\u043c \u043c\u0435\u0434\u0438\u0430\u043d\u043d\u044b\u0439 \u0444\u0438\u043b\u044c\u0442\u0440 \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043b\u043e\u0445\u043e. <\/p>\n<p>\u0424\u0438\u043b\u044c\u0442\u0440 \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043b\u043e\u0436\u0438\u0442\u044c \u0438 \u0432\u0438\u0434\u0435 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0441\u0432\u0435\u0440\u0442\u043a\u0438 \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u0435\u0439. \u0413\u0430\u0443\u0441\u0441\u043e\u0432\u0441\u043a\u0438\u0439 \u0444\u0438\u043b\u044c\u0442\u0440, \u043a\u0441\u0442\u0430\u0442\u0438, \u0447\u0430\u0441\u0442\u043d\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u0442\u0430\u043a\u043e\u0433\u043e \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0433\u043e \u0444\u0438\u043b\u044c\u0442\u0440\u0430. \u041a\u0430\u043a \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044f? \u041c\u044b \u0431\u0435\u0440\u0435\u043c \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0435 \u043e\u043a\u043d\u043e, \u043f\u043e\u043f\u0438\u043a\u0441\u0435\u043b\u044c\u043d\u043e \u0443\u043c\u043d\u043e\u0436\u0430\u0435\u043c \u044f\u0440\u043a\u043e\u0441\u0442\u044c \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043e\u043a\u043d\u0430 \u043d\u0430 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u0432 \u043c\u0430\u0442\u0440\u0438\u0446\u0435, \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u043c \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432 \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443 \u043e\u043a\u043d\u0430. \u041f\u043e\u0442\u043e\u043c \u043e\u043a\u043d\u043e \u0441\u0434\u0432\u0438\u0433\u0430\u0435\u043c \u043d\u0430 \u043e\u0434\u0438\u043d \u043f\u0438\u043a\u0441\u0435\u043b\u044c \u0438 \u0434\u0435\u043b\u0430\u0435\u043c \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435. \u0418 \u0442\u0430\u043a \u043f\u043e\u043a\u0430 \u043d\u0435 \u043f\u0440\u043e\u0439\u0434\u0435\u043c \u043f\u043e \u0432\u0441\u0435\u043c\u0443 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044e. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0444\u0438\u043b\u044c\u0442\u0440\u0430:<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u041c\u043e\u0436\u043d\u043e \u043f\u043e\u0432\u044b\u0441\u0438\u0442\u044c \u0440\u0435\u0437\u043a\u043e\u0441\u0442\u044c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"python\">import cv2 import numpy as np my_photo = cv2.imread('MyPhoto.jpg') kernel = np.array([[-1,-1,-1], [-1,9,-1], [-1,-1,-1]]) im = cv2.filter2D(my_photo, -1, kernel) cv2.imshow('MyPhoto', im ) cv2.waitKey(0) cv2.destroyAllWindows()<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u043a\u0430\u043a \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0421\u0440\u0435\u0434\u0438 \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432 \u0435\u0441\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u044b\u0435 \u0444\u0438\u043b\u044c\u0442\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0434\u0433\u043e\u0442\u0430\u0432\u043b\u0438\u0432\u0430\u044e\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u044d\u0442\u0430\u043f\u0443 \u2013 \u043f\u043e\u0438\u0441\u043a\u0443 \u0444\u0438\u0447\u044c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0444\u0438\u043b\u044c\u0442\u0440 \u0421\u043e\u0431\u0435\u043b\u044f:<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u0412\u043e\u0442 \u044d\u0444\u0444\u0435\u043a\u0442 \u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0444\u0438\u043b\u044c\u0442\u0440\u0430:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041c\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043b\u0438 \u0435\u0433\u043e \u043a \u0446\u0432\u0435\u0442\u043d\u043e\u043c\u0443 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044e, \u043d\u043e \u043e\u0431\u044b\u0447\u043d\u043e \u0442\u0430\u043a\u0438\u0435 \u0444\u0438\u043b\u044c\u0442\u0440\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442 \u043a \u0447\u0435\u0440\u043d\u043e \u0431\u0435\u043b\u043e\u043c\u0443 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044e:<\/p>\n<pre><code class=\"python\">import cv2 import numpy as np my_photo = cv2.imread('MyPhoto.jpg',cv2.IMREAD_GRAYSCALE) kernel = np.array([[-1,0,1], [-2,0,2], [-1,0,1]]) im = cv2.filter2D(my_photo, -1, kernel) cv2.imshow('MyPhoto', im ) cv2.waitKey(0) cv2.destroyAllWindows()<\/code><\/pre>\n<p>\u0418 \u0432\u043e\u0442 \u043a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u0444\u0438\u043b\u044c\u0442\u0440 \u0421\u043e\u0431\u0435\u043b\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0438\u0442\u044c \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u043a\u043e\u043d\u0442\u0443\u0440\u044b. \u041f\u0440\u0430\u0432\u0430, \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0438\u0442\u044c, \u0430 \u043d\u0435 \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c. \u0414\u043b\u044f \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0442\u0443\u0440\u043e\u0432 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u043c, \u0438 \u0443\u0436\u0435 \u043d\u0430 \u043d\u0435\u043c \u043d\u0430\u0439\u0442\u0438 \u043a\u043e\u043d\u0442\u0443\u0440\u044b. \u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u044d\u0442\u0438\u043c\u0438 \u043a\u043e\u043d\u0442\u0443\u0440\u0430\u043c\u0438 \u0434\u0430\u043b\u044c\u0448\u0435 \u2013 \u0443\u0436\u0435 \u0434\u0440\u0443\u0433\u043e\u0439 \u0432\u043e\u043f\u0440\u043e\u0441, \u043c\u044b \u0434\u043e \u044d\u0442\u043e\u0433\u043e \u0435\u0449\u0435 \u0434\u043e\u0431\u0435\u0440\u0435\u043c\u0441\u044f. \u0410 \u043f\u043e\u043a\u0430 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0444\u0438\u043b\u044c\u0442\u0440 \u2013 \u043b\u0430\u043f\u043b\u0430\u0441\u0438\u0430\u043d:<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u0412\u043e\u0442 \u044d\u0444\u0444\u0435\u043a\u0442 \u043e\u0442 \u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f (\u043a \u0447\u0435\u0440\u043d\u043e \u0431\u0435\u043b\u043e\u043c\u0443 \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, \u0442\u0443\u0442 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u044b \u043a\u043e\u043d\u0442\u0443\u0440\u044b \u0431\u043e\u043b\u0435\u0435 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e. \u041d\u043e, \u0442\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u044d\u0442\u043e \u0435\u0449\u0435 \u043d\u0435 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0443\u0440\u043e\u0432. \u042d\u0442\u043e \u043b\u0438\u0448\u044c \u0437\u0430\u0433\u043e\u0442\u043e\u0432\u043a\u0430, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u0430\u044f \u043a\u043e\u043d\u0442\u0443\u0440\u043d\u044b\u0439 \u043f\u0440\u0435\u043f\u0430\u0440\u0430\u0442. \u0418 \u0441 \u043d\u0438\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0442\u0430\u043a \u0436\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u0442\u043e, \u0447\u0442\u043e \u0431\u044b\u043b\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0432\u044b\u0448\u0435: \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0435 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u043c, \u0438 \u0443\u0436\u0435 \u043d\u0430 \u043d\u0435\u043c \u043d\u0430\u0439\u0442\u0438 \u043a\u043e\u043d\u0442\u0443\u0440\u044b.<\/p>\n<p>\u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u0432 OpenCV \u0435\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0442\u0443\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u0435\u043b\u0430\u0435\u0442 \u0432\u0441\u0435, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u043a\u043e\u043d\u0442\u0443\u0440. \u0412\u043e\u0442 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u0442 \u043a\u043e\u043d\u0442\u0443\u0440<\/p>\n<pre><code class=\"python\">import cv2 import numpy as np  my_photo = cv2.imread('MyPhoto.jpg') img_grey = cv2.cvtColor(my_photo,cv2.COLOR_BGR2GRAY)  #\u0437\u0430\u0434\u0430\u0434\u0438\u043c \u043f\u043e\u0440\u043e\u0433 thresh = 100  #\u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443, \u043e\u0431\u0440\u0435\u0437\u0430\u043d\u043d\u0443\u044e \u043f\u043e\u0440\u043e\u0433\u043e\u043c ret,thresh_img = cv2.threshold(img_grey, thresh, 255, cv2.THRESH_BINARY)  #\u043d\u0430\u0434\u0435\u043c \u043a\u043e\u043d\u0442\u0443\u0440\u044b contours, hierarchy = cv2.findContours(thresh_img, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)  #\u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0443\u0441\u0442\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 img_contours = np.zeros(my_photo.shape)  #\u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u043c \u043a\u043e\u043d\u0442\u0443\u0440\u044b cv2.drawContours(img_contours, contours, -1, (255,255,255), 1)  cv2.imshow('contours', img_contours) # \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u043e\u043a\u043d\u043e  cv2.waitKey() cv2.destroyAllWindows()<\/code><\/pre>\n<p>\u0418 \u0432\u043e\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0415\u0441\u043b\u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0442\u0443\u0440\u043e\u0432 \u043d\u0435 \u0443\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0438\u0433\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u043f\u043e\u0440\u043e\u0433\u043e\u043c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u043f\u043e\u0440\u043e\u0433 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c 50, \u0442\u043e \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0432\u043e\u0442 \u0442\u0430\u043a\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0410 \u0432\u043e\u0442 \u0442\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043a\u043e\u043d\u0442\u0443\u0440, \u0435\u0441\u043b\u0438 \u043f\u043e\u0440\u043e\u0433 \u0441\u0434\u0435\u043b\u0430\u0442\u044c 150:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0414\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0434\u0440\u0443\u0433\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412\u044b\u0434\u0435\u043b\u0438\u0432 \u043a\u043e\u043d\u0442\u0443\u0440 (\u043f\u043e\u0440\u043e\u0433 180), \u043c\u044b \u043e\u0447\u0435\u043d\u044c \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e \u0443\u0432\u0438\u0434\u0438\u043c \u043b\u0438\u043d\u0438\u0438 \u043a\u0440\u044b\u0448 \u0437\u0434\u0430\u043d\u0438\u0439 <\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u043d\u043e\u0432\u0430 \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u043f\u0440\u0435\u0434\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435. \u0412\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043a \u043c\u0435\u0434\u0438\u0430\u043d\u043d\u043e\u0439 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438, \u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u043a \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044e \u044d\u0442\u043e\u0442 \u0444\u0438\u043b\u044c\u0442\u0440, \u0430 \u0443\u0436\u0435 \u043f\u043e\u0442\u043e\u043c \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u043a\u043e\u043d\u0442\u0443\u0440:<\/p>\n<pre><code class=\"python\">import cv2 import numpy as np  my_photo = cv2.imread('DSCN1311.jpg') median_image  = cv2.medianBlur(my_photo,5) img_grey = cv2.cvtColor(median_image,cv2.COLOR_BGR2GRAY)  #set a thresh thresh = 180  #get threshold image ret,thresh_img = cv2.threshold(img_grey, thresh, 255, cv2.THRESH_BINARY)  #find contours contours, hierarchy = cv2.findContours(thresh_img, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)  #create an empty image for contours img_contours = np.zeros(my_photo.shape)  # draw the contours on the empty image cv2.drawContours(img_contours, contours, -1, (255,255,255), 1)  cv2.imshow('contours', img_contours) # \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u043e\u043a\u043d\u043e  cv2.waitKey() cv2.destroyAllWindows()<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041f\u0440\u043e\u0438\u0433\u0440\u0430\u0435\u043c\u0441\u044f \u0441 \u043f\u043e\u0440\u043e\u0433\u043e\u043c, \u044f \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043b 100, \u0438 \u0432\u043e\u0442 \u043c\u044b \u0443\u0436\u0435 \u0432\u0438\u0434\u0438\u043c \u043d\u0430 r\u043e\u043d\u0442\u0443\u0440\u0435 \u0432\u043c\u0435\u043d\u044f\u0435\u043c\u043e\u0435 \u043e\u0447\u0435\u0440\u0442\u0430\u043d\u0438\u0435 \u0437\u0434\u0430\u043d\u0438\u044f:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041b\u0430\u0434\u043d\u043e. \u0412\u043e\u0442 \u0432\u044b\u0434\u0435\u043b\u0438\u043b\u0438 \u043c\u044b \u043a\u043e\u043d\u0442\u0443\u0440. \u0427\u0442\u043e \u0434\u0430\u043b\u044c\u0448\u0435? \u0410 \u0434\u0430\u043b\u044c\u0448\u0435 \u0443\u0436\u0435 \u0438\u0434\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u044d\u0442\u0430\u043f: \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u0430\u044f \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438. \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u0441\u0430\u043c\u043e \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0443\u0440\u0430 \u2013 \u044d\u0442\u043e \u0443\u0436\u0435 \u043d\u0430\u0447\u0430\u043b\u043e \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u044d\u0442\u0430\u043f\u0430, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u043e \u043a\u043e\u043d\u0442\u0443\u0440\u0443 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442\u044c \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0433\u0440\u0430\u043d\u0438\u0446\u044b, \u0443\u0433\u043b\u044b. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u0430\u0436\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043a\u043e\u043d\u0442\u0443\u0440, \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u043a \u0442\u0440\u0435\u0442\u044c\u0435\u043c\u0443 \u044d\u0442\u0430\u043f\u0443 \u2013 \u043f\u043e\u0438\u0441\u043a \u0444\u0438\u0447. <\/p>\n<p>\u0427\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043a\u043e\u043d\u0442\u0443\u0440\u043e\u043c? \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/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<\/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\/654663\/\"> https:\/\/habr.com\/ru\/post\/654663\/<\/a><br \/><\/br><\/br><\/p>\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-330399","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/330399","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=330399"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/330399\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=330399"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=330399"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=330399"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}