gpt4 book ai didi

javascript - 如何在基石库中传递 dicom 文件的路径并显示它?

转载 作者:行者123 更新时间:2023-11-30 20:07:47 24 4
gpt4 key购买 nike

我想显示来 self 网站的 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 文件中传递一个路径,然后显示它?

最佳答案

您在这里缺少图像加载器部分。 Cornerstone 需要图像加载器将您的链接转换为 Cornerstone 可读的图像对象。如果你看cornerstone's github repo ,你会发现两个图像加载器。 WADO 图像加载器可用于读取 DICOM 文件。您将不得不构建一个后端来提供 DICOM 文件,因为浏览器将无法访问服务器文件。假定您有访问 DICOM 文件的 uri:

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);
});

注意:如果您没有 npm,只需链接到 .js 文件作为脚本而不是导入(或者您也可以在 ES6+ 中导入它们)

关于javascript - 如何在基石库中传递 dicom 文件的路径并显示它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52698119/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com