Lab 01 – Zliczanie komórek

f=imread(‚png’);
bf=im2bw(f ,graythresh(f) )
[junk threshold] = edge(I, ‚sobel’);
fudgeFactor = .5;
BWs = edge(I,’sobel’, threshold * fudgeFactor);
figure, imshow(BWs), title(‚binary gradient mask’);
se90 = strel(‚line’, 3, 90);
se0 = strel(‚line’, 3, 0);
BWsdil = imdilate(BWs, [se90 se0]);
figure, imshow(BWsdil), title(‚dilated gradient mask’);
BWdfill = imfill(BWsdil, ‚holes’);
figure, imshow(BWdfill);
title(‚binary image with filled holes’);
BWnobord = imclearborder(BWdfill, 4);
figure, imshow(BWnobord), title(‚cleared border image’);
seD = strel(‚diamond’,1);
BWfinal = imerode(BWnobord,seD);
BWfinal = imerode(BWfinal,seD);
figure, imshow(BWfinal), title(‚segmented image’);
BWoutline = bwperim(BWfinal);
Segout = I;
Segout(BWoutline) = 255;
figure, imshow(Segout), title(‚outlined original image’);
pepper2 = rgb2gray(peppers);
imshow(pepper2);
gearBW = (gearGray > 100); imshow(gearBW)
Small ex:
I = imread(‚coins.png’);
imshow(I);
bw = im2bw(I,graythresh(I));
figure,imshow(bw);
bw = imfill(bw,’holes’);
figure,imshow(bw);
L = bwlabel(bw);
obj1 = max(max(L))
stats = regionprops(L,’Basic’);
obj2 = numel(stats)