%% chdir /mas/vision/vismod/users/steve/mannfamily
if ~(exist('a') & exist('b'))
  %a=loadraw('mannfamily67',M,N);
  %b=loadraw('mannfamily66',M,N);
  imagepath = '/mas/disks/vision9/steve/flakes';
  a=loadppm([imagepath '/cement/mannfamily/mannfamily67g.pgm']);
  b=loadppm([imagepath '/cement/mannfamily/mannfamily66g.pgm']);
end%if

figure
tvs(a)
set(gcf,'Name','Image a')

figure
tvs(b)
set(gcf,'Name','Image b')

badb=sign(b-250.5)/2+1/2;
c=badb.*a+(1-badb)/3.5.*b;  % composite
%%clear a
%%clear b
%%clear badb

figure
tvs(c)
set(gcf,'Name','a and b combined using the Wyckoff principle')

c4=c.^(1/4);

p=path;
if isempty(findstr(p,'mallat'))
  path(p,'/mas/disks/vision9/steve/mallat/mallat2')
end%if

c4_und=undsamavg(c4);
tvs(c4_und);   % for figure; downsampled good for 85dpi, 4in col.
[M,N]=size(c4_und);
axis('off')
hlef=line([1,1],[1,M]);
hbot=line([1,N],[M,M]);
hrig=line([N,N],[M,1]);
htop=line([N,1],[1,1]);
% set border to white; will print as black
set(hlef,'color',[1 1 1])
set(hbot,'color',[1 1 1])
set(hrig,'color',[1 1 1])
set(htop,'color',[1 1 1])

fig_mannfamily_composite = gcf;
%% figure(fig_mannfamily_composite); print mannfamily_composite.eps -deps

badb_und = undsamavg(badb);
figure; tvs(badb_und)
axis('off')
hlef=line([1,1],[1,M]);
hbot=line([1,N],[M,M]);
hrig=line([N,N],[M,1]);
htop=line([N,1],[1,1]);
% set border to white; will print as black
set(hlef,'color',[1 1 1])
set(hbot,'color',[1 1 1])
set(hrig,'color',[1 1 1])
set(htop,'color',[1 1 1])

fig_badb = gcf;
%% figure(fig_badb); print mannfamily_badb.eps -deps

