maygapixel

Untitled

Dec 17th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.84 KB | None | 0 0
  1. img = imread('target.jpg');
  2. >> figure
  3. >> imshow(img);
  4. >> threshold = graythresh(img);
  5. >> bw = ~im2bw(img,threshold);
  6. >> bw = bwareaopen(bw, 40);
  7. >> figure
  8. >> imshow(bw)
  9. >> I = padarray(bw,[1 1],1,'pre');
  10. >> bw = imfill(I,'holes');
  11. >> bw = bw(3:end,3:end);
  12. >> figure
  13. >> imshow(bw);
  14. >> [CC,NUM] = bwlabel(bw,4)
  15. >> sizecell = regionprops(CC,'basic');
  16. >> cell= bwareaopen(bw,6000);
  17. >> st = imsubtract(bw,cell);
  18. >> normal = bwareaopen(st,2000);                
  19. >> small = imsubtract(logical(st),normal);
  20. >> [normal,num1] = bwlabel(normal);
  21. >> figure
  22. >> imshow(normal);
  23. >> title(['Normal size: ' num2str(num1) '']);
  24. >> [small,num2] = bwlabel(small);
  25. >> figure
  26. >> imshow(small);
  27. >> title(['Small size: ' num2str(num2) '']);
  28. >> [cell,num3] = bwlabel(cell);
  29. >> figure
  30. >> imshow(cell);
  31. >> title(['Two Cell: ' num2str(num3) '']);
Advertisement
Add Comment
Please, Sign In to add comment