{"id":170485,"date":"2013-02-23T23:29:03","date_gmt":"2013-02-23T19:29:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=170485"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=170485","title":{"rendered":"<span class=\"post_title\">\u0420\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u0440\u0438\u0434\u043e\u0440\u043e\u0432 \u0432 \u0442\u0435\u043a\u0441\u0442\u0435<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u041a\u043e\u0440\u0438\u0434\u043e\u0440 (river) \u2014 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0431\u0435\u043b\u043e\u0432 \u043f\u043e \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u0438 \u0438\u043b\u0438 \u043d\u0430\u043a\u043b\u043e\u043d\u043d\u043e\u0439 \u043b\u0438\u043d\u0438\u0438 \u0432 \u0442\u0440\u0451\u0445 \u0438 \u0431\u043e\u043b\u0435\u0435 \u0441\u043c\u0435\u0436\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a\u0430\u0445. \u0421\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u0434\u0435\u0444\u0435\u043a\u0442\u043e\u0432 \u0432\u0451\u0440\u0441\u0442\u043a\u0438. \u0414\u0435\u0444\u0435\u043a\u0442 \u0443\u0441\u0442\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043b\u0435\u0433\u043a\u043e, \u043d\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0435\u0433\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0438.<\/p>\n<p>  \u0412\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u043a\u043e\u0440\u0438\u0434\u043e\u0440\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0442 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0431\u0435\u043b\u043e\u0432, \u043d\u043e \u0438 \u043e\u0442 \u0444\u043e\u0440\u043c\u044b \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430 \u0434\u0432\u0443\u0445 \u0442\u0435\u043a\u0441\u0442\u0430\u0445 \u043d\u0438\u0436\u0435 \u043f\u0440\u043e\u0431\u0435\u043b\u044b \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u044b \u0432 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0445 \u043c\u0435\u0441\u0442\u0430\u0445, \u043d\u043e \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u043a\u043e\u0440\u0438\u0434\u043e\u0440\u044b \u0445\u043e\u0440\u043e\u0448\u043e \u0437\u0430\u043c\u0435\u0442\u043d\u044b, \u0430 \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0434\u0435\u0444\u0435\u043a\u0442\u0430 \u043d\u0435\u0442. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0437\u0434\u0435\u0441\u044c \u043c\u0435\u0442\u043e\u0434 \u0441 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u043e\u043c \u0442\u0435\u043a\u0441\u0442\u0430 \u0432 \u0440\u0430\u0441\u0442\u0440\u043e\u0432\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/f6b\/217\/117\/f6b2171174caf763cd536c6ad59e1179.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/f0c\/bbb\/a06\/f0cbbba064209729968dad3199525de4.png\"\/><br \/>  <a name=\"habracut\"><\/a><br \/>  \u041f\u0440\u0438 <a href=\"http:\/\/dsp.stackexchange.com\/questions\/374\/river-detection-in-text\">\u043e\u0431\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0430 StackExchange<\/a> \u0431\u044b\u043b\u043e \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043e \u0434\u0432\u0430 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u044f. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043a\u043e\u043c\u0443-\u0442\u043e \u043e\u043d\u0438 \u0442\u043e\u0436\u0435 \u043e\u043a\u0430\u0436\u0443\u0442\u0441\u044f \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c\u0438.<\/p>\n<p>  1. \u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0441 \u0447\u0451\u0440\u043d\u043e-\u0431\u0435\u043b\u043e\u0439 \u043c\u0430\u0441\u043a\u043e\u0439 nPix-by-1, \u0433\u0434\u0435 nPix \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u0435\u0436\u0441\u0442\u0440\u043e\u0447\u043d\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0443, \u0442\u043e \u0435\u0441\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u043f\u0438\u043a\u0441\u0435\u043b\u043e\u0432 \u043c\u0435\u0436\u0434\u0443 \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438. <\/p>\n<pre><code>opImg = imopen(bwImg,ones(13,1));<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/6d4\/2ad\/a22\/6d42ada223afe21b5b365bb261659134.png\"\/><\/p>\n<p>  2. \u041e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043c\u0430\u0441\u043a\u043e\u0439 1-by-mPix, \u0433\u0434\u0435 mPix \u2014 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0448\u0438\u0440\u0438\u043d\u0430 \u043a\u043e\u0440\u0438\u0434\u043e\u0440\u0430. \u0422\u0430\u043a \u043c\u044b \u0438\u0437\u0431\u0430\u0432\u043b\u044f\u0435\u043c\u0441\u044f \u043e\u0442 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0442\u043e\u043d\u043a\u0438\u0445 \u043b\u0438\u043d\u0438\u0439.<\/p>\n<pre><code>opImg = imopen(opImg,ones(1,5));<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/e86\/09a\/9c0\/e8609a9c02bd4ad5c82579f0ac25ad18.png\"\/><\/p>\n<p>  3. \u0418\u0437\u0431\u0430\u0432\u043b\u044f\u0435\u043c\u0441\u044f \u043e\u0442 \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u00ab\u043a\u043e\u0440\u0438\u0434\u043e\u0440\u043e\u0432\u00bb, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0432\u044b\u0437\u0432\u0430\u043d\u044b \u0438\u043b\u0438 \u043e\u0442\u0441\u0442\u0443\u043f\u043e\u043c \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438, \u0438\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u043c \u043c\u0435\u0436\u0434\u0443 \u0430\u0431\u0437\u0430\u0446\u0430\u043c\u0438. \u0422\u0430\u043a\u0436\u0435 \u0443\u0431\u0438\u0440\u0430\u0435\u043c \u00ab\u043e\u0437\u0451\u0440\u0430\u00bb \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430, \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u043b\u043e\u0436\u0438\u0432 \u043c\u0430\u0441\u043a\u0443 \u0447\u0443\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c nPix-by-nPix. \u041d\u0430 \u044d\u0442\u043e\u043c \u0448\u0430\u0433\u0435 \u043c\u044b \u0438\u0437\u0431\u0430\u0432\u043b\u044f\u0435\u043c\u0441\u044f \u0442\u0430\u043a\u0436\u0435 \u043e\u0442 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0445 \u00ab\u0440\u0435\u0447\u0443\u0448\u0435\u043a\u00bb, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u043c\u0435\u044e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 \u043c\u0435\u043d\u044c\u0448\u0435, \u0447\u0435\u043c (nPix+2)*(mPix+2)*4, \u0442\u043e \u0435\u0441\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0440\u0438 \u0441\u0442\u0440\u043e\u043a\u0438.<\/p>\n<pre><code>%# horizontal river: just look for rows that are all true opImg(all(opImg,2),:) = false; %# open with line spacing (nPix) opImg = imopen(opImg,ones(13,1));  %# remove lakes with nPix+2 opImg = opImg & ~imopen(opImg,ones(15,15));   %# remove small fry opImg = bwareaopen(opImg,7*15*4);<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/76d\/dfe\/3d2\/76ddfe3d21587a5652983e86513456f4.png\"\/><\/p>\n<p>  4. \u0415\u0441\u043b\u0438 \u043d\u0430\u043c \u0432\u0430\u0436\u043d\u0430 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u0438\u043d\u0430, \u043d\u043e \u0438 \u0442\u043e\u043b\u0449\u0438\u043d\u0430 \u043a\u043e\u0440\u0438\u0434\u043e\u0440\u0430, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u0441\u043a\u0435\u043b\u0435\u0442 \u0438\u0437 \u0442\u043e\u0447\u0435\u043a, \u0440\u0430\u0432\u043d\u043e\u0443\u0434\u0430\u043b\u0451\u043d\u043d\u044b\u0445 \u043e\u0442 \u0433\u0440\u0430\u043d\u0438\u0446 \u043a\u043e\u0440\u0438\u0434\u043e\u0440\u0430, \u0441 \u043e\u043a\u0440\u0430\u0441\u043a\u043e\u0439 \u043a\u0430\u0436\u0434\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u0448\u0438\u0440\u0438\u043d\u043e\u0439 \u043a\u043e\u0440\u0438\u0434\u043e\u0440\u0430 \u0432 \u044d\u0442\u043e\u043c \u043c\u0435\u0441\u0442\u0435. <\/p>\n<pre><code>   dt = bwdist(~opImg);    sk = bwmorph(opImg,'skel',inf);    %# prune the skeleton a bit to remove branches    sk = bwmorph(sk,'spur',7);     riversWithWidth = dt.*sk;<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/2c7\/48d\/21e\/2c748d21e32df100928a46c30b38b467.png\"\/><\/p>\n<p>  \u0412 Mathematica \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u0440\u043e\u0437\u0438\u0438 \u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0425\u0430\u0444\u0430 \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u043e\u0447\u0435\u043a \u043a\u043e\u0434\u0430.<\/p>\n<pre><code>(*Get Your Images*) i = Import \/@ {&quot;http:\/\/i.stack.imgur.com\/4ShOW.png&quot;,                 &quot;http:\/\/i.stack.imgur.com\/5UQwb.png&quot;};  (*Erode and binarize*) i1 = Binarize \/@ (Erosion[#, 2] & \/@ i);  (*Hough transform*) lines = ImageLines[#, .5, &quot;Segmented&quot; -&gt; True] & \/@ i1;  (*Ready, show them*) Show[#[[1]],Graphics[{Thick,Orange, Line \/@ #[[2]]}]] & \/@ Transpose[{i, lines}]<\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/95c\/0c7\/964\/95c0c7964abcd9e28a2670e2387f5c76.png\"\/>    \t \t\t   \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/170485\/\"> http:\/\/habrahabr.ru\/post\/170485\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u041a\u043e\u0440\u0438\u0434\u043e\u0440 (river) \u2014 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0431\u0435\u043b\u043e\u0432 \u043f\u043e \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u0438 \u0438\u043b\u0438 \u043d\u0430\u043a\u043b\u043e\u043d\u043d\u043e\u0439 \u043b\u0438\u043d\u0438\u0438 \u0432 \u0442\u0440\u0451\u0445 \u0438 \u0431\u043e\u043b\u0435\u0435 \u0441\u043c\u0435\u0436\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a\u0430\u0445. \u0421\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u0434\u0435\u0444\u0435\u043a\u0442\u043e\u0432 \u0432\u0451\u0440\u0441\u0442\u043a\u0438. \u0414\u0435\u0444\u0435\u043a\u0442 \u0443\u0441\u0442\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043b\u0435\u0433\u043a\u043e, \u043d\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0435\u0433\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0438.<\/p>\n<p>  \u0412\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u043a\u043e\u0440\u0438\u0434\u043e\u0440\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0442 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0431\u0435\u043b\u043e\u0432, \u043d\u043e \u0438 \u043e\u0442 \u0444\u043e\u0440\u043c\u044b \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430 \u0434\u0432\u0443\u0445 \u0442\u0435\u043a\u0441\u0442\u0430\u0445 \u043d\u0438\u0436\u0435 \u043f\u0440\u043e\u0431\u0435\u043b\u044b \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u044b \u0432 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0445 \u043c\u0435\u0441\u0442\u0430\u0445, \u043d\u043e \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u043a\u043e\u0440\u0438\u0434\u043e\u0440\u044b \u0445\u043e\u0440\u043e\u0448\u043e \u0437\u0430\u043c\u0435\u0442\u043d\u044b, \u0430 \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0434\u0435\u0444\u0435\u043a\u0442\u0430 \u043d\u0435\u0442. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0437\u0434\u0435\u0441\u044c \u043c\u0435\u0442\u043e\u0434 \u0441 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u043e\u043c \u0442\u0435\u043a\u0441\u0442\u0430 \u0432 \u0440\u0430\u0441\u0442\u0440\u043e\u0432\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/f6b\/217\/117\/f6b2171174caf763cd536c6ad59e1179.png\"\/> <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/f0c\/bbb\/a06\/f0cbbba064209729968dad3199525de4.png\"\/>  <\/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-170485","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/170485","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=170485"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/170485\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=170485"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=170485"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=170485"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}