\u300cMRI\u753b\u50cf\u3092\u30b9\u30e9\u30a4\u30c0\u30fc\u3092\u4f7f\u3063\u3066\u30a6\u30a4\u30f3\u30c9\u30a6\u8abf\u6574\uff11\uff08OpenCv\u7de8\uff09\u300d<\/a>\u3092\u4e00\u5ea6\u8aad\u3093\u3067\u3044\u305f\u3060\u304f\u3068\u610f\u5473\u304c\u7406\u89e3\u3067\u304d\u308b\u3068\u601d\u3044\u307e\u3059\u3002\uff09<\/p>\n\n\n\n\u4f5c\u6210\u306e\u969b\u306b\u306f\u3001\u753b\u50cf\u306e\u7e26\u3001\u6a2a\u306e\u30d4\u30af\u30bb\u30eb\u6570\u3001\u753b\u50cf\u679a\u6570\u306e\uff13\u6b21\u5143\u306e\u914d\u5217\u3092\u4f5c\u6210\u3057\u307e\u3059\u306e\u3067\u3001\u3068\u308a\u3042\u3048\u305a\u3001\uff11\u679a\u753b\u50cf\u3092\u8aad\u307f\u8fbc\u3093\u3067\u7e26\u6a2a\u306e\u30d4\u30af\u30bb\u30eb\u6570\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002\u753b\u50cf\u306e\u679a\u6570\u306f\u5909\u6570filenames\u306e\u8981\u7d20\u6570\u3092\u53d6\u5f97\u3059\u308b\u3053\u3068\u3067\u308f\u304b\u308a\u307e\u3059\u3002<\/p>\n\n\n\n
\u305d\u308c\u3067\u306f\u4f5c\u6210\u3057\u3066\u3044\u304d\u307e\u3059\u304c\u3001\u914d\u5217\u64cd\u4f5c\u306fnumpy\u3092\u7528\u3044\u308b\u306e\u304c\u4fbf\u5229\u306a\u306e\u3067\u307e\u305a\u306fnumpy\u3092np\u3068\u3044\u3046\u540d\u524d\u3067\u4f7f\u3048\u308b\u3088\u3046\u306b\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u307e\u3057\u3087\u3046<\/p>\n\n\n\n
\uff10\u3067\u521d\u671f\u5316\u3057\u305f\u914d\u5217\u3092\u4f5c\u6210\u3059\u308b\u306e\u306f\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3067\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n
np.zeros((z, y, x),dtype ,order)<\/p>\n\n\n\n
\uff11\u500b\u306e\u76ee\u306e\u5f15\u6570\u306f\u914d\u5217\u306e\u8ef8\u306e\u8a2d\u5b9a\u3067\u3059\u3002z\u306f\u753b\u50cf\u306e\u679a\u6570\u3001y\u306f\u753b\u50cf\u306e\u7e26\u65b9\u5411\u306e\u30d4\u30af\u30bb\u30eb\u6570\u3001x\u306f\u753b\u50cf\u306e\u6a2a\u65b9\u5411\u306e\u30d4\u30af\u30bb\u30eb\u6570\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n
\uff12\u500b\u76ee\u306e\u5f15\u6570\u306f\u683c\u7d0d\u3055\u308c\u308b\u5024\u306e\u578b\u3068\u306a\u308a\u307e\u3059\u3002\u6574\u6570\u578b\u304b\u3001\u5c0f\u6570\u70b9\u4ed8\u304d\u304b\u3001\u6587\u5b57\u5217\u306a\u306e\u304b\u7b49\u306e\u8a2d\u5b9a\u3092\u3057\u307e\u3059\u3002\u4eca\u56de\u306f\u6574\u6570\u578b\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n
\uff13\u500b\u76ee\u306e\u5f15\u6570\u306f\u4ed6\u6b21\u5143\u914d\u5217\u306e\u969b\u306b\u3001\u884c\u3092\u512a\u5148\u3059\u308b\u304b\u3001\u5217\u3092\u512a\u5148\u3059\u308b\u304b\u306e\u8a2d\u5b9a\u3067\u3059\u3002\u30aa\u30d7\u30b7\u30e7\u30f3\u306e\u8a2d\u5b9a\u3068\u306a\u308a\u307e\u3059\u306e\u3067\u4eca\u56de\u306f\u6307\u5b9a\u3057\u307e\u305b\u3093\u3002<\/p>\n\n\n\n
<\/p>\n\n\n\n
\u753b\u50cf\u306e\u30d4\u30af\u30bb\u30eb\u6570\u3092\u53d6\u5f97\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n
\u307e\u305a\u306f\u3001 pydicom\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u3066\u753b\u50cf\u3092\u8aad\u307f\u8fbc\u307f\u307e\u3059\u3002<\/p>\n\n\n\n
\u8aad\u307f\u8fbc\u3093\u3060\u753b\u50cf\u306e\u6a2a\u65b9\u5411\u3092\u5909\u6570row\u3001\u7e26\u65b9\u5411\u3092\u5909\u6570columns\u3068\u3057\u3066\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n\n\n\n
\nimport fileselect\u3000as fs #\u30d5\u30a1\u30a4\u30eb\u30d1\u30b9\u53d6\u5f97\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\nimport numpy np\nimport pydicom\n\nfilenames = fs.multi_fileselect\n\ndcm = pydicom.dcmread(filenames[0])\nrow,columns = dcm.pix_array.shape[0],dcm.pix_array.shape[1]\n #\u8aad\u307f\u8fbc\u3093\u3060\u753b\u50cf\u306e\u6a2a\u65b9\u5411\u3092\u5909\u6570row\u3001\u7e26\u65b9\u5411\u3092\u5909\u6570columns\u3068\u3057\u3066\u53d6\u5f97\u3057\u307e\u3059\u3002\n\ndcm_copy = np.zeros((len(filenames), row, columns),dtype = int)\n #dcm_copy\u3068\u3044\u3046\u540d\u524d\u3067\uff10\u3067\u521d\u671f\u5316\u3057\u305f\u914d\u5217\u3092\u4f5c\u6210\n<\/code><\/pre>\n\n\n\n
<\/p>\n\n\n\n
\u4f5c\u6210\u3057\u305f\u914d\u5217\u306b\u753b\u50cf\u306e\u30d4\u30af\u30bb\u30eb\u30c7\u30fc\u30bf\u3092\u5165\u308c\u308b<\/h3>\n\n\n\n
\uff10\u3067\u521d\u671f\u5316\u3057\u305f\u914d\u5217\u306e\u4e2d\u306b\u753b\u50cf\u306e\u30d4\u30af\u30bb\u30eb\u30c7\u30fc\u30bf\u3092\u5165\u308c\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n\n\n\n
\u3053\u308c\u306f\u7e70\u308a\u8fd4\u3057\u306e\u4f5c\u696d\u3068\u306a\u308a\u307e\u3059\u306e\u3067for\u6587\u3067\u51e6\u7406\u3057\u3066\u3044\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n\n\n\n
\nimport fileselect\u3000as fs #\u30d5\u30a1\u30a4\u30eb\u30d1\u30b9\u53d6\u5f97\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\nimport numpy np\nimport pydicom\n\nfilenames = fs.multi_fileselect\n\ndcm = pydicom.dcmread(filenames[0])\nrow,columns = dcm.pix_array.shape[0],dcm.pix_array.shape[1]\n #\u8aad\u307f\u8fbc\u3093\u3060\u753b\u50cf\u306e\u6a2a\u65b9\u5411\u3092\u5909\u6570row\u3001\u7e26\u65b9\u5411\u3092\u5909\u6570columns\u3068\u3057\u3066\u53d6\u5f97\u3057\u307e\u3059\u3002\n\ndcm_copy = np.zeros((len(filenames), row, columns),dtype = int)\n #dcm_copy\u3068\u3044\u3046\u540d\u524d\u3067\uff10\u3067\u521d\u671f\u5316\u3057\u305f\u914d\u5217\u3092\u4f5c\u6210\n\nfor i in range(len(filenames)):\n dcm = pydicom.dcmread(filenames[i])\n dcm_arr = dcm.pixel_array\n dcm_copy[i] = dcm_arr.astype(np.int64) \n #np.int64\u3068\u3057\u3066\u30c7\u30fc\u30bf\u306e\u578b\u3092\u6307\u5b9a\u3057\u3066\u304a\u304d\u307e\u3059\u3002\n<\/code><\/pre>\n\n\n\n\u3053\u308c\u3067\u3001dcm_copy\u306b\u9078\u629e\u3057\u305f\u753b\u50cf\u5168\u3066\u306e\u30d4\u30af\u30bb\u30eb\u30c7\u30fc\u30bf\u304c\u5165\u308a\u307e\u3057\u305f\u3002<\/p>\n\n\n\n
<\/p>\n\n\n\n
\u30b9\u30e9\u30a4\u30c0\u30fc\u306e\u4f5c\u6210 <\/h3>\n\n\n\n
\u30b9\u30e9\u30a4\u30c0\u30fc\u3092\u4f5c\u6210\u3059\u308b\u306b\u306f\u753b\u50cf\u8868\u793a\u306e\u30a6\u30a4\u30f3\u30c9\u30a6\u540d\u304c\u5fc5\u8981\u3068\u306a\u308a\u307e\u3059\u306e\u3067\u3001\u307e\u305a\u306f\u753b\u50cf\u8868\u793a\u306e\u30a6\u30a4\u30f3\u30c9\u30a6\u306e\u8a2d\u5b9a\u3092\u3057\u307e\u3059\u3002<\/p>\n\n\n\n
cv2.namedWindow(name<\/strong>,type)<\/p>\n\n\n\n\u7b2c\u4e00\u5f15\u6570\u306ename\u306f\u30a6\u30a4\u30f3\u30c9\u30a6\u540d\u3067\u3059\u3002<\/p>\n\n\n\n
\u7b2c\u4e8c\u5f15\u6570\u306b\u306f\u8868\u793a\u5f62\u5f0f\u3092\u3057\u3066\u3044\u3057\u307e\u3059\u3002\u5f62\u5f0f\u306f\u4ee5\u4e0b\u306e\uff12\u7a2e\u985e\u3067\u3059\u3002<\/p>\n\n\n\n
cv2.WINDOW_AUTOSIZE\uff1a\u30c7\u30d5\u30a9\u30eb\u30c8\u3002\u30a6\u30a3\u30f3\u30c9\u30a6\u30b5\u30a4\u30ba\u56fa\u5b9a\u8868\u793a<\/p>\n\n\n\n
cv2.WINDOW_NORMAL\uff1a\u30a6\u30a3\u30f3\u30c9\u30a6\u306e\u30b5\u30a4\u30ba\u3092\u5909\u66f4\u53ef\u80fd\u306b\u3059\u308b<\/p>\n\n\n\n
\u4eca\u56de\u306f\u3001\u30a6\u30a4\u30f3\u30c9\u30a6\u30b5\u30a4\u30ba\u3092\u5909\u66f4\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u305f\u3044\u306e\u3067cv2.WINDOW_NORMAL \u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n
\nimport fileselect\u3000as fs #\u30d5\u30a1\u30a4\u30eb\u30d1\u30b9\u53d6\u5f97\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\nimport numpy np\nimport pydicom\n\nfilenames = fs.multi_fileselect\n\ndcm = pydicom.dcmread(filenames[0])\nrow,columns = dcm.pix_array.shape[0],dcm.pix_array.shape[1]\n #\u8aad\u307f\u8fbc\u3093\u3060\u753b\u50cf\u306e\u6a2a\u65b9\u5411\u3092\u5909\u6570row\u3001\u7e26\u65b9\u5411\u3092\u5909\u6570columns\u3068\u3057\u3066\u53d6\u5f97\u3057\u307e\u3059\u3002\n\ndcm_copy = np.zeros((len(filenames), row, columns),dtype = int)\n #dcm_copy\u3068\u3044\u3046\u540d\u524d\u3067\uff10\u3067\u521d\u671f\u5316\u3057\u305f\u914d\u5217\u3092\u4f5c\u6210\n\nfor i in range(len(filenames)):\n dcm = pydicom.dcmread(filenames[i])\n dcm_arr = dcm.pixel_array\n dcm_copy[i] = dcm_arr.astype(np.int64) \n #np.int64\u3068\u3057\u3066\u30c7\u30fc\u30bf\u306e\u578b\u3092\u6307\u5b9a\u3057\u3066\u304a\u304d\u307e\u3059\u3002\n\ncv2.namedWindow('dcm_image',cv2.WINDOW_NORMAL)\n #\u30a6\u30a4\u30f3\u30c9\u30a6\u540d\u3092'dcm_image'\u3068\u3057\u3001\u30a6\u30a4\u30f3\u30c9\u30a6\u30b5\u30a4\u30ba\u3092\u5909\u66f4\u3067\u304d\u308b\u3088\u3046\u306b\u8a2d\u5b9a\n<\/code><\/pre>\n\n\n\n\u753b\u50cf\u8868\u793a\u30a6\u30a4\u30f3\u30c9\u30a6\u306e\u8a2d\u5b9a\u304c\u7d42\u308f\u3063\u305f\u306e\u3067\u3001\u3044\u3088\u3044\u3088\u30b9\u30e9\u30a4\u30c0\u30fc\u306e\u8a2d\u5b9a\u306b\u5165\u308a\u307e\u3059\u3002\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3067\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n
cv2.createTrackbar( name , window_name , initial_value , max_value , definition ) <\/p>\n\n\n\n
\u4f5c\u6210\u3059\u308b\u30b9\u30e9\u30a4\u30c0\u30fc\u306f\uff12\u3064\u3002WW\u3068WL\u306e\uff12\u3064\u3067\u3059\u3002\u305d\u308c\u305e\u308c\u6700\u5927\u5024\u3092\u30d4\u30af\u30bb\u30eb\u30c7\u30fc\u30bf\u306e\u6700\u5927\u5024\u3068\u3057\u305f\u3044\u306e\u3067\u753b\u50cf\u306e\u30d4\u30af\u30bb\u30eb\u30c7\u30fc\u30bf\u304c\u5165\u3063\u3066\u3044\u308bdcm_copy\u306e\u4e2d\u306e\u6700\u5927\u5024\u3092\u8abf\u3079\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002\u6700\u5927\u5024\u306f\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3067\u53d6\u5f97\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n
maxvalue = dcm_copy.max().astype(np.int64)<\/p>\n\n\n\n
\u6700\u5f8c\u306e .astype(np.int64) \u306f\u53d6\u5f97\u3057\u305f\u5024\u306e\u578b\u3092\u6307\u5b9a\u3057\u3066\u304a\u304d\u307e\u3059\u3002\uff08\u5f8c\u306e\u51e6\u7406\u3067\u578b\u304c\u9055\u3046\u3068\u30a8\u30e9\u30fc\u304c\u51fa\u3066\u3057\u307e\u3046\u306e\u3067\u53d6\u5f97\u306e\u6bb5\u968e\u3067\u578b\u306e\u6307\u5b9a\u3057\u3066\u304a\u304d\u307e\u3059\u3002\uff09<\/p>\n\n\n\n
\u30b9\u30e9\u30a4\u30c0\u30fc\u306e\u521d\u671f\u5024\u306f\u3068\u308a\u3042\u3048\u305a\u3001WL\u306f\u753b\u50cf\u6700\u5927\u5024\u306e\u534a\u5206\u3001 WW\u306f\u753b\u50cf\u6700\u5927\u5024\u306e\uff14\u5206\u306e\uff11\u3068\u3057\u3066\u8a2d\u5b9a\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n
cv2.createTrackbar(“WL”, “dcm_image”, (maxvalue \/\/ 2), maxvalue, make_LUT)
cv2.createTrackbar(“WW”, “dcm_image”, (maxvalue \/\/ 4), maxvalue, make_LUT)<\/p>\n\n\n\n
\u3053\u3053\u3067\u3001 maxvalue \/\/ 2 \u3068 maxvalue \/\/ 4 \u306e\u2019\/\/\u2019\u306f\u9593\u9055\u3044\u3067\u306f\u306a\u304f\u3001\u8a08\u7b97\u7d50\u679c\u304c\u5c11\u6570\u306b\u306a\u3089\u306a\u3044\u3088\u3046\u306b\u3059\u308b\u6f14\u7b97\u5b50\u3067\u3059\u3002\u3053\u308c\u306b\u3088\u308a\u5c0f\u6570\u70b9\u4ee5\u4e0b\u306f\u5207\u308a\u6368\u3066\u3089\u308c\u307e\u3059\u3002<\/p>\n\n\n\n
\u3061\u306a\u307f\u306b\u3001\u7b2c\uff15\u756a\u76ee\u306e\u5f15\u6570\u306f\u3057\u3066\u3044\u3057\u306a\u3044\u3068\u30a8\u30e9\u30fc\u306b\u306a\u3063\u3066\u3057\u307e\u3046\u306e\u3067\u4f55\u3082\u3057\u306a\u3044”make_LUT”\u3068\u3044\u3046\u95a2\u6570\u3092\u4f5c\u6210\u3057\u3066\u304a\u304d\u307e\u3059\u3002\u4f5c\u6210\u3057\u305f\u95a2\u6570\u3067\u53d7\u3051\u308b\u5f15\u6570\u306f\u6700\u4f4e\u4e00\u3064\u306f\u306a\u3044\u3068\u3053\u308c\u3082\u30a8\u30e9\u30fc\u3068\u306a\u3063\u3066\u3057\u307e\u3046\u306e\u3067\u9069\u5f53\u306bval\u3068\u3044\u3046\u53d7\u3051\u3092\u66f8\u3044\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n\n\n\n
\nimport fileselect\u3000as fs #\u30d5\u30a1\u30a4\u30eb\u30d1\u30b9\u53d6\u5f97\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\nimport numpy np\nimport pydicom\n\nfilenames = fs.multi_fileselect\n\ndcm = pydicom.dcmread(filenames[0])\nrow,columns = dcm.pix_array.shape[0],dcm.pix_array.shape[1]\n #\u8aad\u307f\u8fbc\u3093\u3060\u753b\u50cf\u306e\u6a2a\u65b9\u5411\u3092\u5909\u6570row\u3001\u7e26\u65b9\u5411\u3092\u5909\u6570columns\u3068\u3057\u3066\u53d6\u5f97\u3057\u307e\u3059\u3002\n\ndcm_copy = np.zeros((len(filenames), row, columns),dtype = int)\n #dcm_copy\u3068\u3044\u3046\u540d\u524d\u3067\uff10\u3067\u521d\u671f\u5316\u3057\u305f\u914d\u5217\u3092\u4f5c\u6210\n\nfor i in range(len(filenames)):\n dcm = pydicom.dcmread(filenames[i])\n dcm_arr = dcm.pixel_array\n dcm_copy[i] = dcm_arr.astype(np.int64) \n #np.int64\u3068\u3057\u3066\u30c7\u30fc\u30bf\u306e\u578b\u3092\u6307\u5b9a\u3057\u3066\u304a\u304d\u307e\u3059\u3002\n\ncv2.namedWindow('dcm_image',cv2.WINDOW_NORMAL)\n #\u30a6\u30a4\u30f3\u30c9\u30a6\u540d\u3092'dcm_image'\u3068\u3057\u3001\u30a6\u30a4\u30f3\u30c9\u30a6\u30b5\u30a4\u30ba\u3092\u5909\u66f4\u3067\u304d\u308b\u3088\u3046\u306b\u8a2d\u5b9a\n\nmaxvalue = dcm_copy.max().astype(np.int64)\n\ncv2.createTrackbar(\"WL\", \"dcm_image\", (maxvalue \/\/ 2), maxvalue, make_LUT)\ncv2.createTrackbar(\"WW\", \"dcm_image\", (maxvalue \/\/ 4), maxvalue, make_LUT)\n\ndef make_LUT(val):\n pass #\u4f55\u3082\u3057\u306a\u3044<\/code><\/pre>\n\n\n\n
<\/p>\n\n\n\n
\u753b\u50cf\u8868\u793a <\/h3>\n\n\n\n
\u3044\u3088\u3044\u3088\u753b\u50cf\u8868\u793a\u3067\u3059\u3002\u753b\u50cf\u8868\u793a\u306f\u30b9\u30e9\u30a4\u30c0\u30fc\u3092\u3044\u3058\u308b\u305f\u3073\u306b\u753b\u50cf\u3092\u5909\u66f4\u3057\u306a\u304f\u3066\u306f\u3044\u3051\u306a\u3044\u306e\u3067\u30eb\u30fc\u30d7\u69cb\u6587while\u3092\u7528\u3044\u3066\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n\n\n\n
\u753b\u7d20\u5024\uff12\uff15\uff15\u3092\u8d85\u3048\u308b\u753b\u50cf\u306fopenCV\u3067\u306f\u8868\u793a\u3067\u304d\u306a\u3044\u306e\u3067\u3001\u305d\u306e\u51e6\u7406\u3092\u3084\u3063\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n\n\n\n
\u307e\u305a\u306f\u3001WL\u3088\u308aWW\uff0f\uff12\u3088\u308a\u9ad8\u3044\u30d4\u30af\u30bb\u30eb\u5024\u3092\uff12\uff15\uff15\u3001 WW\uff0f\uff12\u3088\u308a\u4f4e\u3044\u30d4\u30af\u30bb\u30eb\u3092\uff10\u3068\u3057\u305f\u5f8c\u306b\u3001\u305d\u306e\u9593\u306e\u30d4\u30af\u30bb\u30eb\u5024\u3092\uff12\uff15\uff16\u968e\u8abf\u306b\u843d\u3068\u3057\u8fbc\u3093\u3067\u3044\u304f\u4f5c\u696d\u304c\u5fc5\u8981\u306b\u306a\u308a\u307e\u3059\u3002\u305d\u306e\u4f5c\u696d\u3092\u30d4\u30af\u30bb\u30eb\u3054\u3068\u306b\u8a08\u7b97\u3057\u3066\u7b97\u51fa\u3059\u308b\u3068\u975e\u5e38\u306b\u51e6\u7406\u306b\u6642\u9593\u304c\u304b\u304b\u3063\u3066\u3057\u307e\u3046\u306e\u3067\u30eb\u30c3\u30af\u30a2\u30c3\u30d7\u30c6\u30fc\u30d6\u30eb\u3068\u3044\u3046\u7269\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u30eb\u30c3\u30af\u30a2\u30c3\u30d7\u30c6\u30fc\u30d6\u30eb\u3068\u306f\u3001\u3053\u306e\u6570\u5024\u306f\u3053\u306e\u5024\u3068\u3044\u3046\u8868\u3092\u4f5c\u6210\u3057\u3001\u305d\u308c\u3092\u30d4\u30af\u30bb\u30eb\u3054\u3068\u306b\u53c2\u7167\u3059\u308b\u3053\u3068\u3067\u8a08\u7b97\u51e6\u7406\u3092\u7701\u304f\u51e6\u7406\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n
\u30eb\u30c3\u30af\u30a2\u30c3\u30d7\u30c6\u30fc\u30d6\u30eb\u3092\uff10\u3067\u521d\u671f\u5316\u3057\u305f\u914d\u5217\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u30eb\u30c3\u30af\u30a2\u30c3\u30d7\u30c6\u30fc\u30d6\u30eb\u306e\u6700\u5927\u5024\u306f\u753b\u50cf\u306e\u6700\u5927\u5024\u3068\u306a\u308a\u307e\u3059\u306e\u3067\u30b9\u30e9\u30a4\u30c0\u30fc\u306e\u6700\u5927\u5024\u3092\u53d6\u5f97\u3057\u305f\u6642\u306b\u4e00\u7dd2\u306b\u4f5c\u6210\u3057\u3066\u3057\u307e\u3044\u307e\u3057\u3087\u3046\u3002\u305d\u306e\u969b\u3001\u8981\u7d20\u6570\u3092\u6700\u5927\u5024+1\u3068\u3057\u3066\u6307\u5b9a\u3057\u3066\u304a\u304d\u307e\u3059\u3002 \uff08\u4e0b\u306e\u30b3\u30fc\u30c9\uff13\uff10\u884c\u76ee\uff09 <\/p>\n\n\n\n
\nimport fileselect\u3000as fs #\u30d5\u30a1\u30a4\u30eb\u30d1\u30b9\u53d6\u5f97\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\nimport numpy np\nimport pydicom\nimport math\nimport copy\n\nfilenames = fs.multi_fileselect\n\ndcm = pydicom.dcmread(filenames[0])\nrow,columns = dcm.pix_array.shape[0],dcm.pix_array.shape[1]\n #\u8aad\u307f\u8fbc\u3093\u3060\u753b\u50cf\u306e\u6a2a\u65b9\u5411\u3092\u5909\u6570row\u3001\u7e26\u65b9\u5411\u3092\u5909\u6570columns\u3068\u3057\u3066\u53d6\u5f97\u3057\u307e\u3059\u3002\n\ndcm_copy = np.zeros((len(filenames), row, columns),dtype = int)\n #dcm_copy\u3068\u3044\u3046\u540d\u524d\u3067\uff10\u3067\u521d\u671f\u5316\u3057\u305f\u914d\u5217\u3092\u4f5c\u6210\n\nfor i in range(len(filenames)):\n dcm = pydicom.dcmread(filenames[i])\n dcm_arr = dcm.pixel_array\n dcm_copy[i] = dcm_arr.astype(np.int64) \n #np.int64\u3068\u3057\u3066\u30c7\u30fc\u30bf\u306e\u578b\u3092\u6307\u5b9a\u3057\u3066\u304a\u304d\u307e\u3059\u3002\n\ndcm_main = copy.deepcopy(dcm_copy)\n #\u6df1\u3044\u30b3\u30d4\u30fc\u3067\u8907\u88fd\u3057\u307e\u3059\u3002\n\ncv2.namedWindow('dcm_image',cv2.WINDOW_NORMAL)\n #\u30a6\u30a4\u30f3\u30c9\u30a6\u540d\u3092'dcm_image'\u3068\u3057\u3001\u30a6\u30a4\u30f3\u30c9\u30a6\u30b5\u30a4\u30ba\u3092\u5909\u66f4\u3067\u304d\u308b\u3088\u3046\u306b\u8a2d\u5b9a\n\nmaxvalue = dcm_copy.max().astype(np.int64)\nlookup_tbl = np.zeros(maxvalue+1, dtype=np.int64)\n #\u4f5c\u6210\u8981\u7d20\u6570\u3092\u6700\u5927\u5024+1\u3068\u3057\u3066\u304a\u304f\u3002\n\ncv2.createTrackbar(\"WL\", \"dcm_image\", (maxvalue \/\/ 2), maxvalue, make_LUT)\ncv2.createTrackbar(\"WW\", \"dcm_image\", (maxvalue \/\/ 4), maxvalue, make_LUT)\n\nwhile 1:\n wl = cv2.getTrackbarPos('WL', 'dcm_image')\n ww = cv2.getTrackbarPos('WW', 'dcm_image')\n\n ww_low = wl - ww \/\/ 2\n ww_high = wl + ww \/\/ 2\n lookup_tbl[0:ww_low] = 0\n lookup_tbl[ww_high:maxvalue] = 255\n for i in range(ww_low, ww_high, 1):\n lookup_tbl[i] = math.ceil((i - ww_low) * (256 \/ (ww_high - ww_low)))\n\n dcm_copy = lookup_tbl[dcm_main]\n\n dcm_copy =cv2.convertScaleAbs(dcm_copy, alpha=255\/dcm_copy.max())\n cv2.imshow('dcm_image', dcm_copy[0])\n\n k = cv2.waitKey(1)\n if k == ord('q'):\n break\n\ndef make_LUT(val):\n pass #\u4f55\u3082\u3057\u306a\u3044<\/code><\/pre>\n\n\n\n<\/p>\n\n\n\n
\u30b9\u30e9\u30a4\u30c0\u30fc\u306e\u5024\u3092\u53d6\u5f97\u3057\u3001WL\u3088\u308aWW\uff0f\uff12\u3088\u308a\u9ad8\u3044\u30d4\u30af\u30bb\u30eb\u5024\u3092\uff12\uff15\uff15\u306b WL\u3088\u308aWW\uff0f\uff12\u3088\u308a\u4f4e\u3044\u30d4\u30af\u30bb\u30eb\u5024\u3092\uff10\u306b\u3057\u307e\u3059\u3002(\u4e0a\u306e\u30b3\u30fc\u30c9\uff14\uff12\uff5e\uff14\uff13\u884c\u76ee\uff09<\/p>\n\n\n\n
WW\u306e\u9593\u306f\uff11\u968e\u8abf\u304c\u3069\u306e\u304f\u3089\u3044\u306b\u5f53\u305f\u308b\u304b\u3092\u8a08\u7b97\u3057\u307e\u3059\u3002\u4e0a\u8a18\u30b3\u30fc\u30c9\uff14\uff15\u884c\u76ee\u306e\u8a08\u7b97\u3067\u6c42\u3081\u307e\u3059\u3002ceil \u306f\u5c0f\u6570\u70b9\u4ee5\u4e0b\u5207\u308a\u4e0a\u3052\u308b\u69cb\u6587\u3068\u306a\u308a\u307e\u3059\u3002\u3061\u306a\u307f\u306b\u3001math\u3068\u3044\u3046\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u69cb\u6587\u3068\u306a\u308a\u307e\u3059\u306e\u3067math\u3082\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u3066\u304a\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n
\u30eb\u30c3\u30af\u30a2\u30c3\u30d7\u30c6\u30fc\u30d6\u30eb\u306e\u4f5c\u6210\u306f\u3053\u308c\u3067\u5b8c\u4e86\u3067\u3059\u3002\u3067\u306f\u753b\u50cf\u306e\u30d4\u30af\u30bb\u30eb\u5024\u3092\u30eb\u30c3\u30af\u30a2\u30c3\u30d7\u30c6\u30fc\u30d6\u30eb\u306e\u5024\u306b\u5f53\u3066\u306f\u3081\u308b\u4f5c\u696d\u306b\u306a\u308b\u306e\u3067\u3059\u304c\u3001 \u30d4\u30af\u30bb\u30eb\u30c7\u30fc\u30bf\u3092\u305d\u306e\u307e\u307e\u5909\u66f4\u3057\u3066\u3057\u307e\u3046\u3068\u6b21\u306b\u30b9\u30e9\u30a4\u30c0\u30fc\u3092\u52d5\u304b\u3057\u305f\u6642\u3001\u30eb\u30c3\u30af\u30a2\u30c3\u30d7\u30c6\u30fc\u30d6\u30eb\u3092\u9069\u5fdc\u3057\u305f\u30d4\u30af\u30bb\u30eb\u30c7\u30fc\u30bf\u306b\u30b9\u30e9\u30a4\u30c0\u30fc\u306e\u8a2d\u5b9a\u304c\u53cd\u6620\u3055\u308c\u753b\u50cf\u8868\u793a\u304c\u304a\u304b\u3057\u304f\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u306e\u3067\u753b\u50cf\u30d4\u30af\u30bb\u30eb\u30c7\u30fc\u30bf\u3092dcm_main\u3068\u3057\u3066\u8907\u88fd\u3057\u3066\u304a\u304d\u307e\u3057\u3087\u3046\u3002\u305d\u306e\u969b\u3001\u666e\u901a\u306b dcm_main =dcm_copy\u3068\u3057\u3066\u3082\u30b3\u30d4\u30fc\u3055\u308c\u307e\u305b\u3093\u3002\u4e0a\u8a18\u30b3\u30fc\u30c9\u306f\u53c2\u7167\u3068\u3044\u3046\u610f\u5473\u306b\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002\u3053\u308c\u306fpython\u3067\u306f\u3001\u6d45\u3044\u30b3\u30d4\u30fc\u3068\u3044\u3046\u3053\u3068\u3067\u3042\u308a\u3001\u4eca\u56de\u306f\u6df1\u3044\u30b3\u30d4\u30fc\u3068\u3044\u3046\u65b9\u6cd5\u3092\u3064\u304b\u3063\u3066\u5225\u306e\u914d\u5217\u3068\u3057\u3066\u4f5c\u6210\u3057\u3066\u3042\u3052\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002 <\/p>\n\n\n\n
\u6df1\u3044\u30b3\u30d4\u30fc\u3092\u3057\u3066\u3044\u304d\u307e\u3059\u3002\u307e\u305a\u3001copy\u3068\u3044\u3046\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\uff08\uff15\u884c\u76ee\uff09\u3057\u307e\u3059\u3002\u305d\u306e\u5f8c\u3001\u6df1\u3044\u30b3\u30d4\u30fc\u3092\u3057\u307e\u3059\u3002\uff08\u4e0a\u8a18\u30b3\u30fc\u30c9\uff12\uff13\u884c\u76ee\uff09<\/p>\n\n\n\n
\u305d\u308c\u3067\u306f\u3001\u30eb\u30c3\u30af\u30a2\u30c3\u30d7\u30c6\u30fc\u30d6\u30eb\u3092\u53cd\u6620\u3057\u3066\u3044\u304d\u307e\u3059\u3002\uff14\uff17\u884c\u76ee\u306e\u30b3\u30fc\u30c9\u3067\u53cd\u6620\u3055\u308c\u307e\u3059\u304c\u3001 \u53cd\u6620\u3059\u308b\u914d\u5217\u306f dcm_main\u3068\u3057\u7d50\u679c\u3092dcm_copy\u3068\u3057\u307e\u3059\u3002<\/p>\n\n\n\n
\u3044\u3088\u3044\u3088\u753b\u50cf\u8868\u793a\u306b\u5165\u3063\u3066\u3044\u304f\u306e\u3067\u3059\u304c\u3001\u5b9f\u306f \u5148\u307b\u3069\u306eceil\u95a2\u6570\u306f\u8a08\u7b97\u7d50\u679c\u3092\u5207\u308a\u4e0a\u3052\u51e6\u7406\u3057\u3066\u3044\u308b\u95a2\u4fc2\u3067\uff12\uff15\uff15\u968e\u8abf\u3092\u30aa\u30fc\u30d0\u30fc\u3059\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u306e\u3067\u3053\u3053\u3067\u307e\u305f\uff12\uff15\uff15\u968e\u8abf\u306b\u843d\u3068\u3057\u8fbc\u3080\u4f5c\u696d\u304c\u5fc5\u8981\u306b\u306a\u308a\u307e\u3059\u3002 <\/p>\n\n\n\n
cv2.convertScaleAbs(dcm_copy, alpha=255\/dcm_copy.max())<\/p>\n\n\n\n
cv2.convertScaleAbs \u306f\u30a8\u30c3\u30b8\u51e6\u7406\u3067\u3088\u304f\u4f7f\u308f\u308c\u308b\u30b3\u30fc\u30c9\u3067\u3059\u3002\u8208\u5473\u304c\u3042\u308b\u65b9\u306f\u8abf\u3079\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n
\u5f8c\u306f\u3001\u5fd8\u308c\u304c\u3061\u306a\u5f85\u6a5f\u51e6\u7406\uff08\u30b3\u30fc\u30c9\uff15\uff12\u884c\u76ee\u304b\u3089\uff15\uff14\u884c\u76ee\uff09\u3092\u66f8\u3044\u3066\u7d42\u4e86\u3067\u3059\u3002<\/p>\n\n\n\n
<\/p>\n\n\n\n
\u6b63\u76f4\u3001\u753b\u50cf\u8868\u793a\u306fImage-J\u306a\u3069\u4f7f\u3048\u3070\u7c21\u5358\u306b\u8868\u793a\u3067\u304d\u308b\u306e\u3067\u3059\u304c\u3002\u3053\u308c\u304b\u3089\u3044\u308d\u3044\u308d\u3068\u753b\u50cf\u51e6\u7406\u3092\u3057\u3066\u3044\u3053\u3046\u3068\u8003\u3048\u308b\u3068\u907f\u3051\u3066\u306f\u901a\u308c\u306a\u3044\u9053\u3067\u3059\u306d\u3002\u9811\u5f35\u3063\u3066\u3044\u304d\u307e\u3057\u3087\u3046\uff01\uff01
\u9577\u304f\u306a\u308a\u307e\u3057\u305f\u3002\u3002\u3002\u3002\u3002\u304a\u75b2\u308c\u69d8\u3067\u3059\u3002<\/p>\n\n\n\n
<\/p>\n\n\n\n
\u74b0\u5883<\/h2>\n\n\n\n- windows10<\/li>
- python3.6.1 <\/li>
- Anaconda custom(64-bit)<\/li>
- PyCharm2020.2(Communication Edition)<\/li><\/ul>\n\n\n\n
<\/p>\n","protected":false},"excerpt":{"rendered":"
\u305d\u308c\u3067\u306f\u3001\u30b3\u30fc\u30c9\u3092\u7d44\u307f\u7acb\u3066\u3066\u3044\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002 […]<\/p>\n","protected":false},"author":1,"featured_media":363,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[6,4],"tags":[15,45,47,46],"class_list":["post-463","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-opencv","category-python","tag-mri","tag-opencv","tag-47","tag-46"],"aioseo_notices":[],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/i0.wp.com\/radiology-technologist.info\/wp-content\/uploads\/2019\/11\/python_logo.png?fit=614%2C612","_links":{"self":[{"href":"http:\/\/radiology-technologist.info\/wp-json\/wp\/v2\/posts\/463","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/radiology-technologist.info\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/radiology-technologist.info\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/radiology-technologist.info\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/radiology-technologist.info\/wp-json\/wp\/v2\/comments?post=463"}],"version-history":[{"count":20,"href":"http:\/\/radiology-technologist.info\/wp-json\/wp\/v2\/posts\/463\/revisions"}],"predecessor-version":[{"id":487,"href":"http:\/\/radiology-technologist.info\/wp-json\/wp\/v2\/posts\/463\/revisions\/487"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/radiology-technologist.info\/wp-json\/wp\/v2\/media\/363"}],"wp:attachment":[{"href":"http:\/\/radiology-technologist.info\/wp-json\/wp\/v2\/media?parent=463"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/radiology-technologist.info\/wp-json\/wp\/v2\/categories?post=463"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/radiology-technologist.info\/wp-json\/wp\/v2\/tags?post=463"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}