2011-04-12 456 views
0

當我任何圖像上做segemtation它與背景和前景的表示返回一個圖像I-E的二值圖像。 現在如果我想使用的圖像的背景只爲任何目的.....怎麼辦it..i均值分割後我得到的二進制圖像現在如何識別(或服用)僅背景值。 ???????在Matlab分割後如何利用背景值從圖像?

回答

0

我假設你有一個灰度圖像。當你的分割目標爲1,背景爲0時,只需進行元素明智的矩陣乘法運算即可得到目標圖像。這與掩蔽相似。如果你只需要背景,你可以做(​​1 - 二進制圖像),並做相似的乘法與原始圖像。請記住,這是元素明智的乘法而不是矩陣乘法。

+1

你們,我有一個灰度圖像,我只是想,用1來表示的背景圖像(在分割後我的圖像的情況)。現在我想從背景像素形成原始圖像,並希望取平均值的背景像素。 – chee 2011-04-14 18:52:48

+0

如果我有命名爲「IMG」 ..比我可以通過使用查找語句等的ind採取背景衣被合計分割圖像=找到(IMG == 1); BT它給了奇怪的事情..... – chee 2011-04-14 18:57:45

+0

@chee請添加這些意見你的問題 - 他們使它更加清晰。 – Shai 2012-12-12 16:20:26

1
% Assume you have these variables: 
% 'mask' - binary segmentation results, all 1's or 0's. 
% 'img' - original image. 
% 'bgImg' - Output, containing background only. 

bgImg = zeros(size(img)); % Initialize to all zeros. 
bg(mask) = img(mask);  % Use logical indexing. 
0

如果要衡量前景/背景區域的統計,一個有趣的選擇是regionprops

% img - variable containing original grey-scale image 
% mask - binary mask (same size as img) with 0 - background 1 - foreground 

% using regionprops to measure average intensity and weighted centroid, 
% there are MANY more interesting properties ou can measure, use 
% >> doc regionprops 
% to discover them 
st = regionprops(mask + 1, img, 'MeanIntensity', 'WeightedCentroid'); 

% get BG avg intensity: 
fprintf(1, 'Avg intensity of background = %.2g\n', st(1).MeanIntensity);