[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Need help to optimize for speed
- Subject: Need help to optimize for speed
- From: From way of Hamid <kohen(at)jpl.nasa.gov>
- Date: Tue, 16 May 2000 10:43:18 -0700
- Newsgroups: comp.lang.idl-pvwave
- Organization: Caltech/JPL/NASA
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:19629
Hi,
I have this for loop that searches for a particular pattern (roi).
This search takes for ever.
Does anyone knows how to optimize this code for speed.
Any suggestions ?
Thanks.
Hamid
size1 = size(bscl) ;;; is 1000 x 1000
size2 = size(roi) ;;;; is about 50 x 50
print, 'Size of bscl is ', size1
print, 'Size of roi is ', size2
a = reform(bscl,size1(4))
b = reform(roi,size2(4))
nmatch = 0
print, 'searching'
for column = 0, size1(1) -1 do begin
for row = 0, size1(2) -1 do begin ; num
print,'row and col', row, col
sample = reform(extrac(bscl,column,row,size2(1),size2(2)),size2(4))
IF (array_match(sample,b)) THEN begin
nmatch = nmatch +1 ;;; length has to match
print, '-------------------------'
print,'We have a match at row of', row, ' and colof', column
print, 'The centriod is at ', row + size2(1)/2 , column +
size2(2)/2
print, extrac(bscl,column,row,size2(1),size2(2))
print, '-------------------------'
print, b
end
end
end
print, 'Number of matches', nmatch
print, ' success '