Node.js使用连接的组件在图像上查找blob

时间:2017-04-04 14:02:29

标签: node.js imagemagick graphicsmagick

我正在尝试xy图像中斑点的坐标。

根据此问题的建议:Connected-component labeling with ImageMagick

我有这段代码。

最终结果正确地突出显示blob。

然而,我无法得到"详细"以编程方式输出。我需要x y坐标。我错过了什么?

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`

1 个答案:

答案 0 :(得分:1)

我找到了从gm操作中获取输出的方法

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
});
相关问题