sliding window over 2d array in vb.net -


i'm having problems sliding variable sized window on 2d array in vb.net. porblem when take first element of array @ 0,0 ever size of window needs smaller because element in question has center of sliding window. ex: arrar size(40,43) window size 5x5 ( window size nxn n=3 wins size 3x3) array(0,0) win size 5 2 col , 2 rows need cout out , new window size of 3x3. great.`

public function getpixelsinwindow(byval wsize integer, byval x integer, byval y integer)          dim temparray new arraylist()         dim xwidth integer = wsize         dim yheight integer = wsize         dim xvalue integer = x - wsize / 2         dim yvalue integer = y - wsize / 2         dim imgheight integer = me.mysize.height         dim imgwidth integer = me.mysize.width         dim i, j integer           while xvalue < 0             xvalue += 1             xwidth -= 1         end while         while xvalue > imgwidth             xvalue -= 1             xwidth -= 1         end while         while xwidth >= imgwidth             xwidth -= 1         end while         while xvalue + xwidth > imgwidth             xwidth -= 1         end while          while yvalue < 0             yvalue += 1             yheight -= 1         end while         while yvalue > imgheight             yvalue -= 1             yheight -= 1         end while         while yheight >= imgheight             yheight -= 1         end while         while yvalue + yheight > imgheight             yheight -= 1         end while          = xvalue xvalue + xwidth             j = yvalue yvalue + yheight                 temparray.add(pixels(j, i))             next         next          return temparray     end function 

the var pixels 2d array

something this?

public class mainclass {     public static void main (string[] args)     {         mainclass mc = new mainclass();         list<int> pix = mc.getpixelsinwindow(5, 40, 43);                 }      private int[,] data = new int[40, 43];      public list<int> getpixelsinwindow(int windowsize, int xpoint, int ypoint)     {         // dealing integers, result in truncated value,         // windowsize of 5 yield windowdelta of 2.         int windowdelta = windowsize / 2;         list<int> pixels = new list<int>();          int xmin = math.max(0, xpoint - windowdelta);         int xmax = math.min(data.getlength(0) - 1, xpoint + windowdelta);          int ymin = math.max(0, ypoint - windowdelta);         int ymax = math.min(data.getlength(1) - 1, ypoint + windowdelta);          (int x = xmin; x <= xmax; x++)         {             (int y = ymin; y <= ymax; y++)             {                 console.writeline("getting pixel (" + x.tostring() + ", " + y.tostring() + ")...");                 pixels.add(data[x, y]);             }         }             return pixels;     } } 

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -