>> clear
>> close all
>> clc
>> I = imread('C:\Temp\Universe.bmp');
>> g = rgb2gray(I);
>> bw = im2bw(g);
>> figure, imshow(bw);
>> bw2 = im2bw(g, 0.3);
>> bw1 = im2bw(g);
>> bw1 = ~bw1;
>> bw2 = ~bw2;
>> b1 = bwboundaries(bw1);
>> figure, imshow(bw1);
>> text(10,10,strcat('\color{green}Objects Found : ',num2str(length(b1))));
>> hold on
>> for k = 1:length(b1) ...
boundary1 = b1{k}; ...
plot(boundary1(:,2), boundary1(:,1), 'g', 'LineWidth', 0.2); ...
end
Universe
Binary (bw1)
Binary Boundary (bw1) found 808 objects
>> b2 = bwboundaries(bw2);
>> figure, imshow(bw2);
>> text(10,10,strcat('\color{red}Objects Found : ',num2str(length(b2))));
>> hold on
>> for k = 1:length(b2) ...
boundary2 = b2{k}; ...
plot(boundary2(:,2), boundary2(:,1), 'r', 'LineWidth', 0.2); ...
end
Binary (bw2)
Binary Boundary (bw2) found 1691 objects