显示基于BLOB的[row,column]数组的图像

时间:2018-11-03 17:42:20

标签: matlab image-processing

我正在尝试在Matlab中进行一些图像分析。我所拥有的是一个图像,我首先使用阈值将其转换为二进制图像,然后使用bwlabel获取图像的BLOB。然后,我找到第一个BLOB的索引,并尝试仅显示此BLOB I(row,column,:)的RGB值。但是,这显然行不通,而且我不知道如何基于二进制图像中的行,列数据为原始图像编制索引并获取相应的RGB值。我想我可以使用for循环,但是图像是4032 x 3024,并且我想对很多图像进行这种处理。

I = imread('someimg.jpg');
Ired   = I(:,:,1);
Igreen = I(:,:,2);
Iblue  = I(:,:,3);
% threshold
IBinary = Ired > 200 & Igreen > 150 & Iblue > 50;
IBinary = imopen(ISigns,strel('square',9));
% get labbelled BLOBs
IBinaryLabelled = bwlabel(IBinary,8);
% find index of the first label image
[row,column] = find(IBinaryLabelled == 1);
% Get RGB of the BLOB with label 1
RGB = I(row,column,:)

因此,我的问题是:如何有效地基于二进制图像的行,列数据获取RGB值?

0 个答案:

没有答案