Skip to content

Instantly share code, notes, and snippets.

View haehn's full-sized avatar
🤠

Daniel Haehn haehn

🤠
View GitHub Profile
element = cornerstone.getEnabledElements()[0];
pixels = element.image.getPixelData();
new_pixels = Sobel(pixels, element.image.width, element.image.height);
pixels.set(new_pixels);
element.needsRedraw = true;
@haehn
haehn / load.html
Created April 9, 2022 21:30
Cornerstone.js DICOM Minimal example
<html>
<head>
<script src="https://unpkg.com/cornerstone-core/dist/cornerstone.min.js
"></script>
<script src="https://unpkg.com/cornerstone-wado-image-loader"></script>
<script src="https://unpkg.com/dicom-parser"></script>
<script>
cornerstoneWADOImageLoader.external.cornerstone = cornerstone;
cornerstoneWADOImageLoader.external.dicomParser = dicomParser;
@haehn
haehn / view.html
Last active April 9, 2022 21:50
Cornerstone.js DICOM Viewer
<html>
<head>
<script src="https://unpkg.com/cornerstone-core/dist/cornerstone.min.js
"></script>
<script src="https://unpkg.com/cornerstone-wado-image-loader"></script>
<script src="https://unpkg.com/dicom-parser"></script>
<script>
cornerstoneWADOImageLoader.external.cornerstone = cornerstone;
cornerstoneWADOImageLoader.external.dicomParser = dicomParser;
@haehn
haehn / brush.html
Created April 9, 2022 22:52
Cornerstone.js DICOM Brush Example
<html>
<head>
<script src="https://unpkg.com/cornerstone-core/dist/cornerstone.min.js
"></script>
<script src="https://unpkg.com/cornerstone-wado-image-loader"></script>
<script src="https://unpkg.com/dicom-parser"></script>
<script src="https://unpkg.com/cornerstone-math"></script>
<script src="https://unpkg.com/cornerstone-tools"></script>
<script src="https://unpkg.com/hammerjs"></script>
<script>
@haehn
haehn / stack.html
Last active April 15, 2022 01:09
Cornerstone.js DICOM Stack+Brush
<html>
<head>
<script src="https://unpkg.com/cornerstone-core/dist/cornerstone.min.js
"></script>
<script src="https://unpkg.com/cornerstone-wado-image-loader"></script>
<script src="https://unpkg.com/dicom-parser"></script>
<script src="https://unpkg.com/cornerstone-math"></script>
<script src="https://unpkg.com/cornerstone-tools"></script>
<script src="https://unpkg.com/hammerjs"></script>
<script>
@haehn
haehn / gist:9c36c57f2c845eb8791331628896ef5b
Created November 8, 2022 01:41
robot.js from class Fall 2022
Robot = function(x, y, z) {
//
// HEAD, NECK, TORSO
//
var fromhelper = HELPER.cylinderSkeletonMesh(3, 5, 'blue')
var geometry = fromhelper[0];
var material = fromhelper[1];
var bones = fromhelper[2];
@haehn
haehn / sam.js
Created May 12, 2023 02:38
SegmentAnything for Cornerstone.js (JS injection!)
//
// VISIT DANIELHAEHN.COM !
//
// Thanks to Alireza Seghi and Kevin Wang for all the help!
//
//
//
// GET EMBEDDING FOR CANVAS
element = cornerstone.getEnabledElements()[0];
@haehn
haehn / test.js
Created June 6, 2023 15:56
NiiVue SAM WIP
// 1. hide crosslines
nv.setCrosshairColor([0,0,0,0]);
nv.opts.crosshairWidth=0;
nv.updateGLVolume();
// 2. grab REAL pixels
c = document.getElementById('viewer')
ctx = c.getContext("webgl2")
script = document.createElement("script");
script.type = "text/javascript";
script.src = "https://boostlet.org/dist/boostlet.min.js";
script.onload = run;
document.head.appendChild(script);
eval(script);
function run() {
canvas = viewer.canvas.children[0]; // TODO needs to be generic and executed with Boostlet.init
@haehn
haehn / index.html
Last active September 29, 2023 15:57
CS460 Fall 2023 Hello Rectangle in Vanilla WebGL!
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<title>Default WebGL!</title>
<style>
html, body {
background-color:#000;
margin: 0;
padding: 0;