MathGroup Archive 1995

[Date Index] [Thread Index] [Author Index]

Search the Archive

Q: Help processing large arrays?

  • To: mathgroup at
  • Subject: [mg2563] Q: Help processing large arrays?
  • From: robert fuentes <robert at>
  • Date: Mon, 20 Nov 1995 01:50:21 -0500
  • Organization: Lockheed Martin Tactical Aircraft Systems

I'm doing several things in the area of image processing. Generally, I 
have rather large arrays (e.g., 256 by 256 and larger) that I need to 
apply some type of operation on. My programming technique is not very 
mature and I am seeking suggestions. Here is a typical example of my 
approach. In this case, I have a 381 by 289 image that I need to run a 
Sobel operator over (i.e., convolve with a 3 by 3 Sobel operator). This 
involves taking a 3 by 3 array and moving it over the image pixel by 
pixel, applying the multipliers of the Sobel operator to the 
corresponding 3 by 3 area of the image and replacing the value of the 
image with the sum of the operation. Here is my code that I use, it seems 
to be very slow (680+ seconds on a P90 with 32Mb ram):

   image is the input image
   rows is the number of rows in the image
   cols is the number of columns in the image
   kernel is the 3 by 3  Sobel operator
   ki & kj are the dimensions of the kernel

basically, I calculate an adjustment for the edges around the image where 
the operator will extend beyond the image boundaries, then for each pixel 
in the image I construct a 3 by 3 array and multiply it by the input 
kernel and then sum these up and replace the point in the image with the 



RPConvolve[image_,rows_,cols_,kernel_,ki_,kj_] := 
iadjust = (ki-1)/2;
jadjust = (kj-1)/2;
mistart = iadjust+1;
mistop = rows - iadjust;
mjstop = cols - jadjust;
nuimage = image;
      maskarea = Table[image[[m,n]],
      nuimage[[i,j]] = Apply[Plus,Flatten[maskarea*kernel]];

thanks for any help,
Robert Fuentes
robert at

  • Prev by Date: Bug: too subtle for me
  • Next by Date: large linear systems
  • Previous by thread: Bug: too subtle for me
  • Next by thread: Re: Q: Help processing large arrays?