我可以做些什么来提高我的图像质量?

What can I do to enhance my image quality?

我有一个三相图像,其中我使用自动阈值(multithresh)和“imquantize”功能进行了分割。在没有任何过滤操作的情况下,我的图像中确实有很多漏洞。但是,当我使用中值过滤器时,这些孔会减少,尽管尽管进行了过滤,但仍然有很多孔。

从这一点开始应用“imfill”函数会导致“过度填充”,如下图红圈部分所示。

代码如下:

%# Read in image
I = imread(‘original_image.jpg');
figure, imshow(I),axis off, title('Original Image');

%# Filter image
I = medfilt2(I);
% figure, imshow(I), title('Median-filtered image')

%# Segment image
thresh  = multithresh(I, 2);
BW      = imquantize(I, thresh);    
figure, imshow(BW,[]),axis off, title('Segmented Image'); 

%# Fill holes
BW2     = imfill(BW,'holes');    
figure, imshow(BW2, []); title('Filled holes image');

我只是想知道是否有更好的方法来处理这种情况。您认为使用“multithresh”和“imquantize”函数是否足以进行分割?分水岭能做得更好吗?这里有必要吗?

一般来说,请问我可以做些什么来提高输出图像的质量?

我问的原因是因为如果缩放原始图像的“imshow”,您会注意到大部分黑相接触实体(白相)。然而,自动分割并不能准确捕捉到这一点,因为分割后的图像在固相周围有中间(灰色)相环。我该如何处理?

非常感谢您的期待help/suggestions。

你的方法是否足够好在很大程度上取决于你想在这里实现什么。例如,边框需要多平滑?

针对您的具体问题:您的量化图像具有三个级别,0(黑色)、1(灰色)和 2(白色)。你似乎想关闭灰色区域的小黑洞。为此,只需创建一个仅包含灰色像素的单独二进制图像,然后组合回您的多级图像(您不应该将其称为 BW,因为 Matlab 文档在任何地方都将其用于二进制图像,如果您应该保持一致可以)。

% pull out the gray "channel"
grayPixels = BW==1; % will have ones everywhere there's gray, and 0 otherwise

% to close holes up to a maximum size, invert the image (holes become islands) 
% and eliminate small islands with bwareaopen
invGray = ~grayPixels;
invGray = bwareaopen(invGray,100); % closes holes up to 100pix size - adjust
grayPixels = ~invGray; % imshow to view result

% merge gray channel back in. Note we want black->gray, 
% but we don't want white->gray. 
% Since black/gray/white are 0/1/2, if we take the maximum of the gray 
% (which is 0/1) and your "BW" (which is 0/1/2), we replace 0 in BW with 1 
% wherever we have closed a hole

BW = max(BW,double(grayPixels);
imshow(BW,[]);

同样,您可以在"black"频道上运行bwareaopen去除这里那里的白点。

您可以将 "white" 通道从 BW 中类似地拉出,作为大球形颗粒的分水岭,您很可能会得到很好的结果(如果白色颗粒是什么你在追求)。


如果想让白色颗粒周围的细灰色边框消失,可以试试形态学开运算。基本上,您将灰色区域缩小几个像素(腐蚀),然后再将其重新增长几个像素(膨胀)。一条灰色的细线会完全消失,所以不会再长出任何东西。

% take the gray "channel" again (after closing the small holes)
grayPixels = BW == 1;
grayPixelsOpened = imopen(grayPixels,strel('disk',3)); % play with the radius 3 to get the desired result

% everything that used to be gray and is no longer so needs to be turned black 
% in the original image
BW(grayPixels~=grayPixelsOpened) = 0;

会有一些折衷,因为灰色阶段的弯月面将不再那么尖锐。如果需要,您可以通过后续打开黑色通道来恢复一些。