簡體   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