{"id":8728,"date":"2020-01-19T03:35:22","date_gmt":"2020-01-19T03:35:22","guid":{"rendered":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/?p=8728"},"modified":"2020-01-19T09:06:31","modified_gmt":"2020-01-19T09:06:31","slug":"%e4%bd%9c%e6%a5%ad%e3%83%a1%e3%83%a2python%e3%81%a7%e7%94%bb%e5%83%8f%e3%81%ae%e3%82%b5%e3%82%a4%e3%82%ba%e3%82%92%e5%a4%89%e6%9b%b4%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/?p=8728","title":{"rendered":"(\u4f5c\u696d\u30e1\u30e2)python\u3067\u753b\u50cf\u306e\u30b5\u30a4\u30ba\u3092\u5909\u66f4\u3059\u308b\u3053\u3068\u3068\u753b\u50cf\u3092\u53cd\u8ee2\u93e1\u6620\u3055\u305b\u308b\u3053\u3068"},"content":{"rendered":"<p>python \u3067\u753b\u50cf\u306e\u30b5\u30a4\u30ba\u3092\u5909\u66f4\u3059\u308b\u3002\u3082\u3068\u3082\u3068\u304c\u6b63\u65b9\u5f62\u306e\u30b5\u30a4\u30ba\u3067\u3082\u306a\u3044\u306e\u3067\u3001\u30a2\u30b9\u30da\u30af\u30c8\u6bd4\u304c\u5909\u308f\u308b\u306e\u3067\u3059\u304c\u3001\u591a\u5c11\u30ab\u30c3\u30c8\u3057\u306a\u304c\u3089\u30b5\u30a4\u30ba\u3092\u6b63\u65b9\u5f62\u306b\u5909\u66f4\u3057\u307e\u3059\u3002\u30b3\u30fc\u30c9\u306f\u4e0b\u8a18\u306e\u53c2\u8003\u30b5\u30a4\u30c8\u305d\u306e\u307e\u307e\u3067\u3059\u3002<\/p>\n<p>\u53c2\u8003\u30b5\u30a4\u30c8<\/p>\n<ul><a href=\"https:\/\/note.nkmk.me\/python-pillow-square-circle-thumbnail\/\">Python, Pillow\u3067\u6b63\u65b9\u5f62\u30fb\u5186\u5f62\u306e\u30b5\u30e0\u30cd\u30a4\u30eb\u753b\u50cf\u3092\u4e00\u62ec\u4f5c\u6210<\/a><\/ul>\n<p>\u3084\u308b\u3053\u3068\u306f\u3001\u307e\u305a melon \u3068 melon100 \u3068\u3044\u3046\u30d5\u30a9\u30eb\u30c0\u30fc\u304c\u3042\u3063\u3066\u3001melon \u306e\u65b9\u306b\u5143\u753b\u50cf\u304c\u3042\u308a\u3001\u305d\u306e\u4e2d\u5fc3\u90e8\u3092\u6b63\u65b9\u5f62\u306b\u5207\u308a\u51fa\u3057\u3066\u3001\u30b5\u30a4\u30ba\u3092 100 x 100 \u306e\u753b\u50cf\u306b\u5909\u63db\u3057\u3066 melon100 \u306b\u66f8\u304d\u51fa\u3057\u307e\u3059\u3002<\/p>\n<pre><code style=\"color:midnightblue; font-size:12px;white-space:pre-wrap\"># coding: utf-8\r\nimport sys, os\r\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\nfrom dataset.imgnet import load_imgnet\r\n\r\nfrom PIL import Image, ImageDraw, ImageFilter\r\nimport pickle\r\nimport glob\r\n\r\n\r\ndef crop_center(pil_img, crop_width, crop_height):\r\n    img_width, img_height = pil_img.size\r\n    return pil_img.crop(((img_width - crop_width) \/\/ 2,\r\n                         (img_height - crop_height) \/\/ 2,\r\n                         (img_width + crop_width) \/\/ 2,\r\n                         (img_height + crop_height) \/\/ 2))\r\n\r\ndef crop_max_square(pil_img):\r\n    return crop_center(pil_img, min(pil_img.size), min(pil_img.size))\r\n\r\n\r\n\r\nthumb_width = 100\r\n\r\n#\u5168\u753b\u50cf\u306e\u30d5\u30a1\u30a4\u30eb\u540d\u3092\u53d6\u5f97\r\nmelons = glob.glob('melon\/*.jpg')\r\n\r\nfor key, value in enumerate(melons):\r\n\tim = Image.open(value)\r\n\r\n\tim_thumb = crop_max_square(im).resize((thumb_width, thumb_width), Image.LANCZOS)\r\n\r\n\tim_thumb.save('melon100\/' + 'melon' + str(key) + '.jpg', quality=95)\r\n<\/code><\/pre>\n<p>\u753b\u50cf\u3092\u6c34\u5897\u3057\u3059\u308b\u305f\u3081\u306b\u53cd\u8ee2\u3057\u305f\u3082\u306e\u3084\u93e1\u6620\u3057\u305f\u3082\u306e\u3092\u4f5c\u308b\u3002<\/p>\n<pre><code style=\"color:midnightblue; font-size:12px;white-space:pre-wrap\"># coding: utf-8\r\nimport sys, os\r\nsys.path.append(os.pardir)  # \u89aa\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3059\u308b\u305f\u3081\u306e\u8a2d\u5b9a\r\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\nfrom dataset.imgnet import load_imgnet\r\nfrom PIL import Image, ImageDraw, ImageFilter\r\n\r\nim = Image.open(\".\/apple943.jpg\")\r\n\r\n#\u753b\u50cf\u3092array\u306b\u5909\u63db\r\nim_list = []\r\ntmpA = np.asarray(im).copy()\r\nim_list.append(tmpA)\r\n\r\ntmpB = np.flipud(tmpA.copy())\r\ntmpC = np.fliplr(tmpA.copy())\r\n\r\nim_list.append(tmpB)\r\nim_list.append(tmpC)\r\n\r\ntmpD = np.flipud(tmpC.copy())\r\nim_list.append(tmpD)\r\n\r\n#\u8cbc\u308a\u4ed8\u3051\r\nfor i in range(4):\r\n\tplt.imshow(im_list[i])\r\n\t#\u8868\u793a\r\n\tplt.show()\r\n\r\n\t#im_list4 = im_list4.tolist()\r\n\r\n\ttmpImage = Image.fromarray(im_list[i])\r\n\r\n\ttmpImage.save(\".\/apple943-\" + str(i) + \".jpg\", quality=95)<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>python \u3067\u753b\u50cf\u306e\u30b5\u30a4\u30ba\u3092\u5909\u66f4\u3059\u308b\u3002\u3082\u3068\u3082\u3068\u304c\u6b63\u65b9\u5f62\u306e\u30b5\u30a4\u30ba\u3067\u3082\u306a\u3044\u306e\u3067\u3001\u30a2 &#8230; <a class=\"more-link\" href=\"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/?p=8728\">Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-8728","post","type-post","status-publish","format-standard","hentry","category-column"],"_links":{"self":[{"href":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/8728","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8728"}],"version-history":[{"count":8,"href":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/8728\/revisions"}],"predecessor-version":[{"id":8736,"href":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/8728\/revisions\/8736"}],"wp:attachment":[{"href":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8728"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8728"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8728"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}