Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- img = imread('target.jpg');
- >> figure
- >> imshow(img);
- >> threshold = graythresh(img);
- >> bw = ~im2bw(img,threshold);
- >> bw = bwareaopen(bw, 40);
- >> figure
- >> imshow(bw)
- >> I = padarray(bw,[1 1],1,'pre');
- >> bw = imfill(I,'holes');
- >> bw = bw(3:end,3:end);
- >> figure
- >> imshow(bw);
- >> [CC,NUM] = bwlabel(bw,4)
- >> sizecell = regionprops(CC,'basic');
- >> cell= bwareaopen(bw,6000);
- >> st = imsubtract(bw,cell);
- >> normal = bwareaopen(st,2000);
- >> small = imsubtract(logical(st),normal);
- >> [normal,num1] = bwlabel(normal);
- >> figure
- >> imshow(normal);
- >> title(['Normal size: ' num2str(num1) '']);
- >> [small,num2] = bwlabel(small);
- >> figure
- >> imshow(small);
- >> title(['Small size: ' num2str(num2) '']);
- >> [cell,num3] = bwlabel(cell);
- >> figure
- >> imshow(cell);
- >> title(['Two Cell: ' num2str(num3) '']);
Advertisement
Add Comment
Please, Sign In to add comment