Created
September 4, 2020 11:35
-
-
Save ehzawad/19ddb3b11d5844b41cc779e72f1f1328 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clc | |
clear all | |
close all | |
I = imread('/Users/ehzawad/Desktop/footBall_orig.jpg'); | |
% I = imread('peppers.png'); | |
Im = rgb2gray(I); | |
% disp(Im); | |
% I = imread('bag.png'); | |
% | |
% figure, subplot(2,2,1), imshow(I), title('Original Image'); | |
% [I_prw1,t1] = edge(I,'Canny'); % % sobel prewitt Roberts log zerocross Canny | |
% subplot(2,2,2), imshow(I_prw1); | |
% I_noise = imnoise(I,'gaussian'); | |
% % [I_prw2,t2] = edge(I_noise,'Canny'); % sobel prewitt Roberts log zerocross Canny | |
% [I_prw2,t2] = edge(I_noise,'Canny', [], 2.5); % sobel prewitt Roberts log zerocross Canny | |
% subplot(2,2,3), imshow(I_noise); | |
% subplot(2,2,4), imshow(I_prw2); | |
th = .50; | |
% I_bw = im2bw(I,.5); | |
% I_bw = imbinarize(I, 0.5); | |
% iteration = 1000; | |
flattenImage = Im(:); | |
% disp(flattenImage); | |
% iteration = length(I_bw); | |
for i = 1 : iteration | |
%first segment or piece | |
disp(th); | |
G1 = flattenImage > th; | |
disp(G1); | |
G2 = flattenImage <= th; | |
disp(G2); | |
median = (mean(G1) + mean(G2))/ 2; | |
% disp(median); | |
if (abs(median - th) <= 0.001) | |
break | |
end | |
th = median; | |
% disp(th); | |
end | |
newEstimated = im2bw(I, th); | |
imshow(newEstimated); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment