Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Overview of the project:
To count particle in the DNA-DSB using Robert's edge detector.
I looked on the internet and found a code mentioned below. Please check this code and let me know if it is correct.

code:
C#
i = imread('particle.jpg');
I = rgb2gray(i);
BW3= edge(I,'roberts');
subplot (2,2,1);
imshow(I);
title('original');
subplot(2,2,2); 
imshow(BW1);
imshow(BW3); 
title('Roberts'); 
Read particle.jpg.
RGB = imread('particle.jpg');
imshow(RGB);
I = rgb2gray(RGB);
threshold = graythresh(I);
bw = im2bw(I,threshold);
imshow(bw)
bw = bwareaopen(bw,30);
 
se = strel('disk',2);
bw = imclose(bw,se);
bw = imfill(bw,'holes');
 
imshow(bw)
[B,L] = bwboundaries(bw,'noholes');
 
imshow(label2rgb(L, @jet, [.5 .5 .5]))
hold on
for k = 1:length(B)
  boundary = B{k};
  plot(boundary(:,2), boundary(:,1), 'w', 'LineWidth', 2)
end
metric = 4*pi*area/perimeter^2.
stats = regionprops(L,'Area','Centroid');
 
threshold = 0.94;
 
for k = 1:length(B)
 
  boundary = B{k};
 
  
  delta_sq = diff(boundary).^2;
  perimeter = sum(sqrt(sum(delta_sq,2)));
 
  area = stats(k).Area;
 
    metric = 4*pi*area/perimeter^2;
 
    metric_string = sprintf('%2.2f',metric);
 
    if metric > threshold
    centroid = stats(k).Centroid;
    plot(centroid(1),centroid(2),'ko');
  end
 
  text(boundary(1,2)-35,boundary(1,1)+13,metric_string,'Color','y',...
       'FontSize',14,'FontWeight','bold');
 
end
 
title(['Metrics closer to 1 indicate that ',...
       'the object is approximately round']);
Posted
Updated 25-Apr-12 18:56pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900