blobs索引并将其掩盖在连续图像中

问题描述 投票:0回答:1

我需要找到blobs索引,然后在连续图像中屏蔽它们。谁能帮我?请让我知道如何列出blob的索引。我使用blob_analyzer来分析图像。干杯Mahtab

idl-programming-language
1个回答
0
投票

获取更多信息会很有帮助,但我假设您正在使用Coyote IDL Library中的blob_analyzer

因此,您从图像中创建一个blob对象:

blobs = obj_new('blob_analyzer', image)

您可以使用NumberOfBlobs方法找出识别出多少blob:

n_blobs = blobs -> NumberOfBlobs()

或者,您可以使用ReportStats方法获取有关所有blob的摘要信息:

blobs -> ReportStats

要获取第i个blob的索引,请使用GetIndices方法:

indices = blobs -> GetIndices(i)

这应该为您提供一维索引向量,如果需要,可以使用ARRAY_INDICES将其转换为二维索引。那将是:

indices_2D = array_indices(image, indices)

要屏蔽图像中的斑点,您可以简单地执行以下操作:

new_image = image  ;Make a copy of the original image
new_image[indices] = 0  ;Set all the pixels in the blob to 0

当然,这只会掩盖第i个blob中的像素,但您可以简单地创建一个循环来为所有blob重复上述过程。

new_image = image ;Make a copy of the original image
;Loop through and mask blobs
for i = 0, n_blobs - 1 do begin

    indices = blobs -> GetIndices(i)  ;Get indices for the ith blob
    new_image[indices] = 0            ;Mask those pixels

endfor
© www.soinside.com 2019 - 2024. All rights reserved.