Re: code optimization help
- From: Peter Boettcher <boettcher@xxxxxxxxxx>
- Date: Fri, 02 Jun 2006 10:29:30 -0400
Peter Bone <peterbone@xxxxxxxxxxx> writes:
I need to make this code as fast as possible. It creates an image
from a source image of a particular mapping transformation using an
interpolation lookup table for speed. The lookup table is a 2D array
the same size as the output image, each element of which is a list
of pixels from the source image that contribute to the corresponding
element of the output image. So lookupRegion represents a single
pixel of the output image. lookupRegion(:,1) and lookupRegion(:,2)
are the x and y coordinates of the contributing source image
pixels. lookupRegion(:,3) are the fraction that those pixels
contribute to the output pixel (for sub pixel accuracy). The lookup
table is created using a seperate function. So can anyone optimize
this code further or think of a faster way of doing it?
I think the problem is the data structure itself. You might be better
off reconsidering the entire algorithm, rather than optimizing this
cell array version.
The usual way to do mapping transforms is to iterate over the
*destination* image, reverse map the coordinate into the source image
(as a fractional pixel location), then interpolate that fractional
location from the surrounding locations. This is likely to be much
faster. I can't tell if it fits into your application or not.
If you have the image processing toolbox, there are some functions
that do this stuff for you. If not, then interp2 will help anyway.
--
Peter Boettcher <boettcher@xxxxxxxxxx>
MIT Lincoln Laboratory
MATLAB FAQ: http://www.mit.edu/~pwb/cssm/
.
- Follow-Ups:
- Re: code optimization help
- From: Peter Bone
- Re: code optimization help
- References:
- code optimization help
- From: Peter Bone
- code optimization help
- Prev by Date: MATLAB's FFT
- Next by Date: XLSREAD
- Previous by thread: code optimization help
- Next by thread: Re: code optimization help
- Index(es):
Relevant Pages
|