UNPKG

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

31 lines (28 loc) 939 B
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([200,200], 0); for(var i = 40; i<100; i++){ for (var j = 40; j <100 ; j++) { image.SetGreyPixel(i,j,50) } } image.SetGreyPixel(102,102,50) var output = node_itk.ImageFilter({ "InputA":image, "FilterName":"BinaryPruningImageFilter", "Iteration":"1", "Progress": function(progress){console.log('处理进度:'+progress.toPercent(2))}, "Finish": function(r){ if(r.OK){ r.Output.Write('BinaryPruningImageFilter.bmp', 'bmp') console.log(r) }else{ console.log(r); } }}); var viewer = new node_itk.NodeQuickView(); viewer.AddImage({"Input":image,"Flipvertical":true}) viewer.AddImage({"Input":output,"Flipvertical":true}) viewer.Visualize();