{"id":3184,"date":"2013-09-01T02:22:32","date_gmt":"2013-08-31T17:22:32","guid":{"rendered":"http:\/\/njet.oops.jp\/wordpress\/?p=3184"},"modified":"2014-01-20T12:44:40","modified_gmt":"2014-01-20T03:44:40","slug":"%e3%82%ac%e3%83%b3%e3%83%9e%e8%a3%9c%e6%ad%a3%e3%81%ae%e5%bc%8f%e3%81%8c%e3%82%8f%e3%81%8b%e3%82%89%e3%81%aa%e3%81%84","status":"publish","type":"post","link":"https:\/\/njet.oops.jp\/wordpress\/2013\/09\/01\/%e3%82%ac%e3%83%b3%e3%83%9e%e8%a3%9c%e6%ad%a3%e3%81%ae%e5%bc%8f%e3%81%8c%e3%82%8f%e3%81%8b%e3%82%89%e3%81%aa%e3%81%84\/","title":{"rendered":"\u30ac\u30f3\u30de\u88dc\u6b63\u306e\u5f0f\u304c\u308f\u304b\u3089\u306a\u3044"},"content":{"rendered":"<p>OpenCV\u3092\u4f7f\u3063\u3066\uff0c\u81ea\u708a\u3057\u305f\u672c\u306e\u753b\u50cf\u306e\u5909\u63db\u306f\uff0c\u307e\u305a\u307e\u305a\u4e0a\u624b\u304f\u884c\u3063\u3066\u3044\u308b\u306e\u3060\u304c\uff0c\u30ac\u30f3\u30de\u88dc\u6b63\u306e\u3068\u3053\u308d\u3060\u3051\u304c\u5206\u304b\u3089\u306a\u3044\u3002\u3057\u304b\u305f\u306a\u3044\u306e\u3067\uff0c\u3068\u308a\u3042\u3048\u305a\u306f gamma=1 \u3064\u307e\u308a\u76f4\u7dda\u88dc\u9593\u3057\u3066\u3044\u308b\u306e\u3060\u304c\uff0c\u3069\u3053\u304c\u9593\u9055\u3063\u3066\u3044\u308b\u306e\u3060\u308d\u3046\u304b\u3002<\/p>\n<p>\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n\/\/ cv_Level<br \/>\n\/\/ \u30ec\u30d9\u30eb\u88dc\u6b63\u30fb\u30ac\u30f3\u30de\u88dc\u6b63<br \/>\n\/\/ (ImageMagick\u306e convert -level white_point black_point gamma \u3068\u540c\u3058\u306b\u3057\u305f\u3044\u306e\u3060\u304c)<br \/>\n\/\/ src    = \u5165\u529b\u753b\u50cf<br \/>\n\/\/ dst    = \u51fa\u529b\u753b\u50cf<br \/>\n\/\/ high   = \u30db\u30ef\u30a4\u30c8\u30dd\u30a4\u30f3\u30c8 (0..255)<br \/>\n\/\/ low    = \u30d6\u30e9\u30c3\u30af\u30dd\u30a4\u30f3\u30c8 (0..255)<br \/>\n\/\/ gamma  = \u30ac\u30f3\u30de\u88dc\u6b63\u5024<br \/>\n\/\/ \u6ce8\u610f\uff1a\u66ab\u5b9a\u7248\u3002\u30ac\u30f3\u30de\u88dc\u6b63\u306e\u5f0f\u306f\u3053\u308c\u3067\u6b63\u3057\u3044\u306e\u304b\u4e0d\u660e\u3002<br \/>\n\/\/ 0<x &lt;1 \u3068\u6b63\u898f\u5316\u3057\u305f\u3068\u304d\uff0cf(x)={(x-low)\/(high-low)}^{1\/gamma} \u3068\u3057\u3066\u307f\u305f\u3002\n\/\/---------------------------------------------------------------\nvoid cv_Level(IplImage* src, IplImage* dst, int high, int low, double gamma){\n \n    int i;\n    int j;\n    double x;\n    const double p = 1.0 \/ gamma ;\n    const double a = pow( (double) low , p);\n    const double b = pow( (double) high, p);\n \n    uchar LUT[256];\n \n    \/\/\u88dc\u6b63\u7528\u306e\u30eb\u30c3\u30af\u30a2\u30c3\u30d7\u30c6\u30fc\u30d6\u30eb\u306e\u4f5c\u6210\n    \/*\n    for (i = 0; i < 256; i++)\n    {\n      if (i<low)\n      {\n        LUT[i] = 0;\n      }\n      else if (i>high)<br \/>\n      {<br \/>\n        LUT[i] = 255;<br \/>\n      }<br \/>\n      else<br \/>\n      {<br \/>\n        x = (double) i \/255.0;<br \/>\n        LUT[i] = cvCeil( ((pow(x,p)-a)\/(b-a)) * 255.0 );<br \/>\n        \/\/LUT[i] = (int) ( pow( ( ((double)i &#8211; (double)low) \/ ((double)high &#8211; (double)low) ), 1.0 \/ gamma ) * 255.0 );<br \/>\n        \/\/LUT[i] = (int)(pow((double)i \/ 255.0, 1.0 \/ gamma) * 255.0);<br \/>\n      }<br \/>\n    }<br \/>\n    *\/<br \/>\n    for (i=0; i<low ; i++) { LUT[i] = 0; }\n    for (i=high; i&lt;256; i++) { LUT[i] = 255; }\n    for (i=low; i<high; i++) \n    {\n      x = pow( (double) i, p);\n      LUT[i] = cvCeil( ((x-a)\/(b-a)) * 255.0 );\n    }\n \n    \/\/CvMat\u3078\u5909\u63db\n    CvMat lut_mat = cvMat(1, 256, CV_8UC1, LUT);\n \n    \/\/\u30eb\u30c3\u30af\u30a2\u30c3\u30d7\u30c6\u30fc\u30d6\u30eb\u5909\u63db\n    cvLUT(src, dst, &#038;lut_mat);\n}\n[\/code]<\/x><\/p>\n","protected":false},"excerpt":{"rendered":"<p>OpenCV\u3092\u4f7f\u3063\u3066\uff0c\u81ea\u708a\u3057\u305f\u672c\u306e\u753b\u50cf\u306e\u5909\u63db\u306f\uff0c\u307e\u305a\u307e\u305a\u4e0a\u624b\u304f\u884c\u3063\u3066\u3044\u308b\u306e\u3060\u304c\uff0c\u30ac\u30f3\u30de\u88dc\u6b63\u306e\u3068\u3053\u308d\u3060\u3051\u304c\u5206\u304b\u3089\u306a\u3044\u3002\u3057\u304b\u305f\u306a\u3044\u306e\u3067\uff0c\u3068\u308a\u3042\u3048\u305a\u306f gamma=1 \u3064\u307e\u308a\u76f4\u7dda\u88dc\u9593\u3057\u3066\u3044\u308b\u306e\u3060\u304c\uff0c\u3069\u3053\u304c\u9593\u9055\u3063\u3066\u3044\u308b\u306e\u3060\u308d\u3046\u304b [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[55,10,47],"tags":[],"class_list":["post-3184","post","type-post","status-publish","format-standard","hentry","category-opencv","category-10","category-pdf"],"_links":{"self":[{"href":"https:\/\/njet.oops.jp\/wordpress\/wp-json\/wp\/v2\/posts\/3184","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/njet.oops.jp\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/njet.oops.jp\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/njet.oops.jp\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/njet.oops.jp\/wordpress\/wp-json\/wp\/v2\/comments?post=3184"}],"version-history":[{"count":7,"href":"https:\/\/njet.oops.jp\/wordpress\/wp-json\/wp\/v2\/posts\/3184\/revisions"}],"predecessor-version":[{"id":3271,"href":"https:\/\/njet.oops.jp\/wordpress\/wp-json\/wp\/v2\/posts\/3184\/revisions\/3271"}],"wp:attachment":[{"href":"https:\/\/njet.oops.jp\/wordpress\/wp-json\/wp\/v2\/media?parent=3184"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/njet.oops.jp\/wordpress\/wp-json\/wp\/v2\/categories?post=3184"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/njet.oops.jp\/wordpress\/wp-json\/wp\/v2\/tags?post=3184"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}