10

나의 생물 학자 친구는 내가 도마뱀의 squam을 (이것은 적당한 번역인가?)에 프로그램을 만드는 것을 도울 수 있는지 나에게 물었다.도마뱀의 squama를 센다

그는 어떤 이미지를 보내고 Matlab에서 몇 가지 것을 시도했습니다. 일부 이미지의 경우 다른 이미지보다 훨씬 더 짙습니다 (예 : 어두운 영역이있는 경우). 적어도 내 방법으로. 나는 여기에 유용한 도움을 얻을 수있을 것이라고 확신한다. 어떻게 개선해야합니까? 나는 올바른 접근법을 취했는가?

다음은 일부 이미지입니다.

pic2

pic1

나는 Image Processing and Counting using MATLAB에 따라 가장 좋은 결과를 얻었다. 기본적으로 이미지를 흑백으로 바꾼 다음 임계 값으로 설정합니다. 그러나 나는 약간의 침식을 더했다.

여기에 코드입니다 :

img0=imread('C:...\pic.png'); 

img1=rgb2gray(img0); 

%The output image BW replaces all pixels in the input image with luminance greater than level with the value 1 (white) and replaces all other pixels with the value 0 (black). Specify level in the range [0,1]. 
img2=im2bw(img1,0.65);%(img1,graythresh(img1)); 

imshow(img2) 
figure; 

%erode 
se = strel('line',6,0);  
img2 = imerode(img2,se); 
se = strel('line',6,90); 
img2 = imerode(img2,se); 
imshow(img2) 
figure; 

imshow(img1, 'InitialMag', 'fit') 

% Make a truecolor all-green image. I use this later to overlay it on top of the original image to show which elements were counted (with green) 
green = cat(3, zeros(size(img1)),ones(size(img1)), zeros(size(img1))); 
hold on 
h = imshow(green); 
hold off 


%counts the elements now defined by black spots on the image 
[B,L,N,A] = bwboundaries(img2); 
%imshow(img2); hold on; 
set(h, 'AlphaData', img2) 
text(10,10,strcat('\color{green}Objects Found:',num2str(length(B)))) 
figure; 



%this produces a new image showing each counted element and its count id on top of it. 
imshow(img2); hold on; 
colors=['b' 'g' 'r' 'c' 'm' 'y']; 
for k=1:length(B), 
    boundary = B{k}; 
    cidx = mod(k,length(colors))+1; 
    plot(boundary(:,2), boundary(:,1), colors(cidx),'LineWidth',2); 
    %randomize text position for better visibility 
    rndRow = ceil(length(boundary)/(mod(rand*k,7)+1)); 
    col = boundary(rndRow,2); row = boundary(rndRow,1); 
    h = text(col+1, row-1, num2str(L(row,col))); 
    set(h,'Color',colors(cidx),'FontSize',14,'FontWeight','bold'); 
end 
figure; 
spy(A); 

그리고이 결과의 일부입니다. 왼쪽 상단 모서리에는 계산 된 개수가 표시됩니다.

또한 계산 된 요소를 초록색으로 표시하여 사용자가 수동으로 계산해야하는 요소를 알 수 있도록하는 것이 유용하다고 생각합니다. watershed segmentation :

enter image description here

+2

나는이 문제에 더 많은 시간을 할애했으면 좋겠다. 정말로 흥미있는 소리가 난다! 나는 이미지를 선명하게하는 것으로 시작하고 선을 탐지하려고 시도 할 것입니다. (허벅지 변환을 사용하여) 보통 스쿼 머를 분리하는 직선이있는 것처럼 보입니다. 블랙 스퀘어가 있기 때문에 이미지를 뒤집을만한 가치가있을 수도 있습니다. –

+0

라인 감지 사용을 고려하지 않았습니다!나는 시도와 업데이 트를 줄 것이다 :) Thanks @IvayloStrandjev – fersarr

+1

당신은 로컬 콘트라스트 향상 필터와 Canny 에지 검출 알고리즘을 시도 할 수있다. – MBo

답변

6

고려해야 할 하나 개의 경로가있다. 여기에 (당신은 IP 도구 상자를 가지고 가정) 첫 번째 이미지로 신속하고 더러운 예입니다 : 컬러 맵으로 표시

raw=rgb2gray(imread('lCeL8.jpg')); 

Icomp = imcomplement(raw); 
I3 = imhmin(Icomp,20); 
L = watershed(I3); 
%% 
imagesc(L); 
axis image 

결과 : 당신은 다음과 같은 세포를 셀 수

watershed

은 다음 : 장점

count = numel(unique(L)); 

하나는 직접 regionprops에 공급하고 당신에게 개인에 대한 모든 좋은 정보를 제공 할 수 있다는 것입니다 '비늘' bounding boxes

참고 : 당신이 사용할 수

r=regionprops(L, 'All'); 
imshow(raw); 

for k=2:numel(r) 
    if r(k).Area>100 % I chose 100 to filter out the objects with a small are. 
     rectangle('Position',r(k).BoundingBox, 'LineWidth',1, 'EdgeColor','b', 'Curvature', [1 1]); 
    end 
end 

이 세그먼트에서/이상 모니터링하는 특별한 감사를 r 구조 here의 필드에 적절한 접근 도와 @jucestain하기

+0

그것은 바닥 부분에서 특별히 더 잘 작동합니다! :) 고마워. 방금 해봤 어. – fersarr

+0

@fersarr 당신을 진심으로 환영합니다. 그건 그렇고, 내가 다른 게시물에 예제로 귀하의 이미지 중 하나를 사용 : http://stackoverflow.com/a/22818561/2777181 난 괜찮아 지길 바래. –

+1

괜찮습니다! 도마뱀을 유명하게 만드십시오! :) – fersarr