Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
Duck-Jin Park wrote: > > Hi All! > > I don't know why happened error on IDL4.0.. > follow function did not happened error on IDL5.1, but it exist error > IDL4.0 > what different two version? > Can you change follow source to IDL4.0? > > If i change array "[ ]" to "( )", it did not error.. > > That's correct: the [ ] syntax for elements of array variables did not exist in IDL4.0. It was introduced in IDL5.0 I believe. Dick French
Hi All! I don't know why happened error on IDL4.0.. follow function did not happened error on IDL5.1, but it exist error IDL4.0 what different two version? Can you change follow source to IDL4.0? If i change array "[ ]" to "( )", it did not error.. ************************************************************ **** FUNCTION HR_LABEL_REGION,A ;Find the size of the array A. To do this we use the SIZE function. S=SIZE(A) & N=S[1] & M=S[2] ; The number of columns and rows in A Q=INTARR(N,M) ; Q will hold the results. It has the same size as A. L=0 ; L is the value of the current class. Start with L=0. EQU=INTARR(M*N*M) ; EQU is a place to record the class equivalencies in pass 1. th=16 ;Label the corner pixel. IF A[0,0] GT 0 THEN BEGIN L=L+1 & Q[0,0]=L EQU[L]=L ENDIF ;Label the pixels in the first row. FOR x=1,N-1 DO BEGIN IF A[x,0] GT 0 THEN BEGIN IF (A[x,0] GE (A[x-1,0]-th))AND (A[X,0] LE (A[X-1,0]+th)) THEN Q[x,0]=Q[x-1,0] ELSE BEGIN L=L+1 Q[x,0]=L EQU[L]=L ENDELSE ENDIF ENDFOR ; Label the remaining rows FOR y=1,M-1 DO BEGIN ; Label the first pixel in the row IF (A[0,y] GE (A[0,y-1]-th)) AND (A[0,Y] LE (A[0,Y-1]+th)) THEN Q[0,y]=Q[0,y-1] IF (A[0,y] GT 0) AND (A[0,y] LT (A[0,y-1]-th)) OR (A[0,Y] GT (A[0,Y-1]+th)) THEN BEGIN L=L+1 Q[0,y]=L EQU[L]=L ENDIF FOR x=1,N-1 DO BEGIN ; Label the rest of the elements in row y IF A[x,y] GT 0 THEN BEGIN IF (A[x,y] GE (A[x-1,y]-th)) AND (A[x,y] LE (A[x-1,y]+th)) AND (A[x,y] LT (A[x,y-1]-th)) OR $ (A[x,y] GT (A[x,y-1]+th)) THEN Q[x,y]=Q[x-1,y] IF (A[x,y] LT (A[x-1,y]-th)) OR (A[x,y] GT (A[x-1,y]+th)) AND (A[x,y] GE (A[x,y-1]-th)) AND $ (A[x,y] LE (A[x,y-1]+th)) THEN Q[x,y]=Q[x,y-1] IF (A[x,y] GE (A[x-1,y]-th)) AND (A[x,y] LE (A[x-1,y]+th)) AND (A[x,y] GE (A[x,y-1]-th)) AND $ (A[x,y] LE (A[x,y-1]+th)) THEN BEGIN IF ((Q[x-1,y]) GE (Q[x,y-1]-th)) AND ((Q[x-1,y]) LE (Q[x,y-1]+th)) OR ((Q[x-1,y]-TH) LE (Q[x,y-1])) AND $ ((Q[x-1,y]+TH) GE (Q[x,y-1]))THEN Q[x,y]=Q[x-1,y] ELSE BEGIN ; An equivalence of classes has been discovered. L1=Q[x-1,y]<Q[x,y-1] ; Find the smaller class label L2=Q[x-1,y]>Q[x,y-1] ; Find the larger class label Q[x,y]=L1 ; Set the current pixel class to the smaller EQU[L2]=L1 ; Note the equivalency in the array ENDELSE ENDIF IF (A[x,y] LT (A[x-1,y]-th)) OR (A[x,y] GT (A[x-1,y]+th)) AND $ (A[x,y] LT (A[x,y-1]-th)) OR (A[x,y] GT (A[x,y-1]+th)) THEN BEGIN L=L+1 ;New class is needed Q[x,y]=L EQU[L]=L ENDIF ENDIF ENDFOR ENDFOR ; This completes the first pass through the image. We now have to resolve ; the class equivalencies. EQU=EQU(0:L) ; Shorten the vector to the classes actually created. FOR m=L,2,-1 DO BEGIN n=m WHILE (EQU[n] LT n) DO n=EQU[n] EQU[m]=n ENDFOR FOR m=2,L DO BEGIN D=WHERE(Q EQ m) Q(D)=EQU[m] ENDFOR RETURN,Q END