Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Matlab
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:
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 25-Apr-12 18:37pm
Edited 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)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 367
1 Abhinav S 226
2 thatraja 220
3 OriginalGriff 195
4 Peter Leow 160
0 Sergey Alexandrovich Kryukov 8,849
1 OriginalGriff 5,035
2 Peter Leow 3,949
3 Maciej Los 3,535
4 Abhinav S 3,148


Advertise | Privacy | Mobile
Web03 | 2.8.140415.2 | Last Updated 26 Apr 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid