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
|