[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Efficiently accessing subarrays from an image file...
From: |
Miroslaw Kwasniak |
Subject: |
Re: Efficiently accessing subarrays from an image file... |
Date: |
Sat, 8 Jan 2005 08:48:31 +0100 |
User-agent: |
Mutt/1.5.6+20040907i |
On Fri, Jan 07, 2005 at 09:48:21PM -0800, Jonathan Greenberg wrote:
> I was hoping I could get some hints on the most efficient way to perform
> "window" analyses on an image:
>
> inputs: large multiband image (satellite imagery), binary format
> analysis: perform some repeated algorithm using a moving window of a fixed
> size
> - example: for each location in the matrix, calculate the variance of
> the 3 x 5 rectangle of matrix elements (e.g. Pixels) surrounding the current
> location
Rule no. 1 - always vectorize your algorithm, don't use loops ;)
You can do something like this:
image=randn(1000);
rectangle=ones(5,3); lr=length(rectangle(:));
tic,
local_mean = filter2( rectangle/lr, image );
local_variance = filter2( rectangle/lr, (image-local_mean).^2 );
toc
ans = 0.83769
> What I'm hoping are some ways to speed this up for use in a MP environment
> -- what optimizations can help me do this?
Look around MPI Toolbox for Octave: http://atc.ugr.es/javier-bin/mpitb
Mirek
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------