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
29 lines (28 loc) • 948 B
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.CreateImage([20,20], 0);
for(var i = 6; i<10; i++){
for (var j = 6; j <10; j++) {
image.SetGreyPixel(i,j,255)
}
}
var output = node_itk.ImageFilter({
"InputA":image,
"FilterName":"BinaryImageToLabelMapFilter",
"Progress": function(progress){console.log('处理进度:'+progress.toPercent(2))},
"Finish": function(r){
if(r.OK){
console.log(r.Output.GetNumberOfLabelObjects())
}else{
console.log(r);
}
}});
for (var i = 0; i < output.GetNumberOfLabelObjects(); i++) {
labelObject = output.GetNthLabelObject(i);
console.log(labelObject)
for (var j = 0; j < labelObject.Size(); j++) {
console.log("Object "+i+ " contains pixel "+labelObject.GetIndex(j))
};
};