Re: correlation between images [message #66101 is a reply to message #65922] |
Thu, 02 April 2009 13:56   |
Brian Larsen
Messages: 270 Registered: June 2006
|
Senior Member |
|
|
OK, so I was on much the same telecom three times today and needed to
occupy myself...
This is an example "related" to what you are working on.
Run this as I think its pretty fun.
Download this image:
http://technabob.com/blog/wp-content/uploads/2008/03/apple_l ogo_rainbow_fruit.jpg
then run the following code:
; .run image_registration
read_jpeg, 'apple_logo_rainbow_fruit.jpg', img, /true
tv, img[1, *, *]
size = size(img, /dimen)
cut_size = 50
sub = img[*, 140:190, 300:350]
ans = fltarr(size[1:2])
FOR i = 0UL, size[1]-cut_size-1, 10 DO BEGIN
FOR j = 0UL, size[2]-cut_size-1, 10 DO BEGIN
ans[i, j] = c_correlate(sub, img[*, i:i+cut_size, j:j+cut_size],
0)
tv, sub, i, j, /true
tv, img[1,i:i+cut_size, j:j+cut_size], i, j
ENDFOR
ENDFOR
ind=where(ans eq max(ans))
wheretomulti, ans, ind, col, row
tv, img[1, *, *]
tv, sub, col, row, /true
END
This is fun as it funds just the right place. To be smart one would
iteratively move different numbers of pixels. As I new the answer I
was able to take large steps and get the right answer, but this gave
the same answer taking 1 pixel steps but takes too long.
Cheers,
Brian
------------------------------------------------------------ --------------
Brian Larsen
Boston University
Center for Space Physics
http://people.bu.edu/balarsen/Home/IDL
|
|
|