node-itk
Version:
ITK is an open-source, cross-platform system that provides developers with an extensive suite of software tools for image analysis. Among them, Node-ITK is a node.js wrapper which built on top of ITK, intended to facilitate its use in rapid prototyping, education, and web servies for Medical Image Processing.Its Origins by My master thesis--jolly, a new Framework for Medical Image Processing
53 lines (48 loc) • 1.58 kB
JavaScript
Number.prototype.toPercent = function(n){n = n || 0;return ( Math.round( this * Math.pow( 10, n + 2 ) ) / Math.pow( 10, n ) ).toFixed( n ) + '%';}
var node_itk = require('node-itk');
var path = require('path')
var image = new node_itk.NodeImage('uchar',2);
image.Read('uchar', 2, path.resolve(__dirname, 'Data/BrainProtonDensitySlice.png'), 'png');
var binaryimage = node_itk.ImageFilter({
"InputA":image,
"FilterName":"ThresholdImageFilter",
"LowerThreshold":180,
"OutsideValue": 0,
"Progress": function(progress){console.log('处理进度:'+progress.toPercent(2))},
"Finish": function(r){
if(r.OK){
r.Output.Write('ThresholdImageFilterOutputBelow.bmp', 'bmp')
console.log(r);
}else{
console.log(r);
}
}});
binaryimage = node_itk.ImageFilter({
"InputA":image,
"FilterName":"ThresholdImageFilter",
"UpperThreshold":180,
"OutsideValue": 0,
"Progress": function(progress){console.log('处理进度:'+progress.toPercent(2))},
"Finish": function(r){
if(r.OK){
r.Output.Write('ThresholdImageFilterOutputAbove.bmp', 'bmp')
console.log(r);
}else{
console.log(r);
}
}});
binaryimage = node_itk.ImageFilter({
"InputA":image,
"FilterName":"ThresholdImageFilter",
"LowerThreshold":170,
"UpperThreshold":190,
"OutsideValue": 0,
"Progress": function(progress){console.log('处理进度:'+progress.toPercent(2))},
"Finish": function(r){
if(r.OK){
r.Output.Write('ThresholdImageFilterOutputOutside.bmp', 'bmp')
console.log(r);
}else{
console.log(r);
}
}});