function [G Y]= delEcmc(gren, yelow, laf) %D7

greenl = rgb2lab(gren);
yellowl = rgb2lab(yelow);
leafl = rgb2lab(laf);

% 
% green= meanCircle(greenl);
% yellow= meanCircle(yellowl);
% leaf = mean_leaf(leafl);

green = LabToLch(greenl);
yellow = LabToLch(yellowl);
leaf = LabToLch(leafl);


f= sqrt(green(2)^4 /(green(2)^4 +1900));

if(green(3) >= 164 && green(3)<=345)
    t= 0.56+ 0.2*cosd(green(3)+168);
else
    t= 0.36+ 0.4*cosd(green(3)+35);
end

if (green(1)<16)
    sl= 0.511;
else
    sl = (0.040975*green(1)) / (1+ 0.01765*green(1))   ;
end
sc= (0.0698*green(2))/ (1+ 0.0131*green(2)) +0.638;
sh= sc* (f*t +1-f);

c1g = sqrt(greenl(2)+greenl(3));
c2g = sqrt(leafl(2)+leafl(3));
deltac = c1g-c2g;
delhg= sqrt((leaf(2) - green(2))^2 +(leaf(3) - green(3))^2 - deltac^2 );
d1= sqrt(((leaf(1)-green(1))/sl)^2 + ((leaf(2)-green(2))/sc) + (delhg/sh)^2);

f2= sqrt(yellow(2)^4 /(yellow(2)^4 +1900));

if(yellow(3) >= 164 && yellow(3)<=345)
    t2= 0.56+ 0.2*cosd(yellow(3)+168);
else
    t2= 0.36+ 0.4*cosd(yellow(3)+35);
end

if (yellow(1)<16)
    sl= 0.511;
else
    sl = (0.040975*yellow(1)) / (1+ 0.01765*yellow(1))   ;
end
sc= (0.0698*yellow(2))/ (1+ 0.0131*yellow(2)) +0.638;
sh= sc* (f2*t2 +1-f2);

c1y = sqrt(yellowl(2)+yellowl(3));
c2y = sqrt(leafl(2)+leafl(3));
deltac = c1y-c2y;
delhy= sqrt((leaf(2) - yellow(2))^2 +(leaf(3) - yellow(3))^2 - deltac^2 );
d2= sqrt(((leaf(1)-yellow(1))/sl)^2 + ((leaf(2)-yellow(2))/sc) + (delhy/sh)^2);


G = 100 *(1- (d1/ (d1+d2)));       %Green percentage
Y = 100 *(1- (d2/(d1+d2)));        %Yellow percentage



