Need help to optimize for speed [message #20115] |
Tue, 16 May 2000 00:00 |
Hamid Kohen
Messages: 5 Registered: March 2000
|
Junior Member |
|
|
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 '
|
|
|