2014-03-26 30 views
1

我需要計算我拍攝的照片中某些微尺寸粒子的周長。 首先我處理圖像,現在我想處理二維處理的圖像,粒子是白色的,背景是黑色的,如你所知。 所以我需要一些方法&代碼來計算像素單位中的粒子直徑&。有什麼建議麼?! 在此先感謝通過matlab img處理粒度分佈的計算

+1

上傳一些樣本圖像(S)和鏈接在這裏嗎?你爲此做了什麼?另外,請看'regionprops' - http://www.mathworks.in/help/images/ref/regionprops.html。它涵蓋了這兩個功能。 – Divakar

+0

TnX for response,這是圖片的鏈接 http://tinypic.com/view.php?pic=i38b5s&s=8#.UzMJmqyKHNE –

回答

0

下面的代碼可以幫助你理解 -

%%// Input image 
BW = imread('text.png'); %%// Available in the MATLAB image library 
figure,imshow(BW) 

%%// Get the scalar distances around the boundaries of the regions/blobs 
P = regionprops(BW, 'Perimeter'); 

%%// Get scalar values that specifies the diameter of a circle with the same 
%%// area as the regions/blobs 
D = regionprops(BW, 'EquivDiameter'); 

%%// Get list of pixels based on their labeling. 
%%// Basically the indices of the structs produced by regionprops refer to the labels. 
pixel_list = regionprops(BW, 'PixelIdxList'); 

%%// Let us find out information about the first blob (blob that is labeled as 1) 

%%// 1. List of pixel coordinates as linear indices 
blob1_pixel_list = pixel_list(1).PixelIdxList; 

%%// Create an image of the same size as the original one and showing the 
%%blob labeled as 1 
blob1 = false(size(BW)); 
blob1(blob1_pixel_list) = true; 
figure,imshow(blob1) 

%%// Perimter of blob -1 
blob1_perimeter = P(1).Perimeter 

%%// Equivalent diameter of blob -1 
blob1_equivdiameter_values = D(1).EquivDiameter 

%%// Get perimeter and diameter values for all the blobs 
perimeter_values = struct2array(P) 
diameter_values = struct2array(D) 
+0

我試過但當我使用disp()顯示值時, 命令行顯示此:17x1結構數組與字段: 周長 17x1結構數組與字段: EquivDiameter –

+0

@VahidS檢出編輯的代碼。它演示瞭如何獲得第一個blob的直徑和周長信息。該17X1結構陣列的第一個元素是您的案例中第一個斑點的直徑。 – Divakar

+1

TNX百萬工作! ,我有很多問題要問,但足夠這個時間。 ;-) –