changeset 266:b06ed1e249e3

A minor code simplification
author hauberg
date Sat, 15 Dec 2007 20:35:07 +0000
parents c7a13f09e8d0
children 54428dd6e8a5
files inst/imfilter.m
diffstat 1 files changed, 8 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/inst/imfilter.m
+++ b/inst/imfilter.m
@@ -113,22 +113,14 @@
   else # res_size == "full"
     res_size = "same";
   endif
-  if (imchannels == 1)
-    if (strcmpi(ftype, "corr"))
-      retval = filter2(f, im, res_size);
-    else
-      retval = conv2(im, f, res_size);
-    endif
-  else # imchannelse == 3
-    if (strcmpi(ftype, "corr"))
-      for i = 3:-1:1
-        retval(:,:,i) = filter2(f, im(:,:,i), res_size);
-      endfor
-    else
-      for i = 3:-1:1
-        retval(:,:,i) = conv2(im(:,:,i), f, res_size);
-      endfor
-    endif
+  if (strcmpi(ftype, "corr"))
+    for i = imchannels:-1:1
+      retval(:,:,i) = filter2(f, im(:,:,i), res_size);
+    endfor
+  else
+    for i = imchannels:-1:1
+      retval(:,:,i) = conv2(im(:,:,i), f, res_size);
+    endfor
   endif
   
   ## Change the class of the output to the class of the input