{"id":192,"date":"2017-06-06T11:11:54","date_gmt":"2017-06-06T02:11:54","guid":{"rendered":"http:\/\/tamatoyaku.com\/b\/?p=192"},"modified":"2017-06-06T11:11:54","modified_gmt":"2017-06-06T02:11:54","slug":"192","status":"publish","type":"post","link":"https:\/\/p-0.me\/b\/p\/192\/","title":{"rendered":"Processing\u3067PGM\u5f62\u5f0f\u306e\u753b\u50cf\u3092\u6271\u3044\u305f\u304b\u3063\u305f\u8a71"},"content":{"rendered":"<p>\u3059\u3063\u304d\u308a\u3068\u3057\u305f\u6271\u3044\u65b9\u306f\u3067\u304d\u306a\u304b\u3063\u305f\u3068\u3044\u3046\u8a71\uff0e<br \/>\n\u4eca\u56de\u306f\u8aad\u307f\u8fbc\u307f\u3057\u304b\u884c\u308f\u306a\u304b\u3063\u305f\u3051\u3069\uff0c\u540c\u69d8\u306a\u624b\u9806\u3067\u66f8\u304d\u8fbc\u307f\u3082\u3067\u304d\u308b\u306f\u305a(\u78ba\u8a8d\u306f\u3057\u3066\u3044\u306a\u3044)\uff0e<br \/>\n\u7d50\u8ad6\u304b\u3089\u8a00\u3046\u3068\uff0cPGM\u5f62\u5f0f\u306e\u753b\u50cf\u306fProcessing\u306eloadImage\u3067\u8aad\u307f\u8fbc\u3080\u3053\u3068\u306f\u3067\u304d\u305a\uff0cOpenCV\u3092\u4f7f\u3063\u3066\u4e00\u65e6png\u5f62\u5f0f\u306b\u3057\u3066\u304b\u3089PImage\u578b\u306e\u5909\u6570\u306b\u8aad\u307f\u8fbc\u3093\u3060\uff0e<br \/>\n\u4ee5\u4e0b\u306f\u305d\u308c\u307e\u3067\u306e\u904e\u7a0b\uff0e\u5177\u4f53\u7684\u306a\u65b9\u6cd5\u3060\u3051\u77e5\u308a\u305f\u3044\u4eba\u306f\u4e00\u756a\u6700\u5f8c\u3060\u3051\u898b\u308b\u3079\u304d\u304b\u3082\uff0e<br \/>\n<!--more--><br \/>\n&nbsp;<br \/>\n\u305d\u3082\u305d\u3082PGM\u5f62\u5f0f\u3068\u306f\u4f55\u304b\u306b\u3064\u3044\u3066\u306f\uff0c<a href=\"https:\/\/ja.wikipedia.org\/wiki\/PNM_(%E7%94%BB%E5%83%8F%E3%83%95%E3%82%A9%E3%83%BC%E3%83%9E%E3%83%83%E3%83%88)\">Wikipedia<\/a>\u3068<a href=\"http:\/\/netpbm.sourceforge.net\/doc\/pgm.html\">PGM Format Specification<\/a>\u3092\u53c2\u7167\uff0e<br \/>\n&nbsp;<br \/>\n<strong>1.Processing\u306eloadImage<\/strong><br \/>\n\u6700\u521d\u306bProcessing\u6a19\u6e96\u306eloadImage\u3067\u8aad\u307f\u8fbc\u3081\u306a\u3044\u304b\u8abf\u3079\u3066\u307f\u308b\uff0e<a href=\"https:\/\/processing.org\/reference\/loadImage_.html\">\u516c\u5f0f\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9<\/a>\u306b\u3088\u308b\u3068\uff0c\u8aad\u307f\u8fbc\u3081\u308b\u306e\u306f4\u7a2e\u985e\u3067.gif,.jpg,.tga,.png\u306e\u307f\u3060\u3068\u3044\u3046\u3053\u3068\u304c\u308f\u304b\u3063\u305f\uff0e<br \/>\n&nbsp;<br \/>\n<strong>2.OpneCV for Processing<\/strong><br \/>\n<a href=\"https:\/\/processing.org\/reference\/libraries\/\">Processing\u306e\u30e9\u30a4\u30d6\u30e9\u30ea<\/a>\u306bOpenCV for Processing\u3068\u3044\u3046\u3082\u306e\u304c\u3042\u308b\uff0e<br \/>\n\u3053\u308c\u306fProcessing\u306e\u30b9\u30b1\u30c3\u30c1\u30d6\u30c3\u30af\u304b\u3089[\u30b9\u30b1\u30c3\u30c1]-&gt;[\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u30a4\u30f3\u30dd\u30fc\u30c8&#8230;]-&gt;[\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u8ffd\u52a0]\u304b\u3089\u7c21\u5358\u306b\u5165\u308c\u308b\u3053\u3068\u304c\u3067\u304d\u308b\uff0e<br \/>\n\u3057\u304b\u3057\uff0c\u8a66\u3057\u3066\u307f\u308b\u3068\u3053\u308c\u3082PGM\u5f62\u5f0f\u3092\u8aad\u307f\u8fbc\u3081\u306a\u3044\u3053\u3068\u304c\u308f\u304b\u3063\u305f\uff0e<br \/>\n<a href=\"https:\/\/github.com\/atduskgreg\/opencv-processing\">Github<\/a>\u306b\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u304c\u3042\u308b\u306e\u3067\u8997\u3044\u3066\u307f\u308b\u3068\uff0cOpenCV\u30af\u30e9\u30b9\u306eloadImage\u30e1\u30bd\u30c3\u30c9\u306fPApplet\u30af\u30e9\u30b9\u306eloadImage\u3092\u547c\u3073\u51fa\u3057\u3066\u3044\u308b\u3060\u3051\u3060\u3068\u5206\u304b\u3063\u305f\uff0e\u3064\u307e\u308a\u6a19\u6e96\u306eloadImage\u3068\u52d5\u4f5c\u306f\u540c\u3058\uff0e<br \/>\n\u53c2\u8003\uff1a<a href=\"https:\/\/github.com\/atduskgreg\/opencv-processing\/blob\/master\/src\/gab\/opencv\/OpenCV.java\">OpenCV.java<\/a>\u306e1191\u884c\u76ee\u3042\u305f\u308a<br \/>\n&nbsp;<br \/>\n<strong>3.Atelier Hyperm\u00e9dia\u306eProcessing \uff0cJava \u7528OpenCV\u30e9\u30a4\u30d6\u30e9\u30ea<\/strong><br \/>\n\u306a\u306b\u304b\u4ed6\u306b\u65b9\u6cd5\u306f\u306a\u3044\u304b\u3068\u63a2\u3057\u3066\u3044\u308b\u3068\uff0c<a href=\"http:\/\/ubaa.net\/shared\/processing\/opencv\/\">\u3042\u308b\u30b5\u30a4\u30c8<\/a>\u304c\u898b\u3064\u304b\u3063\u305f\uff0e<br \/>\nProcessing\u3068Java\u7528\u306eOpenCV\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u63d0\u4f9b\u3057\u3066\u3044\u308b\u3089\u3057\u3044\uff0e<br \/>\n<a href=\"http:\/\/ubaa.net\/shared\/processing\/opencv\/opencv_loadimage.html\">loadImage\u30e1\u30bd\u30c3\u30c9\u306e\u8aac\u660e<\/a>\u3092\u8aad\u3080\u3068\uff0c\u5bfe\u5fdc\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u308b\u3053\u3068\u304c\u5206\u304b\u3063\u305f\uff0e<\/p>\n<ul>\n<li><em>Windows bitmaps &#8211; BMP, DIB<\/em><\/li>\n<li><em>JPEG files &#8211; JPEG, JPG, JPE<\/em><\/li>\n<li><em>Portable Network Graphics &#8211; PNG<\/em><\/li>\n<li><em>Portable image format &#8211; PBM, <span style=\"color: #ff0000;\">PGM<\/span>, PPM<\/em><\/li>\n<li><em>Sun rasters &#8211; SR, RAS<\/em><\/li>\n<li><em>TIFF files &#8211; TIFF, TIF<\/em><\/li>\n<\/ul>\n<p><span style=\"color: #000000;\">\u4eca\u5ea6\u306floadImage\u3067PGM\u5f62\u5f0f\u304c\u8aad\u307f\u8fbc\u3081\u305d\u3046\u3067\u3042\u308b\u3053\u3068\u304c\u5206\u304b\u3063\u305f\uff0e<\/span><br \/>\n\u201ddownload the <a href=\"http:\/\/sourceforge.net\/project\/showfiles.php?group_id=22870&amp;package_id=16937\">OpenCV release version 1.0<\/a>\u201d\u306b\u4e0d\u5b89\u3092\u899a\u3048\u306a\u304c\u3089(\u4eca\u306e\u6700\u65b0\u7248\u306f3.2.0)\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3068\uff0c\u4e88\u60f3\u901a\u308a\u30a8\u30e9\u30fc\u304c\u8d77\u304d\u305f\uff0e\u4ee5\u4e0b\u304c\u305d\u306e\u6642\u306e\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8<br \/>\n<em>A library relies on native code that&#8217;s not available.<\/em><br \/>\n<em>Or only works properly when the sketch is run as a <span style=\"color: #ff0000;\">32-bit<\/span> application.<\/em><br \/>\n\u3093\uff1f32bit\u4f7f\u3048\u3063\u3066\uff1f\u3058\u3083\u3042\u9762\u5012\u3060\u3051\u306932bit\u7248\u306eProcessing\u5165\u308c\u308b\u304b&#8230;<br \/>\n\u3067\uff0c32bit\u7248\u3067\u8868\u793a\u3055\u308c\u305f\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u3053\u3061\u3089<br \/>\n<em>A library relies on native code that&#8217;s not available.<\/em><br \/>\n<em>Or only works properly when the sketch is run as a <span style=\"color: #ff0000;\">64-bit<\/span> application.<\/em><br \/>\n\u305d\u3082\u305d\u3082OpenCV1.0\u3092\u5165\u308c\u3055\u305b\u308b\u6642\u70b9\u304b\u3089\u5acc\u306a\u4e88\u611f\u306f\u3057\u3066\u3044\u305f\uff0eOpenCV\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u5909\u3048\u305f\u308a\u8272\u3005\u8a66\u3057\u305f\u3051\u3069\uff0c\u3053\u308c\u4ee5\u4e0a\u306f\u3069\u3046\u3059\u308c\u3070\u826f\u3044\u306e\u304b\u308f\u304b\u3089\u306a\u304f\u306a\u3063\u305f\u305f\u3081\uff0c\u3053\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u306f\u8ae6\u3081\u305f\uff0e<br \/>\n&nbsp;<br \/>\n<strong>4.\u516c\u5f0f\u306eOpenCV<\/strong><br \/>\n\u524d\u8ff0\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u6700\u65b0\u7248\u306eOpenCV3.2.0\u3092\u5165\u308c\u305f\u3068\u304d\uff0cJava\u7528\u306bopencv-320.jar\u3068opencv_java.dll\u304c\u7528\u610f\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u306b\u6c17\u4ed8\u3044\u305f\uff0eJava\u7528\u306b\u7528\u610f\u3055\u308c\u3066\u3044\u308b\u306e\u306a\u3089Processing\u304b\u3089\u8aad\u307f\u8fbc\u3081\u308b\u306f\u305a\u3068\u601d\u3044\uff0c\u8a66\u3057\u3066\u307f\u305f\uff0e<br \/>\n\u6700\u521d\u306b\u30b9\u30b1\u30c3\u30c1(.pde)\u304c\u3042\u308b\u3068\u3053\u308d\u306bcode\u3068\u3044\u3046\u30d5\u30a9\u30eb\u30c0\u3092\u4f5c\u6210\u3057\uff0c\u305d\u3053\u306bopencv-320.jar\u3068opencv_java320.dll\u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u3092\u7f6e\u304f\uff0eopencv-320.jar\u3068opencv_java320.dll\u306fopencv\/build\/java\u306b\u5165\u3063\u3066\u3044\u308b\uff0e\u30d1\u30b9\u3092\u5408\u308f\u305b\u306a\u3044\u3068\u30a8\u30e9\u30fc\u304c\u51fa\u308b\u3057\uff0c\u6700\u65b0\u7248\u306a\u3089\u30d0\u30fc\u30b8\u30e7\u30f3\u540d\u304c\u5909\u308f\u308b\u306e\u3067\uff0c\u4f7f\u3046\u4eba\u306f\u9069\u5b9c\u305d\u306e\u3042\u305f\u308a\u3092\u4fee\u6b63\u3057\u3066\u4f7f\u7528\u3057\u3066\u307b\u3057\u3044\uff0e<br \/>\n&nbsp;<br \/>\n\u4ee5\u4e0b\u306f\u4f7f\u3044\u65b9\uff0e\u30b9\u30b1\u30c3\u30c1\u306e\u5148\u982d\u306b\u306fimport\u6587\u3092\u66f8\u304f\u5fc5\u8981\u304c\u3042\u308b\uff0e<\/p>\n<pre class=\"lang:java decode:true \">import org.opencv.core.*;<\/pre>\n<p>Java\u306b\u4e0a\u8a18\u306e\u30d5\u30a1\u30a4\u30eb\u306e\u30d1\u30b9\u3092\u901a\u3059\u5fc5\u8981\u304c\u3042\u308b\uff0e\u3053\u308c\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30b3\u30fc\u30c9\u3067\u8a2d\u5b9a\u3067\u304d\u308b\uff0e<\/p>\n<pre class=\"lang:java decode:true\">System.setProperty(\"java.library.path\",sketchPath()+\"\\\\code\");<\/pre>\n<p>\u3061\u306a\u307f\u306b,sketchPath\u30e1\u30bd\u30c3\u30c9\u306f.pde\u30d5\u30a1\u30a4\u30eb\u306e\u3042\u308b\u30d5\u30a9\u30eb\u30c0\u306e\u7d76\u5bfe\u30d1\u30b9\uff0e<br \/>\n\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u8aad\u307f\u8fbc\u307f\u306f<\/p>\n<pre class=\"lang:java decode:true \">System.loadLibrary(\"opencv_java320\");<\/pre>\n<p>\u3068\u3057\u3066\u884c\u3046\uff0e\u62e1\u5f35\u5b50\u306e.dll\u306f\u8981\u3089\u306a\u3044\uff0e<br \/>\n\u8aad\u307f\u8fbc\u307f\u3068\u66f8\u8fbc\u307f\u306f\u305d\u308c\u305e\u308c\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u66f8\u304f\u3053\u3068\u304c\u3067\u304d\u308b\uff0e<\/p>\n<pre class=\"lang:java decode:true \">mat=org.opencv.imgcodecs.Imgcodecs.imread(path+\"\\\\data\\\\\"+fileName);\norg.opencv.imgcodecs.Imgcodecs.imwrite(path+\"\\\\data\\\\\"+fileName.replace(\".pgm\",\".png\"),mat);<\/pre>\n<p>fileName\u306b\u306f&#8221;sample1.pgm&#8221;\u306e\u3088\u3046\u306a\u6587\u5b57\u5217\uff0cpath\u306b\u306fsketchPath()\u306e\u7d50\u679c\u304c\u5165\u3063\u3066\u3044\u308b\u60f3\u5b9a\uff0e<br \/>\n\u3053\u308c\u306b\u3088\u308aPGM\u5f62\u5f0f\u3092PNG\u5f62\u5f0f\u306b\u5909\u63db\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\uff0e<br \/>\n&nbsp;<br \/>\n\u7d50\u679c\u3068\u3057\u3066\uff0c\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30e1\u30bd\u30c3\u30c9\u3092\u4f5c\u6210\u3057\u305f\uff0e<\/p>\n<pre class=\"lang:default decode:true\" title=\"convertPgmToPng\">void convertPgmToPng(String fileName){\n  String path=sketchPath();\n  Mat mat;\n  System.setProperty(\"java.library.path\",path+\"\\\\code\");\n  System.loadLibrary(\"opencv_java320\");\n  mat=org.opencv.imgcodecs.Imgcodecs.imread(path+\"\\\\data\\\\\"+fileName);\n  org.opencv.imgcodecs.Imgcodecs.imwrite(path+\"\\\\data\\\\\"+fileName.replace(\".pgm\",\".png\"),mat);\n}<\/pre>\n<p>\u3053\u308c\u306b\u3088\u308a\u5909\u63db\u304c\u3067\u304d\u305f\uff0e\u3042\u3068\u306f\u3053\u306e\u30e1\u30bd\u30c3\u30c9\u3092\u5b9f\u884c\u3057\u305f\u5f8c\u306bloadImage(fileName.replace(&#8220;.pgm&#8221;,&#8221;.png&#8221;))\u307f\u305f\u3044\u306b\u8aad\u307f\u8fbc\u3081\u3070\u4f7f\u3048\u308b\uff0e<br \/>\n&nbsp;<br \/>\n<span style=\"color: #fafafa;\">\u753b\u50cf\u5de5\u5b66\uff0c\u30d2\u30b9\u30c8\u30b0\u30e9\u30e0\u3092\u4f5c\u308c\u3068\u3044\u3046\u8ab2\u984c\u81ea\u4f53\u3088\u308a\uff0cPGM\u5f62\u5f0f\u306e\u6271\u3044\u306e\u65b9\u304c\u96e3\u3057\u3044\u6c17\u304c\u3057\u305f\uff0e<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3059\u3063\u304d\u308a\u3068\u3057\u305f\u6271\u3044\u65b9\u306f\u3067\u304d\u306a\u304b\u3063\u305f\u3068\u3044\u3046\u8a71\uff0e \u4eca\u56de\u306f\u8aad\u307f\u8fbc\u307f\u3057\u304b\u884c\u308f\u306a\u304b\u3063\u305f\u3051\u3069\uff0c\u540c\u69d8\u306a\u624b\u9806\u3067\u66f8\u304d\u8fbc\u307f\u3082\u3067\u304d\u308b\u306f\u305a(\u78ba\u8a8d\u306f\u3057\u3066\u3044\u306a\u3044)\uff0e \u7d50\u8ad6\u304b\u3089\u8a00\u3046\u3068\uff0cPGM\u5f62\u5f0f\u306e\u753b\u50cf\u306fProcessing\u306eloadImage\u3067\u8aad\u307f\u8fbc [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-192","post","type-post","status-publish","format-standard","hentry","category-tech"],"_links":{"self":[{"href":"https:\/\/p-0.me\/b\/wp-json\/wp\/v2\/posts\/192","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/p-0.me\/b\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/p-0.me\/b\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/p-0.me\/b\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/p-0.me\/b\/wp-json\/wp\/v2\/comments?post=192"}],"version-history":[{"count":0,"href":"https:\/\/p-0.me\/b\/wp-json\/wp\/v2\/posts\/192\/revisions"}],"wp:attachment":[{"href":"https:\/\/p-0.me\/b\/wp-json\/wp\/v2\/media?parent=192"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/p-0.me\/b\/wp-json\/wp\/v2\/categories?post=192"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/p-0.me\/b\/wp-json\/wp\/v2\/tags?post=192"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}