简体   繁体   English

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

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

I have a 3-phase image in which I have segmented using automated thresholding (multithresh) and 'imquantize' functions. 我有一个三相图像,其中我使用自动阈值(multithresh)和'imquantize'函数进行分段。 I do have lots of holes in the image without any filtering operation. 我的图像中有很多洞,没有任何过滤操作。 However, these holes are reduced when I use a median filter although there are still quite a few of them left in-spite of the filtering. 然而,当我使用中值滤波器时,这些孔会减少,尽管仍然存在相当多的滤波器。 原始图像

过滤后的分段图像

Applying the 'imfill' function from this point results in “over-filling” as observed in the red-circled part of the image shown below. 从这一点开始应用'imfill'功能会导致“过度填充”,如下图所示的红色圆圈部分所示。 FilledHoles图像

The code is as follows: 代码如下:

%# 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');

I am just wondering if there is any better way to handle this situation. 我只是想知道是否有更好的方法来处理这种情况。 Do you think using the 'multithresh' and 'imquantize' functions are good enough for the segmentation? 你认为使用'multithresh'和'imquantize'函数对分割来说已经足够了吗? Can the watershed do better and is it even necessary here? 流域能否做得更好,甚至是必要的吗?

In general, please what can I do to enhance the quality of my output image? 一般来说,我该怎么做才能提高输出图像的质量?

The reason I ask is because if you scale 'imshow' of the original image you will notice that most of the black phase touches the solid (white phase). 我问的原因是因为如果你缩放原始图像的'imshow',你会发现大部分黑相都接触到固体(白色相)。 However, the automated-segmentation doesn't accurately capture this as the segmented image has rings of the intermediate (grey) phase around the solid phase. 然而,自动分割不能准确地捕获这一点,因为分割图像具有围绕固相的中间(灰色)相的环。 How do I also handle this? 我该如何处理?

Many thanks for your anticipated help/suggestions. 非常感谢您的预期帮助/建议。

Whether your approach is good enough or not depends a lot on what you want to achieve here. 您的方法是否足够好取决于您希望在此实现的目标。 For example, how smooth do the borders need to be? 例如,边界需要多么平滑?

To your specific question: Your quantized image has three levels, 0 (black), 1 (gray), and 2 (white). 针对您的具体问题:您的量化图像有三个级别,0(黑色),1(灰色)和2(白色)。 You seem to want to close the little black holes in the gray area. 你似乎想要关闭灰色区域的小黑洞。 For this, just create a separate binary image with the gray pixels only, and then combine back into your multilevel image (which you shouldn't call BW, since the Matlab documentation uses that for binary images everywhere, and you should be consistent if you can). 为此,只需用灰色像素创建一个单独的二进制图像,然后再组合成多级图像(你不应该称之为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,[]);

Similarly, you can run bwareaopen on the "black" channel to remove the white dots here and there. 同样,你可以在“黑色”通道上运行bwareaopen来删除这里和那里的白点。

You can pull the "white" channel out similarly out of BW for watershed on the large spherical particles, and you'll most likely get a pretty good result (if the white particles are what you're after). 对于大球形颗粒上的分水岭,您可以类似地从BW拉出“白色”通道,并且您很可能获得相当好的结果(如果白色颗粒是您所追求的)。


If you want to make the thin gray borders around the white particles disappear, you could try morphological opening. 如果你想让白色颗粒周围的薄灰色边框消失,你可以尝试形态开口。 Basically, you shrink the gray area by a few pixels (erosion), and then your re-grow it by a few pixels (dilation). 基本上,你将灰色区域缩小几个像素(侵蚀),然后再重新增长几个像素(膨胀)。 A thin gray line will disappear completely, so there won't be anything to grow back from. 细灰线将完全消失,因此不会有任何后退。

% 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;

There will be some trade-off, since the meniscus of the gray phase will no longer be as sharp. 会有一些权衡,因为灰阶的半月板将不再那么尖锐。 You may be able to recover somewhat with a follow-up opening of the black channel, if needed. 如果需要,您可以通过黑色通道的后续打开来稍微恢复。

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

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