function nshow (I,s,sx,sy)

# Usage: nshow (I,s,sx,sy)
# interface to imshow, output values in [0,1] interval
# if 2nd argument present, it is used as template for the dimensions
# with more arguments it selects a range (not really useful)

  if(nargin ==2)
	imshow(reshape(I,size(s))+0.5);
  elseif(nargin>2) 
	imshow( I((1:s)+sx-s/2,(1:s)+sy-s/2) + 0.5 );
  else imshow( I + 0.5 );
  endif;
endfunction

# other show functions, seldom used
function argshow (I)
  imshow( arg(I)/7 + 0.5 );
endfunction
function logshow (I)
  imshow( log(I)/7  );
endfunction
function ifftshow (If)
  imshow(ifftshift(ifft2(fftshift(If))+0.5));
endfunction

function cshow(Ipf)
# cshow function encodes complex numbers in color
  [Ipsx,Ipsy]=size(Ipf);
  Ihsv = ones(Ipsx,Ipsy,3);
  Ipfl = log(Ipf);
  mmax= max(max(real(Ipfl)));
  mmin= min(min(real(Ipfl)));
  if( mmin < 0 ) mmin=0; endif
  Ihsv(:,:,1) = imag(Ipfl)/pi*0.5+0.5;
  Ihsv(:,:,3) = (real(Ipfl)-mmin)/(mmax-mmin);
  Ihsv(Ihsv<0)=0; Ihsv(Ihsv>1)=1;
  imshow(hsv2rgb(Ihsv));
endfunction

# making images larger or smaller
function Iw = widen(I,n=20,v=0)
  [Isx,Isy]=size(I);
  Iw= [v*ones(n,2*n+Isy);v*ones(Isx,n),I,v*ones(Isx,n);v*ones(n,2*n+Isy)];
endfunction
function In = narrow(Iw,I)
  [Isx,Isy]=size(I);
  [Iwsx,Iwsy]=size(Iw);
  In= Iw(floor((Iwsx-Isx)/2)+(1:Isx),floor((Iwsy-Isy)/2)+(1:Isy));
endfunction
