繁体   English   中英

我该怎么做才能提高图像质量?

[英]What can I do to enhance my image quality?

我有一个三相图像,其中我使用自动阈值(multithresh)和'imquantize'函数进行分段。 我的图像中有很多洞,没有任何过滤操作。 然而,当我使用中值滤波器时,这些孔会减少,尽管仍然存在相当多的滤波器。 原始图像

过滤后的分段图像

从这一点开始应用'imfill'功能会导致“过度填充”,如下图所示的红色圆圈部分所示。 FilledHoles图像

代码如下:

%# 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',你会发现大部分黑相都接触到固体(白色相)。 然而,自动分割不能准确地捕获这一点,因为分割图像具有围绕固相的中间(灰色)相的环。 我该如何处理?

非常感谢您的预期帮助/建议。

您的方法是否足够好取决于您希望在此实现的目标。 例如,边界需要多么平滑?

针对您的具体问题:您的量化图像有三个级别,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,[]);

同样,你可以在“黑色”通道上运行bwareaopen来删除这里和那里的白点。

对于大球形颗粒上的分水岭,您可以类似地从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;

会有一些权衡,因为灰阶的半月板将不再那么尖锐。 如果需要,您可以通过黑色通道的后续打开来稍微恢复。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM