上下文:我利用SVM分析图像并找到感兴趣的像素。在滤出低兴趣像素(下面的完整代码)之后,存储得到的二进制掩码以便稍后显示。同时,我使用ndimage.label
来浏览二进制掩码并生成找到的补丁列表,并跟踪找到的补丁数量(特征数量)
问题/问题:我正在使用的图像是超高分辨率,这意味着有"噪音"由ndimage.label
计算的像素组(小于100)。这意味着由于所有这些噪声组和单个像素,可能只有10个补丁的图像计数为1000+。给定原始二进制掩码和标记数组,有没有办法修改二进制掩码,以便只包含一定大小的补丁?
#SVM analyzes image
scoreMap = self.svmMachine.predict(inData)
scoreMap = scoreMap.reshape(origDims)
#An array with a score for each pixel is produced
self.allPixelScoreMaps[self.imageKeys[i]]['PxlScores'] = scoreMap
#print(scoreMap)
topPrct = np.percentile(scoreMap, 95)
#A binary mask is then created from the pixels of high interest
binaryMap = (scoreMap > topPrct).astype(np.int)
#The mask is then stored to be displayed later
self.allPixelScoreMaps[self.imageKeys[i]]['BinScores'] = binaryMap
labeled_array, num_features = ndimage.label(binaryMap, structure = self.labelCal)
self.allPixelScoreMaps[self.imageKeys[i]]['LabelMap'] = labeled_array
self.allPixelScoreMaps[self.imageKeys[i]]['NumFeatures'] = num_features
答案 0 :(得分:0)
我找到了我正在寻找的确切答案!它可以在本教程中找到:http://www.scipy-lectures.org/intro/summary-exercises/answers_image_processing.html