{"id":293214,"date":"2019-08-10T21:00:15","date_gmt":"2019-08-10T21:00:15","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=293214"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=293214","title":{"rendered":"\u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0447\u0435\u0440\u043d\u043e-\u0431\u0435\u043b\u044b\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0432 ASCII-\u0433\u0440\u0430\u0444\u0438\u043a\u0443 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043d\u0435\u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043b\u043e\u0436\u0435\u043d\u0438\u044f"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\">\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/hq\/s7\/wl\/hqs7wlxixfh79akhz1b_mtsqdby.png\" width=\"500\"><\/div>\n<p>  \u0412 \u043e\u0431\u0449\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 ASCII-\u0433\u0440\u0430\u0444\u0438\u043a\u0443 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0442\u0440\u0443\u0434\u043e\u0435\u043c\u043a\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443, \u043e\u0434\u043d\u0430\u043a\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u0445\u043e\u0434, \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c\u0438 Paul D. O\u2019Grady \u0438 Scott T. Rickard \u0432 \u0440\u0430\u0431\u043e\u0442\u0435 <a href=\"https:\/\/pdfs.semanticscholar.org\/07c5\/05835924016de7a8cfd3cb6e2de1fb143388.pdf\">\u00abAutomatic ASCII Art Conversion of Binary Images Using Non-Negative Constraints\u00bb<\/a>. \u041e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0438\u043c\u0438 \u043c\u0435\u0442\u043e\u0434 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043a\u0430\u043a \u0437\u0430\u0434\u0430\u0447\u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043d\u0435\u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0435\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f:<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h2>\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430<\/h2>\n<p>  \u0418\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \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 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/8ff\/59f\/7d7\/8ff59f7d770613863cd2c0483685db98.svg\" alt=\"M\\times N\">, \u0433\u0434\u0435 <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/8da\/056\/75e\/8da05675e58b0287c1cca7e37cdc1d99.svg\" alt=\"M\"> \u0438 <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/a1e\/39d\/a1c\/a1e39da1c84981d7264baa207047222a.svg\" alt=\"N\"> \u2014 \u0448\u0438\u0440\u0438\u043d\u0430 \u0438 \u0432\u044b\u0441\u043e\u0442\u0430 \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u0430 \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445. \u0415\u0441\u043b\u0438 \u0448\u0438\u0440\u0438\u043d\u0430\\\u0432\u044b\u0441\u043e\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043d\u0435 \u043a\u0440\u0430\u0442\u043d\u0430 \u0448\u0438\u0440\u0438\u043d\u0435\\\u0432\u044b\u0441\u043e\u0442\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u0430, \u0442\u043e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u043e\u0431\u0440\u0435\u0437\u0430\u0435\u0442\u0441\u044f \u0438\u043b\u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0431\u0435\u043b\u044b\u043c\u0438 \u043e\u0431\u043b\u0430\u0441\u0442\u044f\u043c\u0438 \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/se\/qe\/pu\/seqepumqylvcdk6upn-dd9vi_4q.png\" width=\"250\"><\/div>\n<p>  \u041a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/b95\/4f4\/3ce\/b954f43ce67f65a92502a661914b76e4.svg\" alt=\"K\"> \u0431\u043b\u043e\u043a\u043e\u0432, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u043f\u043e\u0441\u043b\u0435 \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u0432\u0438\u0434\u0435 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u0434\u043b\u0438\u043d\u043e\u0439 <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/840\/ed3\/a5a\/840ed3a5a13dc397969bf6a205f84279.svg\" alt=\"R=M*N\">, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0438\u043d\u0442\u0435\u043d\u0441\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u0446\u0432\u0435\u0442\u0430 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f (\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043e\u0442 0 \u0434\u043e 255, \u0433\u0434\u0435 \u0431\u0435\u043b\u043e\u043c\u0443 \u043f\u0438\u043a\u0441\u0435\u043b\u044e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 0, \u0430 \u0447\u0435\u0440\u043d\u043e\u043c\u0443 \u2014 255). \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0432\u0435\u043a\u0442\u043e\u0440\u044b \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043d\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043d\u043e\u0440\u043c\u0443 <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/966\/980\/a89\/966980a893368f21382de225cb386c40.svg\" alt=\"l_2\">:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/b9d\/025\/739\/b9d025739593e0f7204d847a453696f6.svg\" alt=\"v_i= \\frac{v_i}{\\sqrt{\\sum^R_{k=1}{v^2_k}}}\"><\/div>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/dy\/yp\/lz\/dyyplzoz5tqb1lcykfkm-4imbm8.png\" width=\"500\"><\/div>\n<p>  \u041d\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0432\u0435\u043a\u0442\u043e\u0440\u044b \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u0432\u0438\u0434\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432, \u043e\u0431\u0440\u0430\u0437\u0443\u044f \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u0430\u0442\u0440\u0438\u0446\u0443 <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/16c\/36a\/136\/16c36a136a8b7f32e276c761a28366ad.svg\" alt=\"V\"> \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/083\/983\/d7b\/083983d7b6c59f43192e4290078b5f25.svg\" alt=\"R\\times K\">.   <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/86\/sx\/hn\/86sxhn1rqtrj8zgc4ggxdysimxa.png\" width=\"550\"><\/div>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u043c\u0430\u0442\u0440\u0438\u0446\u0443 <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/16c\/36a\/136\/16c36a136a8b7f32e276c761a28366ad.svg\" alt=\"V\"> \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432 \u0432\u0438\u0434\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043c\u0430\u0442\u0440\u0438\u0446 <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/b01\/e2a\/c4f\/b01e2ac4f751abe6f542b4e3e5d7ff46.svg\" alt=\"W\"> \u0438 <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/799\/e1a\/b6e\/799e1ab6e2aed6029f5258773ea6eba1.svg\" alt=\"H\">, \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0435\u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/47e\/bda\/50f\/47ebda50f4a5615da97271890fec3f87.svg\" alt=\"V_{R \\times K}=W_{R\\times L} H_{L \\times K}\"><\/div>\n<p>  \u041c\u0430\u0442\u0440\u0438\u0446\u0430 <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/b01\/e2a\/c4f\/b01e2ac4f751abe6f542b4e3e5d7ff46.svg\" alt=\"W\"> \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u0430 \u0437\u0430\u0440\u0430\u043d\u0435\u0435: \u043e\u043d\u0430 \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043c\u0430\u0442\u0440\u0438\u0446\u0435 <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/16c\/36a\/136\/16c36a136a8b7f32e276c761a28366ad.svg\" alt=\"V\">, \u043d\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u0443\u0447\u0430\u0441\u0442\u043a\u043e\u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u043f\u0440\u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 ASCII-\u0433\u0440\u0430\u0444\u0438\u043a\u0438. \u0415\u0441\u043b\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/899\/a67\/551\/899a675510d28419769a9b42281f0c65.svg\" alt=\"L\"> \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432, \u0442\u043e \u043c\u0430\u0442\u0440\u0438\u0446\u0430 <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/b01\/e2a\/c4f\/b01e2ac4f751abe6f542b4e3e5d7ff46.svg\" alt=\"W\"> \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440 <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/a76\/a5a\/884\/a76a5a884fe0da7d2cdfeeab7d895c8f.svg\" alt=\"R\\times L\">.<br \/>  \u041e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043b\u0438\u0448\u044c \u043f\u043e\u0434\u043e\u0431\u0440\u0430\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u0443 <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/799\/e1a\/b6e\/799e1ab6e2aed6029f5258773ea6eba1.svg\" alt=\"H\"> \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0437\u0443\u044e\u0449\u0435\u0439 \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u043c\u0435\u0436\u0434\u0443 <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/16c\/36a\/136\/16c36a136a8b7f32e276c761a28366ad.svg\" alt=\"V\"> \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/606\/4df\/837\/6064df837796bdcfd80eee8bf2cb5eba.svg\" alt=\"WH\">. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0442\u0430\u043a\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/35d\/fe5\/834\/35dfe58346bb38035eb7f9f1e5c0cc2d.svg\" alt=\"D(V,W,H,\\beta)=\\sum_{ik}\\bigg({v_{ik}\\frac{v_{ik}^{\\beta-1}-[WH]^{\\beta-1}_{ik}}{\\beta(\\beta-1)}}+[WH]^{\\beta-1}_{ik}\\frac{[WH]_{ik}-v_{ik}}{\\beta}\\bigg)\"><\/div>\n<p>  \u0414\u0430\u043d\u043d\u043e\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043f\u043e \u0441\u0443\u0442\u0438 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u0442 \u0432 \u0441\u0435\u0431\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0446\u0435\u043b\u0435\u0432\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439: \u043f\u0440\u0438 <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/215\/e6c\/c96\/215e6cc967c4f2092c353e52ef79ead5.svg\" alt=\"\\beta = 2\"> \u043e\u043d\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442 \u0435\u0432\u043a\u043b\u0438\u0434\u043e\u0432\u0430 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f (Squared Euclidean Distance), \u043f\u0440\u0438 <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/e2b\/8cc\/041\/e2b8cc04156c65f9868bf19291640ceb.svg\" alt=\"\\beta \\rightarrow 1\"> \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0430\u0435\u0442\u0441\u044f \u043a \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044e \u041a\u0443\u043b\u044c\u0431\u0430\u043a\u0430-\u041b\u0435\u0439\u0431\u043b\u0435\u0440\u0430 (Kullback-Leibler Divergence), \u0430 \u043f\u0440\u0438 <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/419\/9a1\/7fa\/4199a17fa752d575915ac78f256b3ca4.svg\" alt=\"\\beta \\rightarrow 0\"> \u2014 \u043a \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044e \u0418\u0442\u0430\u043a\u0443\u0440\u044b-\u0421\u0430\u0439\u0442\u043e (Itakura-Saito Divergence).<\/p>\n<p>  \u041d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u043e\u0434\u0431\u043e\u0440 \u043c\u0430\u0442\u0440\u0438\u0446\u044b <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/799\/e1a\/b6e\/799e1ab6e2aed6029f5258773ea6eba1.svg\" alt=\"H\"> \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c: <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/799\/e1a\/b6e\/799e1ab6e2aed6029f5258773ea6eba1.svg\" alt=\"H\"> \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u043e\u0442 0 \u0434\u043e 1, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u0442\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u043f\u0440\u0430\u0432\u0438\u043b\u0443 (\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u0437\u0430\u0434\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u0440\u0430\u043d\u0435\u0435):<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/ce2\/ab9\/9ba\/ce2ab99baf9cf808d44be37992988bd9.svg\" alt=\"h_{jk}=h_{jk}\\frac{\\sum^R_{i=1}{w_{ij}\\frac{v_{ik}}{[WH]^{2-\\beta}_{ik}}}}{\\sum^R_{i=1}{w_{ij}[WH]^{\\beta-1}_{ik}}}\"><\/div>\n<p>  \u041a\u0430\u0436\u0434\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/40e\/522\/a20\/40e522a2076658bdacea86b0879cbd0e.svg\" alt=\"h_{ij}\"> \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0441\u0445\u043e\u0436\u0435\u0441\u0442\u0438 <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/75c\/b01\/aa8\/75cb01aa8d9f97db4343ac0c5ef11b2d.svg\" alt=\"i\">-\u0433\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u0430 \u0438\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0441 <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/c73\/07a\/1bf\/c7307a1bf9d387db2abbcfc4215797c1.svg\" alt=\"j\">-\u043c \u0443\u0447\u0430\u0441\u0442\u043a\u043e\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/pb\/jn\/1m\/pbjn1mivzxwizfdv4icdcxw-fam.png\" width=\"380\"><\/div>\n<p>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u043a\u0430\u043a\u0438\u043c \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u043c \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/c73\/07a\/1bf\/c7307a1bf9d387db2abbcfc4215797c1.svg\" alt=\"j\">-\u0439 \u0443\u0447\u0430\u0441\u0442\u043e\u043a, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/c73\/07a\/1bf\/c7307a1bf9d387db2abbcfc4215797c1.svg\" alt=\"j\">-\u043c \u0441\u0442\u043e\u043b\u0431\u0446\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u044b <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/799\/e1a\/b6e\/799e1ab6e2aed6029f5258773ea6eba1.svg\" alt=\"H\">. \u041d\u043e\u043c\u0435\u0440 \u0441\u0442\u0440\u043e\u043a\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0438 \u0431\u0443\u0434\u0435\u0442 \u043d\u043e\u043c\u0435\u0440\u043e\u043c \u0438\u0441\u043a\u043e\u043c\u043e\u0433\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u0430 \u0432 \u043d\u0430\u0431\u043e\u0440\u0435. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043c\u043e\u0436\u043d\u043e \u0432\u0432\u0435\u0441\u0442\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u0440\u043e\u0433\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/dfd\/a20\/501\/dfda20501ea6a3b10420bbd24587e600.svg\" alt=\"\\epsilon\">, \u0438 \u0435\u0441\u043b\u0438 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u043e\u0435 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043c\u0435\u043d\u044c\u0448\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0440\u043e\u0433\u0430, \u0442\u043e \u0443\u0447\u0430\u0441\u0442\u043e\u043a \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0431\u0435\u043b\u043e\u043c. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0431\u0435\u043b\u0430 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0432\u0438\u0434\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0441\u0438\u043c\u0432\u043e\u043b\u0430 \u0441 \u043d\u0438\u0437\u043a\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u044c\u044e \u0441\u0445\u043e\u0436\u0435\u0441\u0442\u0438.<\/p>\n<h2>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/h2>\n<p>  \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0430 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 C#. \u0414\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 ASCII-\u0433\u0440\u0430\u0444\u0438\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f 95 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 (\u043e\u0442 0x20 \u0434\u043e 0x7E) \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 11&#215;23 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439; \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0439 \u0448\u0440\u0438\u0444\u0442 \u2014 Courier. \u041d\u0438\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 ASCII-\u0433\u0440\u0430\u0444\u0438\u043a\u0443:<\/p>\n<pre><code class=\"cs\">public static char[,] ConvertImage(     Bitmap image,      double beta,     double threshold,     ushort iterationsCount,     ushort threadsNumber,     Action&lt;int&gt; ProgressUpdated) {     int charNumHor = (int)Math.Round((double)image.Width \/ glyphWidth);     int charNumVert = (int)Math.Round((double)image.Height \/ glyphHeight);     int totalCharactersNumber = charNumVert * charNumHor;     int glyphSetSize = wNorm.ColumnCount;      Matrix&lt;double&gt; v = SplitImage(image, charNumVert, charNumHor);      Matrix&lt;double&gt; h = Matrix&lt;double&gt;.Build.Random(         glyphSetSize,          totalCharactersNumber,          new ContinuousUniform());      int progress = 0;     ushort step = (ushort)(iterationsCount \/ 10);      for (ushort i = 0; i &lt; iterationsCount; i++)     {         UpdateH(v, wNorm, h, beta, threadsNumber);          if((i + 1) % step == 0)         {             progress += 10;              if(progress &lt; 100)             {                 ProgressUpdated(progress);             }         }     }      var result = GetAsciiRepresentation(h, charNumVert, charNumHor, threshold);     ProgressUpdated(100);      return result; } <\/code><\/pre>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u0436\u0434\u044b\u0439 \u0435\u0435 \u0448\u0430\u0433 \u043f\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438:<\/p>\n<p>  1) \u0412\u044b\u0447\u0438\u0441\u043b\u0438\u043c, \u043a\u0430\u043a\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0443\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u043f\u043e \u0448\u0438\u0440\u0438\u043d\u0435 \u0438 \u043f\u043e \u0432\u044b\u0441\u043e\u0442\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"cs\">int charNumHor = (int)Math.Round((double)image.Width \/ glyphWidth); int charNumVert = (int)Math.Round((double)image.Height \/ glyphHeight); <\/code><\/pre>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u043d\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0440\u0430\u0437\u043e\u0431\u044c\u0435\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u0431\u043b\u043e\u043a\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430. \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0430 \u0437\u0430\u043f\u0438\u0448\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u043d\u0442\u0435\u043d\u0441\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u0446\u0432\u0435\u0442\u0430 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0441\u0442\u043e\u043b\u0431\u0435\u0446 \u043c\u0430\u0442\u0440\u0438\u0446\u044b <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/16c\/36a\/136\/16c36a136a8b7f32e276c761a28366ad.svg\" alt=\"V\"> (\u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0432 \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u043d\u0443\u043b\u0435\u0432\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0431\u0435\u043b\u044b\u043c \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u043c), \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0432\u0441\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u044b:<\/p>\n<pre><code class=\"cs\">private static Matrix&lt;double&gt; SplitImage(     Bitmap image,      int charNumVert,      int charNumHor) {     Matrix&lt;double&gt; result = Matrix&lt;double&gt;.Build.Dense(         glyphHeight * glyphWidth,          charNumHor * charNumVert);      for (int y = 0; y &lt; charNumVert; y++)     {         for (int x = 0; x &lt; charNumHor; x++)         {             for (int j = 0; j &lt; glyphHeight; j++)             {                 for (int i = 0; i &lt; glyphWidth; i++)                 {                     byte color = 0;                      if ((x * glyphWidth + i &lt; image.Width) &amp;&amp;                         (y * glyphHeight + j &lt; image.Height))                     {                         color = (byte)(255 - image.GetPixel(                             x * glyphWidth + i,                             y * glyphHeight + j).R);                     }                      result[glyphWidth * j + i, charNumHor * y + x] = color;                 }             }         }     }      result = result.NormalizeColumns(2.0);      return result; } <\/code><\/pre>\n<p>  2) \u0417\u0430\u043f\u043e\u043b\u043d\u0438\u043c \u043c\u0430\u0442\u0440\u0438\u0446\u0443 <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/799\/e1a\/b6e\/799e1ab6e2aed6029f5258773ea6eba1.svg\" alt=\"H\"> \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u043e\u0442 0 \u0434\u043e 1:<\/p>\n<pre><code class=\"cs\">Matrix&lt;double&gt; h = Matrix&lt;double&gt;.Build.Random(     glyphSetSize,      totalCharactersNumber,      new ContinuousUniform()); <\/code><\/pre>\n<p>  \u041f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u043a \u0435\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437:<\/p>\n<pre><code class=\"cs\">for (ushort i = 0; i &lt; iterationsCount; i++) {     UpdateH(v, wNorm, h, beta, threadsNumber);      if((i + 1) % step == 0)     {         progress += 10;          if(progress &lt; 100)         {             ProgressUpdated(progress);         }     } } <\/code><\/pre>\n<p>  \u041d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c (\u043a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u043d\u0430 \u043d\u043e\u043b\u044c, \u0440\u0435\u0448\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043a\u043e\u0441\u0442\u044b\u043b\u0435\u0439):<\/p>\n<pre><code class=\"cs\">private static void UpdateH(     Matrix&lt;double&gt; v,      Matrix&lt;double&gt; w,      Matrix&lt;double&gt; h,      double beta,     ushort threadsNumber) {     const double epsilon = 1e-6;     Matrix&lt;double&gt; vApprox = w.Multiply(h);      Parallel.For(         0,          h.RowCount,          new ParallelOptions() { MaxDegreeOfParallelism = threadsNumber },          j =&gt;         {             for (int k = 0; k &lt; h.ColumnCount; k++)             {                 double numerator = 0.0;                 double denominator = 0.0;                  for (int i = 0; i &lt; w.RowCount; i++)                 {                     if (Math.Abs(vApprox[i, k]) &gt; epsilon)                     {                         numerator +=                              w[i, j] * v[i, k] \/ Math.Pow(vApprox[i, k], 2.0 - beta);                         denominator +=                              w[i, j] * Math.Pow(vApprox[i, k], beta - 1.0);                     }                     else                     {                         numerator += w[i, j] * v[i, k];                          if (beta - 1.0 &gt; 0.0)                         {                             denominator +=                                  w[i, j] * Math.Pow(vApprox[i, k], beta - 1.0);                         }                         else                         {                             denominator += w[i, j];                         }                     }                 }                  if (Math.Abs(denominator) &gt; epsilon)                 {                     h[j, k] = h[j, k] * numerator \/ denominator;                 }                 else                 {                     h[j, k] = h[j, k] * numerator;                 }             }         }); } <\/code><\/pre>\n<p>  3) \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0448\u0430\u0433 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u0432\u044b\u0431\u043e\u0440\u0435 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0443\u0447\u0430\u0441\u0442\u043a\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u0430 \u043f\u0443\u0442\u0435\u043c \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432 \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u0445 \u043c\u0430\u0442\u0440\u0438\u0446\u044b <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/799\/e1a\/b6e\/799e1ab6e2aed6029f5258773ea6eba1.svg\" alt=\"H\">:<\/p>\n<pre><code class=\"cs\">private static char[,] GetAsciiRepresentation(     Matrix&lt;double&gt; h,      int charNumVert,      int charNumHor,      double threshold) {     char[,] result = new char[charNumVert, charNumHor];      for (int j = 0; j &lt; h.ColumnCount; j++)     {         double max = 0.0;         int maxIndex = 0;          for (int i = 0; i &lt; h.RowCount; i++)         {             if (max &lt; h[i, j])             {                 max = h[i, j];                 maxIndex = i;             }         }          result[j \/ charNumHor, j % charNumHor] =             (max &gt;= threshold) ? (char)(firstGlyphCode + maxIndex) : ' ';     }      return result; } <\/code><\/pre>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 html-\u0444\u0430\u0439\u043b. \u041f\u043e\u043b\u043d\u044b\u0439 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 <a href=\"https:\/\/github.com\/vihmp\/AsciiArtGenerator\">\u0442\u0443\u0442<\/a>.<\/p>\n<h2>\u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439<\/h2>\n<p>  \u041d\u0438\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/818\/11b\/0b2\/81811b0b26d4b7e534b439a41d4eb61f.svg\" alt=\"\\beta\"> \u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430\u0445 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439. \u0418\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0438\u043c\u0435\u043b\u043e \u0440\u0430\u0437\u043c\u0435\u0440 407&#215;500 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438\u043c\u0435\u043b\u0438 \u0440\u0430\u0437\u043c\u0435\u0440 37&#215;22 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/t-\/ah\/4s\/t-ah4s39lekdubpaxzd_jj8zhte.png\" width=\"600\"><\/div>\n<p>  <\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>  \u0412 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c\u043e\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438:<\/p>\n<ol>\n<li>\u0414\u043e\u043b\u0433\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439: \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u0435\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c \u043e\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0434\u0435\u0441\u044f\u0442\u043a\u043e\u0432 \u0441\u0435\u043a\u0443\u043d\u0434 \u0434\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0434\u0435\u0441\u044f\u0442\u043a\u043e\u0432 \u043c\u0438\u043d\u0443\u0442.<\/li>\n<li>\u041d\u0438\u0437\u043a\u043e\u0435 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u0435\u0442\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0447\u0435\u043b\u043e\u0432\u0435\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043b\u0438\u0446\u0430 \u0434\u0430\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/uh\/mx\/9c\/uhmx9cl4ccuqhzhh1sydlp6ieai.png\" width=\"600\"><\/div>\n<\/li>\n<\/ol>\n<p>  \u0412 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0434\u0435\u0442\u0430\u043b\u0435\u0439 \u0437\u0430 \u0441\u0447\u0435\u0442 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044f \u044f\u0440\u043a\u043e\u0441\u0442\u0438 \u0438 \u043a\u043e\u043d\u0442\u0440\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u0432\u0438\u0434 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/l4\/qs\/qo\/l4qsqozovwtwlkdw_ajn_wpbueq.png\" width=\"600\"><\/div>\n<p>  \u0412 \u0446\u0435\u043b\u043e\u043c \u043d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0435 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u0432\u043e\u0434 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0434\u0430\u0435\u0442 \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b.<\/div>\n<p>               <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d()}}}t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>     <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\/463193\/\"> https:\/\/habr.com\/ru\/post\/463193\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\">\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/hq\/s7\/wl\/hqs7wlxixfh79akhz1b_mtsqdby.png\" width=\"500\"><\/div>\n<p>  \u0412 \u043e\u0431\u0449\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 ASCII-\u0433\u0440\u0430\u0444\u0438\u043a\u0443 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0442\u0440\u0443\u0434\u043e\u0435\u043c\u043a\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443, \u043e\u0434\u043d\u0430\u043a\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u0445\u043e\u0434, \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c\u0438 Paul D. O\u2019Grady \u0438 Scott T. Rickard \u0432 \u0440\u0430\u0431\u043e\u0442\u0435 <a href=\"https:\/\/pdfs.semanticscholar.org\/07c5\/05835924016de7a8cfd3cb6e2de1fb143388.pdf\">\u00abAutomatic ASCII Art Conversion of Binary Images Using Non-Negative Constraints\u00bb<\/a>. \u041e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0438\u043c\u0438 \u043c\u0435\u0442\u043e\u0434 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043a\u0430\u043a \u0437\u0430\u0434\u0430\u0447\u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043d\u0435\u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043c\u0430\u0442\u0440\u0438\u0447\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0435\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f:  <\/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-293214","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/293214","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=293214"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/293214\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=293214"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=293214"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=293214"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}