我想从我的网站上显示Dicom图像。所以我找到了基石库来做到这一点。
这是代码:
<!DOCTYPE HTML>
<html>
<head>
<!-- twitter bootstrap CSS stylesheet - included to make things pretty, not needed or used by cornerstone -->
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
<link href="cornerstone.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="page-header">
<br>
</div>
<div class="row">
<form class="form-horizontal">
<div class="form-group">
<input type="file" id="selectFile" >
</div>
</form>
</div>
<div style="width:512px;height:512px;position:relative;color: white;display:inline-block;border-style:solid;border-color:black;"
oncontextmenu="return false"
class='disable-selection noIbar'
unselectable='on'
onselectstart='return false;'
onmousedown='return false;'>
<div id="dicomImage"
style="width:512px;height:512px;top:0px;left:0px; position:absolute">
</div>
</div>
</div>
</body>
<!-- jquery - currently a dependency and thus required for using cornerstoneWADOImageLoader -->
<script src="jquery.min.js"></script>
<!-- include the cornerstone library -->
<script src="cornerstone.min.js"></script>
<!-- include the dicomParser library as the WADO image loader depends on it -->
<script src="dicomParser.min.js"></script>
<!-- include the cornerstoneWADOImageLoader library -->
<script src="cornerstoneWADOImageLoader.min.js"></script>
<script src="../dist/cornerstoneFileImageLoader.js"></script>
<!-- jpeg 2000 codec -->
<script src="jpx.min.js"></script>
<script>
$(document).ready(function() {
var element = $('#dicomImage').get(0);
cornerstone.enable(element);
// Listen for the change event on our input element so we can get the
// file selected by the user
$('#selectFile').on('change', function(e) {
// Add the file to the cornerstoneFileImageLoader and get unique
// number for that file
var file = e.target.files[0];
alert("cambio il file");
var index = cornerstoneFileImageLoader.addFile(file);
// create an imageId for this image
var imageId = "dicomfile://" + index;
// load and display this image into the element
var element = $('#dicomImage').get(0);
cornerstone.loadImage(uriImageDesktop).then(function(image) {
cornerstone.displayImage(element, image);
});
});
});
</script>
</html>
使用此代码,我可以使用文件选择器显示单个HTML页面。有了这个组件,我可以导航到我的电脑,然后库加载Dicom图像。
现在,我想从URL传递Dicom图片的路径。
所以我正在尝试这样做
var uriImageDesktop = "C:\Users\michele\Desktop\deflate_tests\image";
// load and display this image into the element
var element = $('#dicomImage').get(0);
cornerstone.loadImage(uriImageDesktop).then(function(image) {
cornerstone.displayImage(element, image);
});
此刻我需要静态dicom图像,但找不到。
问题是,如何从dicom文件中传递路径,然后显示它?
答案 0 :(得分:1)
您在这里缺少图像加载器部分。基石要求图像加载器将您的链接转换为基石可读取的图像对象。如果您查看cornerstone's github repo,将会发现两个图像加载器。 WADO图像加载器可用于读取DICOM文件。尽管由于浏览器将无法访问服务器文件,但是您将必须构建一个后端来提供DICOM文件。 如果您有一个uri来访问DICOM文件:
import * as cornerstone from "cornerstone-core"
import * as cornerstoneWADOImageLoader from "cornerstone-wado-image-loader"
cornerstoneWADOImageLoader.external.cornerstone = cornerstone
const uriServed = "http://xxx/deflate_tests/image"
const element = $('#dicomImage').get(0);
cornerstone.loadImage("wadouri:" + uriServed).then(image => {
cornerstone.displayImage(element, image);
});
NB :如果您没有npm,只需将脚本链接到.js文件而不是导入(或者也可以在ES6 +中将其导入)
答案 1 :(得分:0)
也许URI格式无效。该示例不包含方案。
file://c:/Users/user/Desktop/images/image.dcm
可能会更好。