changeset 10912:ad0fea7c13e1 octave-forge

image: use spaces, not tabs
author carandraug
date Mon, 24 Sep 2012 12:59:10 +0000
parents 7570c0be5a3f
children 91c1311b3623
files main/image/devel/__conditional_mark_patterns_lut_fun__.m main/image/inst/blockproc.m main/image/inst/bmpwrite.m main/image/inst/corr2.m main/image/inst/fspecial.m main/image/inst/hough_circle.m main/image/inst/imrotate_Fourier.m main/image/inst/imshear.m main/image/inst/imtranslate.m main/image/inst/nlfilter.m main/image/inst/poly2mask.m main/image/inst/readexif.m main/image/src/deriche.cc
diffstat 13 files changed, 272 insertions(+), 283 deletions(-) [+]
line wrap: on
line diff
--- a/main/image/devel/__conditional_mark_patterns_lut_fun__.m	Mon Sep 24 12:26:35 2012 +0000
+++ b/main/image/devel/__conditional_mark_patterns_lut_fun__.m	Mon Sep 24 12:59:10 2012 +0000
@@ -76,7 +76,7 @@
   if(any(op=='ST'))
     m|=(sx==4)&&((x0&&x2&&x3)||(x0&&x2&&x7)||(x1&&x2&&x4)||(x0&&x1&&x6)); ## bond 5
     m|=(sx==4)&&((x0&&x1&&x2)||(x2&&x3&&x4)||(x4&&x5&&x6)||(x6&&x7&&x0)); ## bond 5
-    m|=(sx==5)&&((x0&&x2&&x3&&x7)||(x1&&x2&&x4&&x5)); ## bond 6	
+    m|=(sx==5)&&((x0&&x2&&x3&&x7)||(x1&&x2&&x4&&x5)); ## bond 6
   endif
 
   if(any(op=='STK'))
@@ -85,13 +85,13 @@
            (all(X(1,:))&&(x0||x4)) || \
            (all(X(:,3))&&(x2||x6)) || \
            (all(X(:,1))&&(x2||x6)) || \
-   	   (all(X(3,:))&&(x0||x4)) );
+           (all(X(3,:))&&(x0||x4)) );
     m|=(sx==6)&&( !(x4||x5||x6) || !(x6||x7||x0) || !(x0||x1||x2) || \
-		 !(x2||x3||x4) ); ## bond 7
+     !(x2||x3||x4) ); ## bond 7
     m|=(sx==6)&&( !any(X(:,1)) || !any(X(3,:)) || !any(X(:,3)) || \
-		 !any(X(1,:)) ); ## bond 8
+     !any(X(1,:)) ); ## bond 8
     m|=(sx==7)&&( !(x4||(x3&&x5)) || !(x6||(x5&&x7)) || \
-		 !(x0||(x7&&x1)) || !(x2||(x1&&x3)) ); ## bond 9
+     !(x0||(x7&&x1)) || !(x2||(x1&&x3)) ); ## bond 9
     m|=(sx==8)&&( !x0 || !x2 || !x4 || !x6 ); ## bond 10
   endif
 
@@ -105,13 +105,3 @@
 
 %!# We'll only check if number of hits is ok.
 %!assert(sum(makelut("__conditional_mark_patterns_lut_fun__",3,"S")), 58);
-
-%
-% $Log$
-% Revision 1.2  2007/03/23 16:14:36  adb014
-% Update the FSF address
-%
-% Revision 1.1  2004/08/16 14:42:02  jmones
-% Functions used to code bwmorph
-%
-%
--- a/main/image/inst/blockproc.m	Mon Sep 24 12:26:35 2012 +0000
+++ b/main/image/inst/blockproc.m	Mon Sep 24 12:59:10 2012 +0000
@@ -58,7 +58,7 @@
     indexed=true;
     p+=1;
     if(isa(A,"uint8") || isa(A,"uint16"))
-	padval=0;
+      padval=0;
     else
       padval=1; 
     endif
--- a/main/image/inst/bmpwrite.m	Mon Sep 24 12:26:35 2012 +0000
+++ b/main/image/inst/bmpwrite.m	Mon Sep 24 12:59:10 2012 +0000
@@ -57,9 +57,9 @@
 
     if rows(map) > 256, 
       bmpwrite_truecolor(reshape(map(x,1),size(x))*255,
-			 reshape(map(x,2),size(x))*255,
-			 reshape(map(x,3),size(x))*255,
-			 file);
+                         reshape(map(x,2),size(x))*255,
+                         reshape(map(x,3),size(x))*255,
+                         file);
       return;
     endif
     [h,w] = size(x);
--- a/main/image/inst/corr2.m	Mon Sep 24 12:26:35 2012 +0000
+++ b/main/image/inst/corr2.m	Mon Sep 24 12:59:10 2012 +0000
@@ -28,7 +28,7 @@
   endif
 
   if (!(ismatrix (I) && isreal (I) && ismatrix (J) && isreal (J)))
-	error ("corr2: argument must be a real type matrix");
+    error ("corr2: argument must be a real type matrix");
   endif
 
   if (!size_equal (I, J))
--- a/main/image/inst/fspecial.m	Mon Sep 24 12:26:35 2012 +0000
+++ b/main/image/inst/fspecial.m	Mon Sep 24 12:59:10 2012 +0000
@@ -210,7 +210,7 @@
       else
         angle = 0;
       endif
-	    
+      
       ## First generate a horizontal line across the middle
       f = zeros (sze);
       f (floor (len/2)+1, 1:len) = 1;
--- a/main/image/inst/hough_circle.m	Mon Sep 24 12:26:35 2012 +0000
+++ b/main/image/inst/hough_circle.m	Mon Sep 24 12:59:10 2012 +0000
@@ -57,7 +57,7 @@
   ## Iterate over different radius
   for j = 1:length(r)
     rad = r(j);
-	
+
     ## Compute a filter containing the circle we're looking for.
     circ = circle(rad);
 
--- a/main/image/inst/imrotate_Fourier.m	Mon Sep 24 12:26:35 2012 +0000
+++ b/main/image/inst/imrotate_Fourier.m	Mon Sep 24 12:59:10 2012 +0000
@@ -43,128 +43,128 @@
       error("imrotate_Fourier: second input argument must be a real scalar");
     endif
 
-	# Get original dimensions.
-	[ydim_orig, xdim_orig] = size(f);
+    # Get original dimensions.
+    [ydim_orig, xdim_orig] = size(f);
 
-	# This finds the index coords of the centre of the image (indices are base-1)
-	#   eg. if xdim_orig=8, then xcentre_orig=4.5 (half-way between 1 and 8)
-	xcentre_orig = (xdim_orig+1) / 2;
-	ycentre_orig = (ydim_orig+1) / 2;
+    # This finds the index coords of the centre of the image (indices are base-1)
+    #   eg. if xdim_orig=8, then xcentre_orig=4.5 (half-way between 1 and 8)
+    xcentre_orig = (xdim_orig+1) / 2;
+    ycentre_orig = (ydim_orig+1) / 2;
 
-	# Pre-process the angle ===========================================================
-	# Whichever 90 degree multiple theta is closest to, that multiple of 90 will
-	# be implemented by rot90. The remainder will be done by shears.
+    # Pre-process the angle ===========================================================
+    # Whichever 90 degree multiple theta is closest to, that multiple of 90 will
+    # be implemented by rot90. The remainder will be done by shears.
 
-	# This ensures that 0 <= theta < 360.
-	theta = rem( rem(theta,360) + 360, 360 );
+    # This ensures that 0 <= theta < 360.
+    theta = rem( rem(theta,360) + 360, 360 );
 
-	# This is a flag to keep track of 90-degree rotations.
-	perp = 0;
+    # This is a flag to keep track of 90-degree rotations.
+    perp = 0;
 
-	if ( theta>=0 && theta<=45 )
-		phi = theta;
-	elseif ( theta>45 && theta<=135 )
-		phi = theta - 90;
-		f = rot90(f,1);
-		perp = 1;
-	elseif ( theta>135 && theta<=225 )
-		phi = theta - 180;
-		f = rot90(f,2);
-	elseif ( theta>225 && theta<=315 )
-		phi = theta - 270;
-		f = rot90(f,3);
-		perp = 1;
-	else
-		phi = theta;
-	endif
+    if ( theta>=0 && theta<=45 )
+        phi = theta;
+    elseif ( theta>45 && theta<=135 )
+        phi = theta - 90;
+        f = rot90(f,1);
+        perp = 1;
+    elseif ( theta>135 && theta<=225 )
+        phi = theta - 180;
+        f = rot90(f,2);
+    elseif ( theta>225 && theta<=315 )
+        phi = theta - 270;
+        f = rot90(f,3);
+        perp = 1;
+    else
+        phi = theta;
+    endif
 
 
 
-	if ( phi == 0 )
-		fs = f;
-		if ( strcmp(bbox,"loose") == 1 )
-			return;
-		else
-			xmax = xcentre_orig;
-			ymax = ycentre_orig;
-			if ( perp == 1 )
-				xmax = max([xmax ycentre_orig]);
-				ymax = max([ymax xcentre_orig]);
-				[ydim xdim] = size(fs);
-				xpad = ceil( xmax - (xdim+1)/2 );
-				ypad = ceil( ymax - (ydim+1)/2 );
-				fs = impad(fs, [xpad,xpad], [ypad,ypad], "zeros");
-			endif
-			xcentre_new = (size(fs,2)+1) / 2;
-			ycentre_new = (size(fs,1)+1) / 2;
-		endif
-	else
+    if ( phi == 0 )
+        fs = f;
+        if ( strcmp(bbox,"loose") == 1 )
+            return;
+        else
+            xmax = xcentre_orig;
+            ymax = ycentre_orig;
+            if ( perp == 1 )
+                xmax = max([xmax ycentre_orig]);
+                ymax = max([ymax xcentre_orig]);
+                [ydim xdim] = size(fs);
+                xpad = ceil( xmax - (xdim+1)/2 );
+                ypad = ceil( ymax - (ydim+1)/2 );
+                fs = impad(fs, [xpad,xpad], [ypad,ypad], "zeros");
+            endif
+            xcentre_new = (size(fs,2)+1) / 2;
+            ycentre_new = (size(fs,1)+1) / 2;
+        endif
+    else
 
-		# At this point, we can assume -45<theta<45 (degrees)
+        # At this point, we can assume -45<theta<45 (degrees)
 
-		phi = phi * pi / 180;
-		theta = theta * pi / 180;
-		R = [ cos(theta) -sin(theta) ; sin(theta) cos(theta) ];
+        phi = phi * pi / 180;
+        theta = theta * pi / 180;
+        R = [ cos(theta) -sin(theta) ; sin(theta) cos(theta) ];
 
-		# Find max of each dimension... this will be expanded for "loose" and "crop"
-		xmax = xcentre_orig;
-		ymax = ycentre_orig;
+        # Find max of each dimension... this will be expanded for "loose" and "crop"
+        xmax = xcentre_orig;
+        ymax = ycentre_orig;
 
-		# If we don't want wrapping, we have to zeropad.
-		# Cropping will be done later, if necessary.
-		if ( strcmp(bbox, "wrap") == 0 )
-			corners = ( [ xdim_orig xdim_orig -xdim_orig -xdim_orig ; ydim_orig -ydim_orig ydim_orig -ydim_orig ] + 1 )/ 2;
-			rot_corners = R * corners;
-			xmax = max([xmax rot_corners(1,:)]);
-			ymax = max([ymax rot_corners(2,:)]);
+        # If we don't want wrapping, we have to zeropad.
+        # Cropping will be done later, if necessary.
+        if ( strcmp(bbox, "wrap") == 0 )
+            corners = ( [ xdim_orig xdim_orig -xdim_orig -xdim_orig ; ydim_orig -ydim_orig ydim_orig -ydim_orig ] + 1 )/ 2;
+            rot_corners = R * corners;
+            xmax = max([xmax rot_corners(1,:)]);
+            ymax = max([ymax rot_corners(2,:)]);
 
-			# If we are doing a 90-degree rotation first, we need to make sure our
-			# image is large enough to hold the rot90 image as well.
-			if ( perp == 1 )
-				xmax = max([xmax ycentre_orig]);
-				ymax = max([ymax xcentre_orig]);
-			endif
+            # If we are doing a 90-degree rotation first, we need to make sure our
+            # image is large enough to hold the rot90 image as well.
+            if ( perp == 1 )
+                xmax = max([xmax ycentre_orig]);
+                ymax = max([ymax xcentre_orig]);
+            endif
 
-			[ydim xdim] = size(f);
-			xpad = ceil( xmax - xdim/2 );
-			ypad = ceil( ymax - ydim/2 );
-			%f = impad(f, [xpad,xpad], [ypad,ypad], "zeros");
-			xcentre_new = (size(f,2)+1) / 2;
-			ycentre_new = (size(f,1)+1) / 2;
-		endif
+            [ydim xdim] = size(f);
+            xpad = ceil( xmax - xdim/2 );
+            ypad = ceil( ymax - ydim/2 );
+            %f = impad(f, [xpad,xpad], [ypad,ypad], "zeros");
+            xcentre_new = (size(f,2)+1) / 2;
+            ycentre_new = (size(f,1)+1) / 2;
+        endif
 
-		#size(f)
-		[S1, S2] = MakeShears(phi);
+        #size(f)
+        [S1, S2] = MakeShears(phi);
 
-		tic;
-		f1 = imshear(f, 'x', S1(1,2), 'loose');
-		f2 = imshear(f1, 'y', S2(2,1), 'loose');
-		fs = real( imshear(f2, 'x', S1(1,2), 'loose') );
-		%fs = f2;
-		xcentre_new = (size(fs,2)+1) / 2;
-		ycentre_new = (size(fs,1)+1) / 2;
-	endif
+        tic;
+        f1 = imshear(f, 'x', S1(1,2), 'loose');
+        f2 = imshear(f1, 'y', S2(2,1), 'loose');
+        fs = real( imshear(f2, 'x', S1(1,2), 'loose') );
+        %fs = f2;
+        xcentre_new = (size(fs,2)+1) / 2;
+        ycentre_new = (size(fs,1)+1) / 2;
+    endif
 
-	if ( strcmp(bbox, "crop") == 1 )
+    if ( strcmp(bbox, "crop") == 1 )
 
-		# Crop to original dimensions
-		x1 = ceil (xcentre_new - xdim_orig/2);
-		y1 = ceil (ycentre_new - ydim_orig/2);
-		fs = fs (y1:(y1+ydim_orig-1), x1:(x1+xdim_orig-1));
+        # Crop to original dimensions
+        x1 = ceil (xcentre_new - xdim_orig/2);
+        y1 = ceil (ycentre_new - ydim_orig/2);
+        fs = fs (y1:(y1+ydim_orig-1), x1:(x1+xdim_orig-1));
 
-	elseif ( strcmp(bbox, "loose") == 1 )
+    elseif ( strcmp(bbox, "loose") == 1 )
 
-		# Find tight bounds on size of rotated image
-		# These should all be positive, or 0.
-		xmax_loose = ceil( xcentre_new + max(rot_corners(1,:)) );
-		xmin_loose = floor( xcentre_new - max(rot_corners(1,:)) );
-		ymax_loose = ceil( ycentre_new + max(rot_corners(2,:)) );
-		ymin_loose = floor( ycentre_new - max(rot_corners(2,:)) );
+        # Find tight bounds on size of rotated image
+        # These should all be positive, or 0.
+        xmax_loose = ceil( xcentre_new + max(rot_corners(1,:)) );
+        xmin_loose = floor( xcentre_new - max(rot_corners(1,:)) );
+        ymax_loose = ceil( ycentre_new + max(rot_corners(2,:)) );
+        ymin_loose = floor( ycentre_new - max(rot_corners(2,:)) );
 
-		%fs = fs( (ymin_loose+1):(ymax_loose-1) , (xmin_loose+1):(xmax_loose-1) );
-		fs = fs( (ymin_loose+1):(ymax_loose-1) , (xmin_loose+1):(xmax_loose-1) );
+        %fs = fs( (ymin_loose+1):(ymax_loose-1) , (xmin_loose+1):(xmax_loose-1) );
+        fs = fs( (ymin_loose+1):(ymax_loose-1) , (xmin_loose+1):(xmax_loose-1) );
 
-	endif
+    endif
 
     ## Prevent overshooting
     if (strcmp(class(f), "double"))
--- a/main/image/inst/imshear.m	Mon Sep 24 12:26:35 2012 +0000
+++ b/main/image/inst/imshear.m	Mon Sep 24 12:59:10 2012 +0000
@@ -44,83 +44,83 @@
 
 function g = imshear(m, axis, alpha, bbox, noshift)
 
-	# The code below only does y-shearing. This is because of
-	# the implementation of fft (operates on columns, but not rows).
-	# So, transpose first for x-shearing.
-	if ( strcmp(axis, "x")==1 )
-		m = m';
-	endif
+  # The code below only does y-shearing. This is because of
+  # the implementation of fft (operates on columns, but not rows).
+  # So, transpose first for x-shearing.
+  if ( strcmp(axis, "x")==1 )
+    m = m';
+  endif
 
-	if ( nargin < 4 )
-		bbox = "loose";
-		noshift = 0;
-	elseif ( nargin < 5 )
-		noshift = 0;
-	endif
+  if ( nargin < 4 )
+    bbox = "loose";
+    noshift = 0;
+  elseif ( nargin < 5 )
+    noshift = 0;
+  endif
 
-	[ydim_orig xdim_orig] = size(m);
-	if ( strcmp(bbox, "wrap") == 0 )
-		ypad = ceil( (xdim_orig+1)/2 * abs(alpha) );
-		m = impad(m, [0,0], [ypad,ypad]);
-	endif
+  [ydim_orig xdim_orig] = size(m);
+  if ( strcmp(bbox, "wrap") == 0 )
+    ypad = ceil( (xdim_orig+1)/2 * abs(alpha) );
+    m = impad(m, [0,0], [ypad,ypad]);
+  endif
 
-	[ydim_new xdim_new] = size(m);
-	xcentre = ( xdim_new + 1 ) / 2;
-	ycentre = ( ydim_new + 1 ) / 2;
+  [ydim_new xdim_new] = size(m);
+  xcentre = ( xdim_new + 1 ) / 2;
+  ycentre = ( ydim_new + 1 ) / 2;
 
-	# This applies FFT to columns of m (x-axis remains a spatial axis).
-	# Because the way that fft and fftshift are implemented, the origin
-	# will move by 1/2 pixel, depending on the polarity of the image
-	# dimensions.
-	#
-	# If dim is even (=2n), then the origin of the fft below is located
-	# at the centre of pixel (n+1). ie. if dim=16, then centre is at 9.
-	#
-	# If dim is odd (=2n+1), then the origin of the fft below is located
-	# at the centre of pixel (n). ie. if dim=15, then centre is at 8.
-	if ( noshift==1 )
-		M = fft(m);
-	else
-		#M = imtranslate(fft(imtranslate(m, -xcentre, ycentre, "wrap")), xcentre, -ycentre, "wrap");
-		M = fftshift(fft(fftshift(m)));
-	endif
+  # This applies FFT to columns of m (x-axis remains a spatial axis).
+  # Because the way that fft and fftshift are implemented, the origin
+  # will move by 1/2 pixel, depending on the polarity of the image
+  # dimensions.
+  #
+  # If dim is even (=2n), then the origin of the fft below is located
+  # at the centre of pixel (n+1). ie. if dim=16, then centre is at 9.
+  #
+  # If dim is odd (=2n+1), then the origin of the fft below is located
+  # at the centre of pixel (n). ie. if dim=15, then centre is at 8.
+  if ( noshift==1 )
+    M = fft(m);
+  else
+    #M = imtranslate(fft(imtranslate(m, -xcentre, ycentre, "wrap")), xcentre, -ycentre, "wrap");
+    M = fftshift(fft(fftshift(m)));
+  endif
 
-	[ydim xdim] = size(m);
-	x = zeros(ydim, xdim);
+  [ydim xdim] = size(m);
+  x = zeros(ydim, xdim);
 
-	# Find coords of the origin of the image.
-	if ( noshift==1 )
-		xc_coord = 1;
-		yc_coord = 1;
-		l = (1:ydim)' - yc_coord;
-		r = (1:xdim) - xc_coord;
-		if ( strcmp(bbox, "wrap")==1 )
-			l((ydim/2):ydim) = l((ydim/2):ydim) - ydim;
-			r((xdim/2):xdim) = r((xdim/2):xdim) - xdim;
-		endif
-	else
-		xc_coord = (xdim+1)/2;
-		yc_coord = (ydim+1)/2;
-		l = (1:ydim)' - yc_coord;
-		r = (1:xdim) - xc_coord;
-	endif
-	x = l * r;
+  # Find coords of the origin of the image.
+  if ( noshift==1 )
+    xc_coord = 1;
+    yc_coord = 1;
+    l = (1:ydim)' - yc_coord;
+    r = (1:xdim) - xc_coord;
+    if ( strcmp(bbox, "wrap")==1 )
+      l((ydim/2):ydim) = l((ydim/2):ydim) - ydim;
+      r((xdim/2):xdim) = r((xdim/2):xdim) - xdim;
+    endif
+  else
+    xc_coord = (xdim+1)/2;
+    yc_coord = (ydim+1)/2;
+    l = (1:ydim)' - yc_coord;
+    r = (1:xdim) - xc_coord;
+  endif
+  x = l * r;
 
-	Ms = M.* exp(2*pi*I*alpha/ydim * x);
+  Ms = M.* exp(2*pi*I*alpha/ydim * x);
 
-	if ( noshift==1 )
-		g = abs(ifft(Ms));
-	else
-		#g = abs(imtranslate( ifft( imtranslate(Ms, -xcentre, ycentre, "wrap") ), xcentre, -ycentre, "wrap"));
-		g = abs( fftshift(ifft(ifftshift(Ms))) );
-	endif
+  if ( noshift==1 )
+    g = abs(ifft(Ms));
+  else
+    #g = abs(imtranslate( ifft( imtranslate(Ms, -xcentre, ycentre, "wrap") ), xcentre, -ycentre, "wrap"));
+    g = abs( fftshift(ifft(ifftshift(Ms))) );
+  endif
 
-	if ( strcmp(bbox, "crop")==1 )
-		g = g(ypad+1:ydim_orig+ypad, :);
-	endif
+  if ( strcmp(bbox, "crop")==1 )
+    g = g(ypad+1:ydim_orig+ypad, :);
+  endif
 
-	# Un-transpose if x-shearing was wanted
-	if ( strcmp(axis, "x")==1 )
-		g = g';
-	endif
+  # Un-transpose if x-shearing was wanted
+  if ( strcmp(axis, "x")==1 )
+    g = g';
+  endif
 endfunction
--- a/main/image/inst/imtranslate.m	Mon Sep 24 12:26:35 2012 +0000
+++ b/main/image/inst/imtranslate.m	Mon Sep 24 12:59:10 2012 +0000
@@ -26,45 +26,45 @@
 
 function Y = imtranslate(X, a, b, bbox_in)
 
-	bbox = "wrap";
-	if ( nargin > 3 )
-		bbox = bbox_in;
-	endif
+  bbox = "wrap";
+  if ( nargin > 3 )
+    bbox = bbox_in;
+  endif
 
-	if ( strcmp(bbox, "crop")==1 )
+  if ( strcmp(bbox, "crop")==1 )
 
-		xpad = [0,0];
-		if (a>0)
-			xpad = [0,ceil(a)];
-		elseif (a<0)
-			xpad = [-ceil(a),0];
-		endif
+    xpad = [0,0];
+    if (a>0)
+      xpad = [0,ceil(a)];
+    elseif (a<0)
+      xpad = [-ceil(a),0];
+    endif
 
-		ypad = [0,0];
-		if (b>0)
-			ypad = [ceil(b),0];
-		elseif (b<0)
-			ypad = [0,-ceil(b)];
-		endif
+    ypad = [0,0];
+    if (b>0)
+      ypad = [ceil(b),0];
+    elseif (b<0)
+      ypad = [0,-ceil(b)];
+    endif
 
-		X = impad(X, xpad, ypad, 'zeros');
-	endif
+    X = impad(X, xpad, ypad, 'zeros');
+  endif
 
 
-	[dimy, dimx] = size(X);
-	x = fft2(X);
-	px = exp(-2*pi*i*a*(0:dimx-1)/dimx);
-	py = exp(-2*pi*i*b*(0:dimy-1)/dimy)'; 	% actually to correspond to index notation 'b' should be
-						% replaced with '-b'
-						% but I do not want to brake previous version compatibility
-						% note: it also must be done in the cropping iand padding code
-	P = py * px;
-	y = x .* P;
-	Y = real(ifft2(y)); 	% fft return complex number
-				% for integer shifts imaginary part  is 0 
-				% so real takes care of transfer from complex number to real
+  [dimy, dimx] = size(X);
+  x = fft2(X);
+  px = exp(-2*pi*i*a*(0:dimx-1)/dimx);
+  py = exp(-2*pi*i*b*(0:dimy-1)/dimy)';   % actually to correspond to index notation 'b' should be
+                                          % replaced with '-b'
+                                          % but I do not want to brake previous version compatibility
+                                          % note: it also must be done in the cropping iand padding code
+  P = py * px;
+  y = x .* P;
+  Y = real(ifft2(y));   % fft return complex number
+                        % for integer shifts imaginary part  is 0 
+                        % so real takes care of transfer from complex number to real
 
-	if ( strcmp(bbox, "crop")==1 )
-		Y = Y(  ypad(1)+1:dimy-ypad(2) , xpad(1)+1:dimx-xpad(2));
-	endif
+  if ( strcmp(bbox, "crop")==1 )
+    Y = Y(ypad(1)+1:dimy-ypad(2) , xpad(1)+1:dimx-xpad(2));
+  endif
 endfunction
--- a/main/image/inst/nlfilter.m	Mon Sep 24 12:26:35 2012 +0000
+++ b/main/image/inst/nlfilter.m	Mon Sep 24 12:59:10 2012 +0000
@@ -129,7 +129,7 @@
 
 %!demo
 %! nlfilter(eye(10),[3,3],inline("any(x(:)>0)","x"))
-%! # creates a "wide" diagonal	
+%! # creates a "wide" diagonal
 
 %!assert(nlfilter(eye(4),[2,3],inline("sum(x(:))","x")),[2,2,1,0;1,2,2,1;0,1,2,2;0,0,1,1]);
 %!assert(nlfilter(eye(4),'indexed',[2,3],inline("sum(x(:))","x")),[4,2,1,2;3,2,2,3;2,1,2,4;4,3,4,5]);
--- a/main/image/inst/poly2mask.m	Mon Sep 24 12:26:35 2012 +0000
+++ b/main/image/inst/poly2mask.m	Mon Sep 24 12:59:10 2012 +0000
@@ -129,7 +129,7 @@
       ie = ie (:, (ie (1, :) <= n));
       ie = ie (:, (ie (2, :) >= 1));
       for i = 1:columns (ie)
-	BW (sl, ie (1, i):ie (2, i)) = true;
+        BW (sl, ie (1, i):ie (2, i)) = true;
       endfor
     endif
 
--- a/main/image/inst/readexif.m	Mon Sep 24 12:26:35 2012 +0000
+++ b/main/image/inst/readexif.m	Mon Sep 24 12:59:10 2012 +0000
@@ -72,13 +72,13 @@
     switch s
       case JPEG.SOI
       case JPEG.APP0
-	l = fread(in, 1, 'uint16', 'ieee-be');
+        l = fread(in, 1, 'uint16', 'ieee-be');
         if debug, printf('APP0: %i\n', l); end
         fseek(in, l-2, 'cof');
       case JPEG.APP1
-	l = fread(in, 1, 'uint16', 'ieee-be');
-	if debug, printf('APP1: %i\n', l); end
-	app1 = fread(in, l-2, 'uchar');
+        l = fread(in, 1, 'uint16', 'ieee-be');
+        if debug, printf('APP1: %i\n', l); end
+        app1 = fread(in, l-2, 'uchar');
         if nargin==1
           exif = parseexif(app1);
         else
@@ -86,7 +86,7 @@
         end
         % stop reading further, remove following break
         % if you want to extend this parser.
-	break; 
+        break; 
       case JPEG.APP2
         l = fread(in, 1, 'uint16', 'ieee-be');
         if debug, printf('APP2: %i\n', l); end
@@ -118,7 +118,7 @@
       case JPEG.EOI % end of image
         printf('EOI');
       otherwise % Skip unknown tags
-	l = fread(in, 1, 'uint16', 'ieee-be');
+        l = fread(in, 1, 'uint16', 'ieee-be');
         if debug, printf('TAG %04X: %i\n', s, l); end
         fseek(in, l-2, 'cof');
     end
@@ -201,31 +201,31 @@
                ifd_count, ifd_offset, name);
       end
       if ifd_type>0
-	n = ifdsize(ifd_type);
+        n = ifdsize(ifd_type);
 
-	if n*ifd_count<=4
-	  value = data(j+8:j+8+n*ifd_count-1);
-	  value = reshape(value, n, ifd_count);
-	else
-  	  a = 7+ifd_offset;
-	  b = 7+ifd_offset+n*ifd_count-1;
+        if n*ifd_count<=4
+          value = data(j+8:j+8+n*ifd_count-1);
+          value = reshape(value, n, ifd_count);
+        else
+          a = 7+ifd_offset;
+          b = 7+ifd_offset+n*ifd_count-1;
           if (a>0 && b>0 && a<=length(data) && b<=length(data))
-  	    value = data(7+ifd_offset:7+ifd_offset+n*ifd_count-1);
-	    value = reshape(value, n, ifd_count);
-	  else
-	    value = [];
-	  end
-	end
+            value = data(7+ifd_offset:7+ifd_offset+n*ifd_count-1);
+            value = reshape(value, n, ifd_count);
+          else
+            value = [];
+          end
+        end
       end
    
       switch ifd_type
-	case 01 % unsigned char
+        case 01 % unsigned char
           ifd.(name) = uint8(value);
-	  if debug,
-  	    printf('%02x ', uint8(value));
-	    printf('\n');
+          if debug,
+            printf('%02x ', uint8(value));
+            printf('\n');
           end
-	case 02 % Ascii
+        case 02 % Ascii
           ifd.(name) = char(value);
           if debug, printf('%s\n', char(value)); end
         case 03 % 16 bit unsigned int
@@ -239,34 +239,34 @@
           if debug, printf('%i\n', uintn(value, endian)); end
         case 05 % 32 bit unsigned rational
           ifd.(name) = [uintn(value(1:4,:), endian); uintn(value(5:8,:), endian)];
-	  if debug, printf('%i/%i\n',uintn(value(1:4), endian),uintn(value(5:8)), endian); end
+          if debug, printf('%i/%i\n',uintn(value(1:4), endian),uintn(value(5:8)), endian); end
         case 07 % unknown
           ifd.(name) = uint8(value);
           if debug
-    	    printf('%02x ', value);
-  	    printf('\n');
+            printf('%02x ', value);
+            printf('\n');
           end
         case 09 % 32 bit signed int
           ifd.(name) = intn(value, endian);
           if debug, printf('%i\n', intn(value, endian)); end
         case 10 % 32 bit signed rational
           ifd.(name) = [intn(value(1:4,:), endian); intn(value(5:8,:), endian)];
-	  if debug, printf('%i/%i\n',intn(value(1:4), endian),intn(value(5:8)), endian); end
+          if debug, printf('%i/%i\n',intn(value(1:4), endian),intn(value(5:8)), endian); end
         otherwise
-	  printf('%02x ', value);
-	  printf('\n');
+          printf('%02x ', value);
+          printf('\n');
       end
 
       switch ifd_tag
-	case 0x8769, % Exif Pointer
-	  ifd.(name) = ifdparse(exiftags(), data, ifd_offset, endian);
-	case 0x8825, % GPS Pointer
-	  ifd.(name) = ifdparse(gpstags(), data, ifd_offset, endian);
+        case 0x8769, % Exif Pointer
+          ifd.(name) = ifdparse(exiftags(), data, ifd_offset, endian);
+        case 0x8825, % GPS Pointer
+          ifd.(name) = ifdparse(gpstags(), data, ifd_offset, endian);
         case 0xa005 % Interoperatibility Pointer
-	  ifd.(name) = ifdparse(dict, data, ifd_offset, endian);
+          ifd.(name) = ifdparse(dict, data, ifd_offset, endian);
 %        case 0x927c % Makernotes
-%	   ifd.(name) = ifdparse([], data, ifd_offset, endian);
-	otherwise
+%           ifd.(name) = ifdparse([], data, ifd_offset, endian);
+        otherwise
       end
     end
     j = 9+offset+ifd_fields*12;
--- a/main/image/src/deriche.cc	Mon Sep 24 12:26:35 2012 +0000
+++ b/main/image/src/deriche.cc	Mon Sep 24 12:59:10 2012 +0000
@@ -76,17 +76,17 @@
      const double alpha = (nargin <  2) ? 1.0: args(1).double_value();  
      Method method = absgrad;
      if (args.length() >  2){
-	int m = (int)(args(2).double_value());
+        int m = (int)(args(2).double_value());
         switch(m){
-	case 0: break;
-	case 1: method = vecgrad; break;
-        case 2: method = polargrad;		
+        case 0: break;
+        case 1: method = vecgrad; break;
+        case 2: method = polargrad;
           error("not yet implemented. Use builtin 'card2pol' after method 2 (cartesian vector grad).");
-          return octave_value_list ();		
+          return octave_value_list ();
         default:
-          error("unknown method parameter.");		
-          return octave_value_list ();		
-	}	     
+          error("unknown method parameter.");
+          return octave_value_list ();
+        }
      }
   
      Matrix p(args(0).matrix_value());
@@ -94,7 +94,7 @@
      const int w = p.columns();
      switch (method){
      case absgrad:{
-        Matrix b(h, w);	
+        Matrix b(h, w);
         dericheAbs(p.fortran_vec(), b.fortran_vec(), h, w, h, alpha);
         return octave_value(b);     
      }
@@ -104,7 +104,7 @@
         return octave_value(b);
      }
      default:
-	error("method not yet implemented.");
+      error("method not yet implemented.");
         return octave_value_list();
      }     
  }
@@ -120,7 +120,7 @@
   double a2(a1-a0*b1);
   double a3(-a0*b2);
   double *tmp = 0;
-  //const int sz = h*w;	// unused 
+  //const int sz = h*w; // unused 
   try {
     tmp = new double[2*h*w + 2*w];
     if (!tmp) {
@@ -208,8 +208,8 @@
        };
     }  
   }catch(...){
-	delete [] tmp;
-	throw;
+    delete [] tmp;
+    throw;
   }
   delete[] tmp;  
   }
@@ -226,7 +226,7 @@
   double a3(-a0*b2);
   double *tmp = 0;
   double *r=q+h*w;
-  //const int sz = h*w;	 // unused
+  //const int sz = h*w;  // unused
   try {
     tmp = new double[2*h*w + 2*w];
     if (!tmp) {
@@ -250,7 +250,7 @@
     ze = p + linLen*y;
     Ba1 = B1 + w*y;  
     for(int x=0;x < w; x++)
-      Ba1[x] = ze[x] - b1* *(Ba1 + x - w) - b2 * *(Ba1 + x -w -w);   
+      Ba1[x] = ze[x] - b1* *(Ba1 + x - w) - b2 * *(Ba1 + x -w -w);
   };
  
   for(y = h-3 ; y >= 0 ; y--){       // (ii)
@@ -312,9 +312,8 @@
        };
     }  
   }catch(...){
-	delete [] tmp;
-	throw;
+    delete [] tmp;
+    throw;
   }
-  delete[] tmp;  
+  delete[] tmp;
   }
-