2016-04-08 17 views
-1

檢測指谷我的手那樣的二值圖像:用Matlab

hand binary image

我必須寫一個Matlab函數,其檢測兩個手指之間的山谷。 參數是二進制圖像和兩個手指尖的座標。

我是新的圖像處理,我不知道如何開始。

+1

有很多方法。你可以試着找到一些使用谷歌,然後問更具體的問題。 – RobAu

+0

我知道兩個手指之間的黑色區域中的一個點的位置。我的想法是從這一點開始並搜索山谷(搜索區域由白色像素和兩個手指尖的X座標分隔)。但我不知道我該如何搜索谷點。 –

+0

研究:「凸度缺陷」,這是一種通常用於處理這種手部圖像的方法。 – RobAu

回答

1

我建議隔離兩個輸入點之間的黑色區域,然後找到此連接組件中的最高點。 你可以嘗試下面的方法(你可能需要調整一些參數,但它應該是一個好的開始)。

I = rgb2gray(imread('<your path>')); 

%input parameters - points which represents two finger tips. 
x1 = 408; y1 = 441; 
x2 = 454; y2 = 373; 

%binarize image 
I = im2bw(I); 

%noise reduction - close holes 
I2 = imclose(I,strel('disk',10)); 

%draw a line between p1 and p2 
ind = drawline([y1 x1],[y2 x2],size(I)); 
lineMat = zeros(size(I)); 
lineMat(ind) = 1; 

%adds the line to the image 
I2 = I2 | lineMat; 

%finds a point in the middle of the line 
[lineY, lineX] = ind2sub(size(I),ind); 
midX = lineX(ceil(length(ind)/2)); 
midY = lineY(ceil(length(ind)/2)); 

%finds a point which resides in the connected component which is between 
%the line and the two finger. 
xSeed = midX; 
ySeed = midY -5; 

%perform imfill operation, starting from (xSeed,ySeed), 
%in order to find the conected component in which the point (xSeed,ySeed) 
%resides. 
diffMat = imfill(I2,[ySeed xSeed])~=I2; 

%finding the highest point in this connected component 
[Y, X] = ind2sub(size(diffMat),find(diffMat)); 
minInd = find(Y==min(Y),1,'first'); 
yValley = Y(minInd); 
xValley = X(minInd); 

%presents result 
imshow(I);hold on; 
plot(x1,y1,'r.','MarkerSize',20); 
plot(x2,y2,'r.','MarkerSize',20); 
plot(xValley,yValley,'b.','MarkerSize',20); 

*畫線功能取自drawline webpage

最終結果(輸入點紅色,輸出點藍色)。 enter image description here

-1

這只是算法,但所有這些功能MatLab中肯定存在:

  1. 計算的凸包
  2. 計算的區別:凸包減去原來的形狀。然後,你有所有的山谷你正在尋找,再加上一些小圖案。
  3. 連接組件標籤。
  4. 刪除小部件。然後你的手指之間有了所有的山谷。
  5. 然後您可以使用指尖座標選擇您想要的那個。