如何使用 matlab 正确镶嵌细胞图像?
How to properly tesselate a image of cells using matlab?
我有下面这张胰腺细胞照片
我想做的是能够获得每个细胞的膜(红色细丝),然后进行镶嵌以了解细丝的长度。
到目前为止,我已经尝试使用 matlab 网站上给出的示例,但结果并不是很好...
I = imread('picture.tiff');
I_gray = rgb2gray(I);
[~, threshold] = edge(I_gray, 'sobel');
fudgeFactor = .5;
BWs = edge(I_gray,'sobel', threshold * fudgeFactor);
se90 = strel('line', 3, 90);
se0 = strel('line', 3, 0);
BWsdil = imdilate(BWs, [se90 se0]);
我一直在寻找其他方法来做,但没有任何令人满意的结果...有没有办法做到这一点?也许除 matlab 之外的其他软件可能更有效。提前谢谢你!
我不确定这是否能让您更接近问题的解决方案,但我会做这样的事情。请注意,这是一种非常简单和幼稚的方法:
image = imread('picture.tiff'); % load image
image = rgb2hsv(image); % convert to hsv colorspace
image = image(:,:,1); % take the hue channel
binary_im = imbinarize(image); % make binary image
二进制图像应如下所示:
现在您可以使用数学形态学来消除噪声。您首先创建一个结构元素,然后将其与二值图像进行卷积:
str_el = strel('disk', 5, 0); % create a round, 5px radius, str_el
closed_im = imclose(binary_im, str_el); % close image with str_el
现在您的新图片应该如下所示:
此时可以使用另一种寻找骨架的形态学操作:
skeleton = bwmorph(closed_im, 'skel', Inf); % Find skeleton image
骨架图像看起来像这样:
当然,这种方法远非精确,但可以为您提供有关灯丝长度的总体信息,特别是如果您可以去除最终的噪音(骨架的那些附件)。
我对单元格或曲面细分等一无所知。但是如果你想检测非均匀背景中的那些斑点,那么我可能会有所帮助。由于背景不均匀,您需要单独分析斑点。你不能只设置一个固定的阈值来一次检测所有的斑点。首先,您将单独检测每个斑点,然后使用单独的阈值。这是例子
原图
im=imread('gxGkH.jpg');
figure,imagesc(im);axis image;
我只选择蓝色进行分析
imb=im(:,:,3);
figure,imagesc(imb);axis image;
1) 模糊图像,因为模糊后的斑点会有局部
maxima/minima 在他们的中心
sigma=7;
kernel = fspecial('gaussian',4*sigma+1,sigma);
im2=imfilter(imb,kernel,'symmetric');
figure,imagesc(im2);axis image;
2) 使用分水岭变换分离每个斑点区域
% L = watershed(im2);
L = watershed(max(im2(:))-im2);
[x,y]=find(L==0);
划清界限
figure,imagesc(im2),axis image
hold on, plot(y,x,'r.')
3) 在这里我单独分析每个斑点并找到一个 otsu 阈值
每个斑点,然后我检测斑点并结合所有检测结果
tmp=zeros(size(imb));
for i=1:max(L(:))
ind=find(L==i);
mask=L==i;
[thr,metric] =multithresh(imb(ind),1);
if metric>0.7
tmp(ind)=imb(ind)>thr;
end
end
去除一些噪音
tmp=imopen(tmp,strel('disk',1));
figure,imagesc(tmp),axis image
如果背景的对比度比斑点高,则不需要在分水岭变换中反转图像。
我有下面这张胰腺细胞照片
我想做的是能够获得每个细胞的膜(红色细丝),然后进行镶嵌以了解细丝的长度。 到目前为止,我已经尝试使用 matlab 网站上给出的示例,但结果并不是很好...
I = imread('picture.tiff');
I_gray = rgb2gray(I);
[~, threshold] = edge(I_gray, 'sobel');
fudgeFactor = .5;
BWs = edge(I_gray,'sobel', threshold * fudgeFactor);
se90 = strel('line', 3, 90);
se0 = strel('line', 3, 0);
BWsdil = imdilate(BWs, [se90 se0]);
我一直在寻找其他方法来做,但没有任何令人满意的结果...有没有办法做到这一点?也许除 matlab 之外的其他软件可能更有效。提前谢谢你!
我不确定这是否能让您更接近问题的解决方案,但我会做这样的事情。请注意,这是一种非常简单和幼稚的方法:
image = imread('picture.tiff'); % load image
image = rgb2hsv(image); % convert to hsv colorspace
image = image(:,:,1); % take the hue channel
binary_im = imbinarize(image); % make binary image
二进制图像应如下所示:
现在您可以使用数学形态学来消除噪声。您首先创建一个结构元素,然后将其与二值图像进行卷积:
str_el = strel('disk', 5, 0); % create a round, 5px radius, str_el
closed_im = imclose(binary_im, str_el); % close image with str_el
现在您的新图片应该如下所示:
此时可以使用另一种寻找骨架的形态学操作:
skeleton = bwmorph(closed_im, 'skel', Inf); % Find skeleton image
骨架图像看起来像这样:
当然,这种方法远非精确,但可以为您提供有关灯丝长度的总体信息,特别是如果您可以去除最终的噪音(骨架的那些附件)。
我对单元格或曲面细分等一无所知。但是如果你想检测非均匀背景中的那些斑点,那么我可能会有所帮助。由于背景不均匀,您需要单独分析斑点。你不能只设置一个固定的阈值来一次检测所有的斑点。首先,您将单独检测每个斑点,然后使用单独的阈值。这是例子
原图
im=imread('gxGkH.jpg');
figure,imagesc(im);axis image;
我只选择蓝色进行分析
imb=im(:,:,3);
figure,imagesc(imb);axis image;
1) 模糊图像,因为模糊后的斑点会有局部 maxima/minima 在他们的中心
sigma=7;
kernel = fspecial('gaussian',4*sigma+1,sigma);
im2=imfilter(imb,kernel,'symmetric');
figure,imagesc(im2);axis image;
2) 使用分水岭变换分离每个斑点区域
% L = watershed(im2);
L = watershed(max(im2(:))-im2);
[x,y]=find(L==0);
划清界限
figure,imagesc(im2),axis image
hold on, plot(y,x,'r.')
3) 在这里我单独分析每个斑点并找到一个 otsu 阈值 每个斑点,然后我检测斑点并结合所有检测结果
tmp=zeros(size(imb));
for i=1:max(L(:))
ind=find(L==i);
mask=L==i;
[thr,metric] =multithresh(imb(ind),1);
if metric>0.7
tmp(ind)=imb(ind)>thr;
end
end
去除一些噪音
tmp=imopen(tmp,strel('disk',1));
figure,imagesc(tmp),axis image
如果背景的对比度比斑点高,则不需要在分水岭变换中反转图像。