changeset 694:de4cbcc617be

strel: faster algorithm to draw diamond shape
author carandraug
date Thu, 20 Dec 2012 02:33:51 +0000
parents f33550d36273
children 8c3ca958d9f5
files inst/@strel/strel.m
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/inst/@strel/strel.m
+++ b/inst/@strel/strel.m
@@ -104,9 +104,10 @@
         error ("strel: RADIUS must be a positive integer");
       endif
 
-      [xx, yy]  = meshgrid (-radius:radius);
-      SE.nhood  = (abs (xx) + abs (yy)) <= radius;
-      SE.flat   = true;
+      corner   = tril (true (radius+1, radius), -1);
+      SE.nhood = [rot90(tril(true(radius+1))) corner;
+                  corner' rot90(triu(true(radius),1))];
+      SE.flat  = true;
 
     case "disk"
       if (numel (varargin) == 1)