% 
% Original image: http://media.cleveland.com/nationworld_impact/photo/don-blankenship-massey-energy-congressional-testimony-protesterjpg-c1cd111b960aafb6.jpg
% 
[r,g,b]=imread("/home/longa/www/research/MTR/blankenship.jpg");
d=size(r)
nrows=d(1)
ncols=d(2)
rows=[1:nrows];
cols=[1:ncols];
r=r(rows,cols);
g=g(rows,cols);
b=b(rows,cols);
% 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Parameters: 
%
Scale=2
Tongue=1
Power=2
% 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for N=0:19
  Scale=1+N/19
  rstart=130;
  cstart=60;
  mh=rstart+200-15
  mH=rstart+200+15
  ml=cstart+78
  mL=cstart+158
  for j=cstart+83:cstart+148
    jshift = j-(cstart+78);
    istart = round(rstart+200+8 - 10*jshift/80 + 10*((jshift-40.)/40)**2);
    iend   = round(10*Scale*sin(pi*jshift/80)**Power);
    for i=istart-iend:istart+iend
       r(i,j)=195;
       g(i,j)=0;
       b(i,j)=0;
    end
  end
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %Now I'll put the black of the mouth...
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  for j=cstart+98:cstart+138
    jshift = j-(cstart+78);
    istart = round(rstart+200+8 - 10*jshift/80 + 10*((jshift-40.)/40)**2);
    iend   = round( 2*Scale*sin(pi*jshift/80)**Power);
    for i=istart-iend:istart+iend
       r(i,j)=0;
       g(i,j)=0;
       b(i,j)=0;
    end
  end
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %If we need a tongue:
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  if (Tongue == 1)
     for j=cstart+108:cstart+128
	jshift = j-(cstart+78);
	istart = round(rstart+200+8 - 10*jshift/80 + 10*((jshift-40.)/40)**2);
	iend   = round( 2*Scale*sin(pi*jshift/80)**Power);
        for i=istart:istart+iend
	   r(i,j)=232;
	   g(i,j)=158;
	   b(i,j)=168;
	end
     end
  end
% imwrite(strcat("/tmp/Blankenship.",num2str(Scale),".",int2str(Tongue),".",int2str(Power),".","gif"),r,g,b)
  imwrite(strcat("Blankenship.",num2str(Scale),".",int2str(Tongue),".",int2str(Power),".","gif"),r,g,b)
end
