{"id":1729,"date":"2011-12-28T16:47:55","date_gmt":"2011-12-28T07:47:55","guid":{"rendered":"https:\/\/www.iss.ai\/?p=1729"},"modified":"2011-12-28T16:50:38","modified_gmt":"2011-12-28T07:50:38","slug":"retinex%e3%82%92pythonopencv%e3%81%a7%e3%81%8a%e6%89%8b%e8%bb%bd%e3%81%ab%e5%91%b3%e8%a6%8b%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"https:\/\/www.iss.ai\/?p=1729","title":{"rendered":"Retinex\u3092python+OpenCV\u3067\u304a\u624b\u8efd\u306b\u5473\u898b\u3059\u308b"},"content":{"rendered":"\t\t\t\t<p>\u8a8d\u8b58\u51e6\u7406\u306e\u524d\u51e6\u7406\u3067Single scale retinex\u3092\u30c1\u30e7\u30c3\u30c8\u304b\u3051\u3066\u307f\u305f\u3044\u306a\u3042\u3068\u3044\u3046\u3068\u304d\u306b\u304a\u624b\u8efd\u306bPython\u3067\u5b9f\u88c5\u3057\u3066\u307f\u3088\u3046\u3068\u3044\u3046\u304a\u8a71\u3067\u3059\uff0e<br \/>\n\t\t\t\t\u79c1\u304c\u4f7f\u3063\u3066\u3044\u308b\u306e\u306f Python2.7.1(Windows) + OpenCV2.3.1\u3067\u3059\uff0e<br \/>\n\t\t\t\tOpenCV2.3\u7cfb\u306b\u306a\u3063\u3066Python\u3067\u306e\u4f7f\u3044\u52dd\u624b\u304c\u66f4\u306b\u5411\u4e0a\u3057\u305f\u3068\u611f\u3058\u3066\u3044\u307e\u3059\uff0e<br \/>\n\t\t\t\t\u753b\u50cf\u3082\u884c\u5217\u3082Numpy\u306earray\u3067\u7d71\u4e00\u3055\u308c\u3066\u3044\u308b\u306e\u3067\uff0c\u3042\u308c\u3082\u3053\u308c\u3082\uff0c\u6c17\u6301\u3088\u304f\u51e6\u7406\u3067\u304d\u307e\u3059\uff0e<br \/>\n\t\t\t\t\u307e\u3059\u307e\u3059C\u3084C++\u3092\u4f7f\u3046\u306e\u304c\u5104\u52ab\u306b\u306a\u308a\u305d\u3046\u3067\u3059\uff0e<br \/>\n\t\t\t\tRetinex\u306b\u3064\u3044\u3066\u306f\uff0c\u30cd\u30c3\u30c8\u4e0a\u306b\u8a73\u3057\u3044\u8cc7\u6599\u304c\u305f\u304f\u3055\u3093\u3042\u308b\u306e\u3067\u8aac\u660e\u306f\u7701\u7565\u3055\u305b\u3066\u9802\u304d\u307e\u3059\u304c\uff0c\u6065\u305a\u304b\u3057\u306a\u304c\u3089\u79c1\u306e\u66f8\u3044\u305fPython\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u53c2\u8003\u7528\u306b\u8f09\u305b\u3066\u304a\u304d\u307e\u3059\uff0e<br \/>\n\t\t\t\t\u3053\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u51e6\u7406\u3057\u305f\u753b\u50cf\u306e\u4f8b\u306f\u6b21\u306e\u901a\u308a\u3067\u3059\uff0e<br \/>\n\t\t\t\t<div id=\"attachment_1731\" style=\"width: 490px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.iss.ai\/wp-content\/uploads\/2011\/12\/56-s-gray.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1731\" src=\"https:\/\/www.iss.ai\/wp-content\/uploads\/2011\/12\/56-s-gray.jpg\" alt=\"\u539f\u753b\u50cf\" title=\"56-s-gray\" width=\"480\" height=\"270\" class=\"size-full wp-image-1731\" srcset=\"https:\/\/www.iss.ai\/wp-content\/uploads\/2011\/12\/56-s-gray.jpg 480w, https:\/\/www.iss.ai\/wp-content\/uploads\/2011\/12\/56-s-gray-300x168.jpg 300w\" sizes=\"auto, (max-width: 480px) 100vw, 480px\" \/><\/a><p id=\"caption-attachment-1731\" class=\"wp-caption-text\">\u539f\u753b\u50cf<\/p><\/div><br \/>\n\t\t\t\t<div id=\"attachment_1732\" style=\"width: 490px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.iss.ai\/wp-content\/uploads\/2011\/12\/56-s-retinex_out.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1732\" src=\"https:\/\/www.iss.ai\/wp-content\/uploads\/2011\/12\/56-s-retinex_out.jpg\" alt=\"Retinex\u51e6\u7406\u5f8c\" title=\"56-s-retinex_out\" width=\"480\" height=\"270\" class=\"size-full wp-image-1732\" srcset=\"https:\/\/www.iss.ai\/wp-content\/uploads\/2011\/12\/56-s-retinex_out.jpg 480w, https:\/\/www.iss.ai\/wp-content\/uploads\/2011\/12\/56-s-retinex_out-300x168.jpg 300w\" sizes=\"auto, (max-width: 480px) 100vw, 480px\" \/><\/a><p id=\"caption-attachment-1732\" class=\"wp-caption-text\">Retinex\u51e6\u7406\u5f8c<\/p><\/div><br \/>\n\t\t\t\t\u5de6\u5074\u306b\u3044\u308b\u6b69\u884c\u8005\u304c\u306a\u3093\u3068\u306a\u304f\u78ba\u8a8d\u3057\u3084\u3059\u304f\u306a\u3063\u305f\u304b\u3082\u3057\u308c\u307e\u305b\u3093\uff0e\uff0e\uff0e<br \/>\n\t\t\t\t\u672c\u7269\u306fGaussian\u4f7f\u3046\u3079\u304d\u306a\u306e\u3067\u3057\u3087\u3046\u304c\uff0c\u8a8d\u8b58\u306e\u524d\u51e6\u7406\u306a\u3089Blur\u3067\u3082\u554f\u984c\u306a\u304b\u3063\u305f\u308a\u3057\u307e\u3059\u3088\u306d\uff0e<br \/>\n\t\t\t\tpython\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u30b3\u30e1\u30f3\u30c8\u30a2\u30a6\u30c8\u3092\u5916\u305b\u3070\u78ba\u8a8d\u3067\u304d\u307e\u3059\uff0e<br \/>\n\t\t\t\t\u30b9\u30d4\u30fc\u30c9\u547d\u306e\u3054\u6642\u4e16\u3067\u3059\u306e\u3067\uff0c\u51e6\u7406\u5185\u5bb9\u306f\u3044\u3064\u3082\u624b\u629c\u304d\u3068\u9aa8\u629c\u304d\u306e\u65b9\u5411\u3067\u3054\u3056\u3044\u307e\u3059\uff0e<\/p>\n\t\t\t\t<pre>\r\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n#-------------------------------------------------------------------------------\r\n# Name:        Retinex Test\r\n# Author:      Tomoya Kamata (kamatomo@japan-iss.co.jp)\r\n# Created:     26\/12\/2011\r\n# Copyright:   (c) 2011 ISS Inc.\r\n#-------------------------------------------------------------------------------\r\n#!\/usr\/bin\/env python\r\n\r\nimport cv2\r\nimport numpy as np\r\nfrom math import *\r\n\r\ndef main():\r\n    cv2.namedWindow('source')\r\n    cv2.namedWindow('result')\r\n    img = cv2.imread(&quot;source.jpg&quot;)\r\n    gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)\r\n\r\n    g1 = (gray + 1.0) \/ 256.0\r\n    g2 = (cv2.GaussianBlur(gray, (201, 201), 100) + 1.0) \/ 257.0\r\n    #g2 = (cv2.blur(gray, (51, 51)) + 1.0) \/ 256.0  #\u3053\u3063\u3061\u306e\u307b\u3046\u304c\u8efd\u3044\r\n    g3 = cv2.log(g1 \/ g2) #Retinecs\r\n\r\n    #\u6b63\u898f\u5316\u3057\u3066\u307f\u308b\r\n    g3_min, g3_max = g3.min(), g3.max()\r\n    g4 =  ((g3 - g3_min) \/ (g3_max - g3_min)) * 255.0\r\n\r\n    #uint8\u306b\u30ad\u30e3\u30b9\u30c8\r\n    result = np.zeros(g4.shape, dtype=np.uint8)\r\n    result += g4\r\n\r\n    #\u753b\u50cf\u3092\u4fdd\u5b58\u3059\u308b\u306a\u3089\u30b3\u30e1\u30f3\u30c8\u30a2\u30a6\u30c8\r\n    #cv2.imwrite(&quot;gray.jpg&quot;, gray)\r\n    #cv2.imwrite(&quot;retinex_out.jpg&quot;, result)\r\n\r\n    cv2.imshow(&quot;source&quot;, gray)\r\n    cv2.imshow(&quot;result&quot;, result)\r\n\r\n    cv2.waitKey(-1)\r\n    cv2.destroyAllWindows()\r\n\r\nif __name__ == '__main__':\r\n    main()\r\n<\/pre>\n\t\t\t\t<p>T.Kamata<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8a8d\u8b58\u51e6\u7406\u306e\u524d\u51e6\u7406\u3067Single scale retinex\u3092\u30c1\u30e7\u30c3\u30c8\u304b\u3051\u3066\u307f\u305f\u3044\u306a\u3042\u3068\u3044\u3046\u3068\u304d\u306b\u304a\u624b\u8efd\u306bPython\u3067\u5b9f\u88c5\u3057\u3066\u307f\u3088\u3046\u3068\u3044\u3046\u304a\u8a71\u3067\u3059\uff0e \u79c1\u304c\u4f7f\u3063\u3066\u3044\u308b\u306e\u306f Python2.7.1(Windows) + Op [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-1729","post","type-post","status-publish","format-standard","hentry","category-tech"],"_links":{"self":[{"href":"https:\/\/www.iss.ai\/index.php?rest_route=\/wp\/v2\/posts\/1729","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.iss.ai\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.iss.ai\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.iss.ai\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.iss.ai\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1729"}],"version-history":[{"count":9,"href":"https:\/\/www.iss.ai\/index.php?rest_route=\/wp\/v2\/posts\/1729\/revisions"}],"predecessor-version":[{"id":1805,"href":"https:\/\/www.iss.ai\/index.php?rest_route=\/wp\/v2\/posts\/1729\/revisions\/1805"}],"wp:attachment":[{"href":"https:\/\/www.iss.ai\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1729"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.iss.ai\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1729"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.iss.ai\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1729"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}