如何显示面积大于1000的blob

时间:2015-06-16 06:37:09

标签: matlab image-processing computer-vision

我有一堆dicom图像,我已经应用了阈值并获得二进制图像,在标记二进制图像后我得到了区域50,150,450,851,1053,22301,现在我的问题是如何显示blob与区域大于1000。

mri %stack of dicom images 
im = squeeze(mri(:,:,14));
max_level = double(max(im(:)));
min_level = double(min(im(:)));
levels = graythresh(double(im)/min_level) * max_level;
bw = (mri>=levels);
%imshow(bw(:,:,14))
L = bwlabeln(bw);
stats = regionprops(L,'Area','Centroid');
A = [stats.Area]
L(A>1000 & A<24100) =1;
mri(L ~= L(1) )=0;
K = imadjust(mri(:,:,15));
imshow(K)

1 个答案:

答案 0 :(得分:1)

使用bwareaopen它将屏蔽小于给定阈值的blob

minimum_blob_size = 1000;
bw_without_small_blobs = bwareaopen(bw, minimum_blob_size);
imshow(bw_without_small_blobs );

修改

如果你想使用这个新的二进制图像作为掩码,这样的东西应该起作用

%this code is a little complex, but it multiplies the mask by the image
%the nice part is this will even work for an RGB (multi-channel) image
%as well as gray scale
masked_im = bsxfun(@times, im, cast(bw_without_small_blobs,class(im)));

imshow(masked_im);