2017-04-04 66 views
0

我正在尝试xy图像中的斑点坐标。Node.js在使用连接组件的图像上找到blob

从这个问题的以下建议:Connected-component labeling with ImageMagick

我有这样的一段代码。

最终结果正确地突出显示了斑点。

但是,我无法以编程方式获得“详细”输出。我需要xy坐标。 AM我错过了什么?

gm('difference.png') 
.out('-colorspace') 
.out('gray') 
.out('-threshold') 
.out('90%') 
.out('-define') 
.out('connected-components:verbose=true') 
.out('-connected-components') 
.out('4') 
.out('-auto-level') 
.write("out.png", function(err){ 
     console.log(err); 
     //how to get the verbose output about the blob positions?? 
    });`enter code here` 
+0

对不起输出的方式,我不能把握的Javascript所有,但也许你可以'重生()'是这样的 - HTTP ://stackoverflow.com/a/15516475/2836621 –

+0

欣赏你的帮助。我找到了获得blob职位详细输出的方式......张贴我的回答... – mkto

回答

1

我发现来从通用操作

gm(imagePath) 
.out('-define') 
.out('connected-components:verbose=true') 
.out('-connected-components') 
.out('4') 
.out('-auto-level') 
.write('out.png', function(err, stdout){ 
    //details in stdout 
}); 
+0

做得好,并感谢您与SO社区分享您的发现。 –