comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: correlation images please help!
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: correlation images please help! [message #66180] Thu, 23 April 2009 06:25
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Jean H. writes:

> Among them, your
> code launches an Itool... I doubt it's available in pv-wave (could
> someone confirm?)

No, this is one distinct advantage PV-WAVE has over IDL. ;-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: correlation images please help! [message #66182 is a reply to message #66180] Thu, 23 April 2009 06:04 Go to previous message
Jean H. is currently offline  Jean H.
Messages: 472
Registered: July 2006
Senior Member
Fabinho wrote:
> Good morning,
> thanks for your help. I tryed to changed the code as you told me, but
> I still got the following errors:
>
with very minor modification, it compiles and run with no problem
here... I have emailed you the modified file... I am not too familiar
with pv-wave, so I can't help you with the difference in syntaxes...
however, knowing that there is no mistake, you could get the pv-wave
manual (is there any??) to find out about the problem. Among them, your
code launches an Itool... I doubt it's available in pv-wave (could
someone confirm?)

Jean
Re: correlation images please help! [message #66185 is a reply to message #66182] Thu, 23 April 2009 00:04 Go to previous message
Fabinho is currently offline  Fabinho
Messages: 6
Registered: April 2009
Junior Member
Good morning,
thanks for your help. I tryed to changed the code as you told me, but
I still got the following errors:

img = 0.3*Reform(img[0,*,*]) + 0.59*Reform(img[1,*,*]) + $

^
% Syntax error.
At: wox2.pro, Line 5

kernel = REPLICATE((1./(kernelSize[0]*kernelSize[1])), $

^
% Syntax error.
At: wox2.pro, Line 9

print,image_equal(img,img2,/outid)

^
% Syntax error.
At: wox2.pro, Line 13
% 3 Compilation errors in module TEST.

msize=s1[0]<s1[1]<s2[0]<s2[1]

^
% Syntax error.
At: wox2.pro, Line 24

npix<=msize

^
% Syntax error.
At: wox2.pro, Line 27

nx=nsub[0]

^
% Syntax error.
At: wox2.pro, Line 34

ny=nsub[1]

^
% Syntax error.
At: wox2.pro, Line 35

x1=[x0[1:*],s2[0]]-1

^
% Syntax error.
At: wox2.pro, Line 37

y1=[y0[1:*],s2[1]]-1

^
% Syntax error.
At: wox2.pro, Line 39

sub=img2[x0[i]:x1[i],y0[j]:y1[j]]

^
% Syntax error.
At: wox2.pro, Line 50

noffx=s1[0]-ssub[0]

^
% Syntax error.
At: wox2.pro, Line 54

noffy=s1[1]-ssub[1]

^
% Syntax error.
At: wox2.pro, Line 55

ccor[k,l]=c_correlate(sub,img1[k:k+ssub[0],l:l+ssub[1]],0)

^
% Syntax error.
At: wox2.pro, Line 61

xoff[i,j]=k

^
% Syntax error.
At: wox2.pro, Line 68

yoff[i,j]=l

^
% Syntax error.
At: wox2.pro, Line 69

xyccor[i,j]=mccor

^
% Syntax error.
At: wox2.pro, Line 70

img2recon[k,l]=sub

^
% Syntax error.
At: wox2.pro, Line 73

bsame and= total(rebin(total(xoff,2)/ny,nx,ny)-xoff gt shifttol,/pres)

^
% Syntax error.
At: wox2.pro, Line 80

eq 0

^
% Syntax error.
At: wox2.pro, Line 81

bsame and= total(rebin(reform(total(yoff,1),1,ny)/nx,nx,ny)-yoff gt

^
% Syntax error.
At: wox2.pro, Line 82

shifttol,/pres) eq 0

^
% Syntax error.
At: wox2.pro, Line 83
% 18 Compilation errors in module IMAGE_EQUAL.

I would appreciate if someone are able to help me. What am I supposed
to change?

here is the code I used:

;------------------------
pro test
path = Filepath(Subdir=['examples', 'data'], 'rose.jpg')
read_jpeg, path, img, /true
img = 0.3*Reform(img[0,*,*]) + 0.59*Reform(img[1,*,*]) + $
0.11*Reform(img[0,*,*])

kernelSize = [10,10]
kernel = REPLICATE((1./(kernelSize[0]*kernelSize[1])), $
kernelSize[0], kernelSize[1])
img2= CONVOL(img, kernel, /CENTER, /EDGE_TRUNCATE)

print,image_equal(img,img2,/outid)
end;pro test
;------------------------
function
image_equal,img1,img2,npix=npix,shifttol=shifttol,Rtol=Rtol, outid=outid
; Image offsets or scales don't matter
; npix: subimage pixels for cross-correlation
; shifttol: subimage shift tollerance
; Rtol: cross-correlation tollerance

s1=size(img1,/dim)
s2=size(img2,/dim)
msize=s1[0]<s1[1]<s2[0]<s2[1]

if not keyword_set(npix) then npix=fix(msize*0.4)>10 ; 40% of the size
npix<=msize

if n_elements(shifttol) eq 0 then shifttol=(msize*0.01)>1 ; 1% of the
size
if not keyword_set(Rtol) then Rtol=0.9

; Subimages in img2
nsub=s2/npix
nx=nsub[0]
ny=nsub[1]
x0=npix*indgen(nx)
x1=[x0[1:*],s2[0]]-1
y0=npix*indgen(ny)
y1=[y0[1:*],s2[1]]-1

; img2 subimages in img1
xoff=lonarr(nsub)
yoff=xoff
xyccor=fltarr(nsub)
if keyword_set(outid) then img2recon=img1*0

; Cross-correlate subimages of img2 with img1
for i=0,nx-1 do $
for j=0,ny-1 do begin
sub=img2[x0[i]:x1[i],y0[j]:y1[j]]
ssub=size(sub,/dim)-1

; Number of sub-shifts in img1
noffx=s1[0]-ssub[0]
noffy=s1[1]-ssub[1]
ccor=fltarr(noffx,noffy)

; Correlate sub with img1
for k=0,noffx-1 do $
for l=0,noffy-1 do $
ccor[k,l]=c_correlate(sub,img1[k:k+ssub[0],l:l+ssub[1]],0)

; Sub image offset and cross-correlation
mccor=max(ccor,moff)
k=moff mod noffx
l=moff/noffx

xoff[i,j]=k
yoff[i,j]=l
xyccor[i,j]=mccor

if keyword_set(outid) then begin
img2recon[k,l]=sub
print,'Progress: ',(i*ny+j+1.)/(nx*ny)*100,'%'
endif
endfor

; Check whether img2 and img1 are equal
bsame=total(xyccor lt Rtol,/pres) eq 0
bsame and= total(rebin(total(xoff,2)/ny,nx,ny)-xoff gt shifttol,/pres)
eq 0
bsame and= total(rebin(reform(total(yoff,1),1,ny)/nx,nx,ny)-yoff gt
shifttol,/pres) eq 0

if keyword_set(outid) then begin
window
tvscl,img1,0
tvscl,img2,1
tvscl,img2recon,2
tvscl,img2-img2recon,3

xyouts,0.1,0.7,'img1',/normal,color=100
xyouts,0.3,0.7,'img2',/normal,color=100
xyouts,0.5,0.7,'reconstructed img2',/normal,color=100
xyouts,0.7,0.7,'img1 - reconstructed img2',/normal,color=100
isurface,xyccor
endif

return,bsame
end;function image_equal

thanks a lot and have a nice day!


On 22 avr, 17:04, "Jean H." <jghas...@DELTHIS.ucalgary.ANDTHIS.ca>
wrote:
> What kind of errors do you get? ... Of course, you would have reformated
> the code... for example
>   img = 0.3*Reform(img[0,*,*]) + 0.59*Reform(img[1,*,*]) +
>   0.11*Reform(img[0,*,*])
>
> can not work. Either write it on 1 line, or put a $ sign after the last
> + on the first line..
>
> Jean
Re: correlation images please help! [message #66194 is a reply to message #66185] Wed, 22 April 2009 08:04 Go to previous message
Jean H. is currently offline  Jean H.
Messages: 472
Registered: July 2006
Senior Member
What kind of errors do you get? ... Of course, you would have reformated
the code... for example
img = 0.3*Reform(img[0,*,*]) + 0.59*Reform(img[1,*,*]) +
0.11*Reform(img[0,*,*])

can not work. Either write it on 1 line, or put a $ sign after the last
+ on the first line..

Jean
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: idl-envi resolv_all
Next Topic: Annotations of grid in map_set

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 11:42:42 PDT 2025

Total time taken to generate the page: 0.00667 seconds