Image Segmentation
Hyeun-gu Choi

Appendix A: Source code of Widget interface coded in IDL

PRO IMAGEDEMO_EVENT,event
WIDGET_CONTROL,event.id,Get_Value=what
WIDGET_CONTROL,event.top,GET_UVALUE=info
source_image=intarr(256,256)

IF event.id EQ info.sourceBtn then what='SOURCE'
IF event.id EQ info.destinationBtn THEN what='DESTINATION'

CASE what OF
  'SOURCE': BEGIN
          WIDGET_CONTROL,event.id,GET_VALUE=sourcewindow
          CASE sourcewindow OF
          0:  info.sourcewin=info.drawTL
          1: info.sourcewin=info.drawTR
          2: info.sourcewin=info.drawBL
          3: info.sourcewin=info.drawBR
          4: info.sourcewin=info.drawTE

           ENDCASE
          END
  'DESTINATION': BEGIN
          WIDGET_CONTROL,event.id,GET_VALUE=destwin
          CASE destwin OF
          0: info.destinationwin=info.DRAWTL
          1: info.destinationwin=info.DRAWTR
          2: info.destinationwin=info.DRAWBL
          3: info.destinationwin=info.DRAWBR
          4: info.destinationwin=info.drawTE
          ENDCASE
        END

  'DONE':   WIDGET_CONTROL,event.top,/destroy

  '1-2':  BEGIN
          WIDGET_CONTROL,info.drawTL,Get_UValue=tempL
          WIDGET_CONTROL,info.drawTR,Get_UValue=tempR
          WIDGET_CONTROL,info.drawTR,Set_UValue=tempL
          WIDGET_Control,info.drawTL,Set_UValue=tempR
          WIDGET_CONTROL,info.drawTL,Get_Value=win
          WSET,win & ERASE
          TVscl,tempR
          WIDGET_CONTROL,info.drawTR,Get_Value=win
          WSET,win & ERASE
          TVscl,tempL
        END
  '1-3':  BEGIN
          WIDGET_CONTROL,info.drawTL,Get_UValue=tempL
          WIDGET_CONTROL,info.drawBL,Get_UValue=tempS
          WIDGET_CONTROL,info.drawBL,Set_UValue=tempL
          WIDGET_Control,info.drawTL,Set_UValue=tempS
          WIDGET_CONTROL,info.drawTL,Get_Value=win
          WSET,win & ERASE
          TVscl,tempS
          WIDGET_CONTROL,info.drawBL,Get_Value=win
          WSET,win & ERASE
          TVscl,tempL
        END
  '1-4':  BEGIN
          WIDGET_CONTROL,info.drawTL,Get_UValue=temp1
          WIDGET_CONTROL,info.drawBR,Get_UValue=temp2
          WIDGET_CONTROL,info.drawTL,Set_UValue=temp2
          WIDGET_Control,info.drawBR,Set_UValue=temp1
          WIDGET_CONTROL,info.drawTL,Get_Value=win
          WSET,win & ERASE
          TVscl,temp2
          WIDGET_CONTROL,info.drawBR,Get_Value=win
          WSET,win & ERASE
          TVscl,temp1
        END
  '1-5':  BEGIN
          WIDGET_CONTROL,info.drawTL,Get_UValue=temp1
          WIDGET_CONTROL,info.drawTE,Get_UValue=temp2
          WIDGET_CONTROL,info.drawTL,Set_UValue=temp2
          WIDGET_Control,info.drawTE,Set_UValue=temp1
          WIDGET_CONTROL,info.drawTL,Get_Value=win
          WSET,win & ERASE
          TVscl,temp2
          WIDGET_CONTROL,info.drawTE,Get_Value=win
          WSET,win & ERASE
          TVscl,temp1
        END
  '2-3':  BEGIN
          WIDGET_CONTROL,info.drawTR,Get_UValue=temp1
          WIDGET_CONTROL,info.drawBL,Get_UValue=temp2
          WIDGET_CONTROL,info.drawTR,Set_UValue=temp2
          WIDGET_Control,info.drawBL,Set_UValue=temp1
          WIDGET_CONTROL,info.drawTR,Get_Value=win
          WSET,win & ERASE
          TVscl,temp2
          WIDGET_CONTROL,info.drawBL,Get_Value=win
          WSET,win & ERASE
          TVscl,temp1
        END
  '2-4':  BEGIN
          WIDGET_CONTROL,info.drawTR,Get_UValue=temp1
          WIDGET_CONTROL,info.drawBR,Get_UValue=temp2
          WIDGET_CONTROL,info.drawTR,Set_UValue=temp2
          WIDGET_Control,info.drawBR,Set_UValue=temp1
          WIDGET_CONTROL,info.drawTR,Get_Value=win
          WSET,win & ERASE
          TVscl,temp2
          WIDGET_CONTROL,info.drawBR,Get_Value=win
          WSET,win & ERASE
          TVscl,temp1
        END
  '2-5':  BEGIN
          WIDGET_CONTROL,info.drawTR,Get_UValue=temp1
          WIDGET_CONTROL,info.drawTE,Get_UValue=temp2
          WIDGET_CONTROL,info.drawTR,Set_UValue=temp2
          WIDGET_Control,info.drawTE,Set_UValue=temp1
          WIDGET_CONTROL,info.drawTR,Get_Value=win
          WSET,win & ERASE
          TVscl,temp2
          WIDGET_CONTROL,info.drawTE,Get_Value=win
          WSET,win & ERASE
          TVscl,temp1
        END
  '3-4':  BEGIN
          WIDGET_CONTROL,info.drawBL,Get_UValue=temp1
          WIDGET_CONTROL,info.drawBR,Get_UValue=temp2
          WIDGET_CONTROL,info.drawBL,Set_UValue=temp2
          WIDGET_Control,info.drawBR,Set_UValue=temp1
          WIDGET_CONTROL,info.drawBL,Get_Value=win
          WSET,win & ERASE
          TVscl,temp2
          WIDGET_CONTROL,info.drawBR,Get_Value=win
          WSET,win & ERASE
          TVscl,temp1
        END
  '3-5':  BEGIN
          WIDGET_CONTROL,info.drawBL,Get_UValue=temp1
          WIDGET_CONTROL,info.drawTE,Get_UValue=temp2
          WIDGET_CONTROL,info.drawBL,Set_UValue=temp2
          WIDGET_Control,info.drawTE,Set_UValue=temp1
          WIDGET_CONTROL,info.drawBL,Get_Value=win
          WSET,win & ERASE
          TVscl,temp2
          WIDGET_CONTROL,info.drawTE,Get_Value=win
          WSET,win & ERASE
          TVscl,temp1
        END
  '4-5':  BEGIN
          WIDGET_CONTROL,info.drawBR,Get_UValue=temp1
          WIDGET_CONTROL,info.drawTE,Get_UValue=temp2
          WIDGET_CONTROL,info.drawBR,Set_UValue=temp2
          WIDGET_Control,info.drawTE,Set_UValue=temp1
          WIDGET_CONTROL,info.drawBR,Get_Value=win
          WSET,win & ERASE
          TVscl,temp2
          WIDGET_CONTROL,info.drawTE,Get_Value=win
          WSET,win & ERASE
          TVscl,temp1
        END
  'HIGHPASS': BEGIN
          w=[[-1,-1,-1],[-1,8,-1],[-1,-1,-1]] & s=1
          WIDGET_CONTROL,info.sourcewin,GET_UValue=image
          IF N_ELEMENTS(image) GT 0 THEN BEGIN
            B=CONVOL(image,w,s)
            WIDGET_CONTROL,info.destinationwin,GET_VALUE=win
            WIDGET_CONTROL,info.destinationwin,Set_UValue=B
            WSET,win & erase
            TVscl,B
          ENDIF
          END
  'LOWPASS':  BEGIN
          w=[[1,1,1],[1,1,1],[1,1,1]] & s=9
          WIDGET_CONTROL,info.sourcewin,GET_UValue=image
          IF N_ELEMENTS(image) GT 0 THEN BEGIN
            B=CONVOL(image,w,s)
            WIDGET_CONTROL,info.destinationwin,GET_VALUE=win
            WIDGET_CONTROL,info.destinationwin,Set_UValue=B
            WSET,win & erase
            TVscl,B
          ENDIF
          END
  'UNSHARP':  BEGIN
          GET_UNSHARP_VALUE,A
          z=9*A-1
          w=[[-1,-1,-1],[-1,z,-1],[-1,-1,-1]]
          s=(9*a-9)>1
          WIDGET_CONTROL,info.sourcewin,GET_UValue=image
          IF N_ELEMENTS(image) GT 0 THEN BEGIN
            B=CONVOL(image,w,s)
            WIDGET_CONTROL,info.destinationwin,GET_VALUE=win
            WIDGET_CONTROL,info.destinationwin,Set_UValue=B
            WSET,win & erase
            TVscl,B
          ENDIF
        END

  'LAPLACIAN':  BEGIN
          w=[[0,-1,0],[-1,4,-1],[0,-1,0]] & s=1
          WIDGET_CONTROL,info.sourcewin,GET_UValue=image
          IF N_ELEMENTS(image) GT 0 THEN BEGIN
            B=CONVOL(image,w,s)
            WIDGET_CONTROL,info.destinationwin,GET_VALUE=win
            WIDGET_CONTROL,info.destinationwin,Set_UValue=B
            WSET,win & erase
            TVscl,B
          ENDIF
          END
  'VERTICAL EDGES': BEGIN
          w=[[-1,0,1],[-2,0,2],[-1,0,1]] & s=1
          WIDGET_CONTROL,info.sourcewin,GET_UValue=image
          IF N_ELEMENTS(image) GT 0 THEN BEGIN
            B=CONVOL(image,w,s)
            WIDGET_CONTROL,info.destinationwin,GET_VALUE=win
            WIDGET_CONTROL,info.destinationwin,Set_UValue=B
            WSET,win & erase
            TVscl,B
          ENDIF
          END
  'HORIZONTAL EDGES': BEGIN
          w=[[-1,-2,-1],[0,0,0],[1,2,1]] & s=1
          WIDGET_CONTROL,info.sourcewin,GET_UValue=image
          IF N_ELEMENTS(image) GT 0 THEN BEGIN
            B=CONVOL(image,w,s)
            WIDGET_CONTROL,info.destinationwin,GET_VALUE=win
            WIDGET_CONTROL,info.destinationwin,Set_UValue=B
            WSET,win & erase
            TVscl,B
          ENDIF
          END
  'SOBEL':    BEGIN
            WIDGET_CONTROL,info.sourcewin,GET_UValue=image
          IF N_ELEMENTS(image) GT 0 THEN BEGIN
            B=Sobel(image)
            WIDGET_CONTROL,info.destinationwin,GET_VALUE=win
            WIDGET_CONTROL,info.destinationwin,Set_UValue=B
            WSET,win & erase
            TVscl,B
          ENDIF
          END
  'MEDIAN':  BEGIN
          WIDGET_CONTROL,info.destinationwin,GET_VALUE=win
          WSET,win & ERASE
          WIDGET_CONTROL,info.sourcewin,GET_UValue=image
          image=MEDIAN(image,5)
          WIDGET_CONTROL,info.destinationwin,Set_UValue=image
          TVscl,image
                END
  'ADD NOISE': BEGIN
            WIDGET_CONTROL,info.destinationwin,GET_VALUE=win
            WSET,win & ERASE
            WIDGET_CONTROL,info.sourcewin,GET_UVALUE=image
            SIZ=N_ELEMENTS(image)
            IMIN=MIN(IMAGE)
            IMAX=MAX(IMAGE)
            k=LONG(RANDOMU(seed,SIZ/50)*SIZ)
            image(k)=IMIN
            k=LONG(RANDOMU(seed,SIZ/50)*SIZ)
            image(k)=IMAX
            WIDGET_CONTROL,info.destinationwin,SET_UVALUE=image
            TVSCL,image
           END
  'CUSTOM': BEGIN
          WIDGET_CONTROL,info.sourcewin,Get_UValue=image
          GET_WEIGHTS,W,S,action
          print,w & print & print,'S=',s
          IF action THEN BEGIN
            B=CONVOL(image,w,s)
            WIDGET_CONTROL,info.destinationwin,GET_VALUE=win
            WIDGET_CONTROL,info.destinationwin,Set_UValue=B
            WSET,win & erase
            TV,B
          ENDIF
          END
  'ADD 1+3': BEGIN
          WIDGET_CONTROL,info.drawTL,Get_UValue=img1
          WIDGET_CONTROL,info.drawBL,Get_UValue=img3
          SIZ1=SIZE(IMG1) & SIZ3=SIZE(IMG3)
          IF (SIZ1[1] EQ SIZ3[1]) AND (SIZ1[2] EQ SIZ3[2]) THEN BEGIN
          img=img1+img3
          WIDGET_CONTROL,info.destinationwin,GET_VALUE=win
          WIDGET_CONTROL,info.destinationwin,SET_UVALUE=img
          WSET,win & ERASE
          TVscl,img
         ENDIF
        END
  'ADD 1+2': BEGIN
          WIDGET_CONTROL,info.drawTL,Get_UValue=img1
          WIDGET_CONTROL,info.drawTR,Get_UValue=img2
          SIZ1=SIZE(IMG1) & SIZ2=SIZE(IMG2)
          IF (SIZ1[1] EQ SIZ2[1]) AND (SIZ1[2] EQ SIZ2[2]) THEN BEGIN
          img=img1+img2
          WIDGET_CONTROL,info.destinationwin,GET_VALUE=win
          WIDGET_CONTROL,info.destinationwin,SET_UVALUE=img
          WSET,win & ERASE
          TVscl,img
         ENDIF
        END
  'ADD 2+3': BEGIN
          WIDGET_CONTROL,info.drawTR,Get_UValue=img2
          WIDGET_CONTROL,info.drawBL,Get_UValue=img3
          SIZ2=SIZE(IMG2) & SIZ3=SIZE(IMG3)
          IF (SIZ2[1] EQ SIZ3[1]) AND (SIZ2[2] EQ SIZ3[2]) THEN BEGIN
          img=img2+img3
          WIDGET_CONTROL,info.destinationwin,GET_VALUE=win
          WIDGET_CONTROL,info.destinationwin,SET_UVALUE=img
          WSET,win & ERASE
          TVscl,img
         ENDIF
        END
  'SUBTRACT 1-3': BEGIN
          WIDGET_CONTROL,info.drawTL,Get_UValue=img1
          WIDGET_CONTROL,info.drawBL,Get_UValue=img3
          SIZ1=SIZE(IMG1) & SIZ3=SIZE(IMG3)
          IF (SIZ1[1] EQ SIZ3[1]) AND (SIZ1[2] EQ SIZ3[2]) THEN BEGIN
          img=img1-img3
          WIDGET_CONTROL,info.destinationwin,GET_VALUE=win
          WIDGET_CONTROL,info.destinationwin,SET_UVALUE=img
          WSET,win & ERASE
          TVscl,img
         ENDIF
        END
  'NEW':BEGIN

        fname=DIALOG_PICKFILE(PATH='C:\RSI\idl50\',FILTER='*.*');'C:\windows\desktop\MRI\',FILTER='*.*')
        parts = STR_SEP(FNAME, '.')
        CASE PARTS[1] OF
        'tif':A=READ_TIFF(FNAME)
        'TIF':A=READ_TIFF(FNAME)
        'SKW':A=READMRI(FNAME)
        'skw':A=READMRI(FNAME)
        'gif':READ_GIF,FNAME,A,RED,GREEN,BLUE
        'GIF':READ_GIF,FNAME,A,RED,GREEN,BLUE
        ENDCASE
        ;IF PARTS[1] EQ 'TIF' THEN A=READ_TIFF(fname) ELSE A=READMRI(FNAME)
        SIZ=SIZE(A)
print,'IMAGE SIZE = ',SIZ(1),'X',SIZ(2)
        WIDGET_CONTROL,info.destinationwin,GET_VALUE=win
        WSET,win & erase
        TVscl,A
        WIDGET_CONTROL,info.destinationwin,SET_UVALUE=A
      END
  'SAVE IMAGE': BEGIN
        fname=DIALOG_PICKFILE(PATH='C:\Harvey\Images\',$
          FILTER='*.TIF',FILE='IMAGE1.TIF',/WRITE)
        IF fname NE '' THEN BEGIN
        PRINT,'SAVE FNAME=',fname
        WIDGET_CONTROL,info.sourcewin,GET_UVALUE=A
        WRITE_TIFF,fname,A
        ENDIF
      END

  'LABEL REGION': begin

    WIDGET_CONTROL,info.sourcewin,GET_UValue=image
          IF N_ELEMENTS(image) GT 0 THEN BEGIN
          B=label_region(image)
            WIDGET_CONTROL,info.destinationwin,GET_VALUE=win
            WIDGET_CONTROL,info.destinationwin,Set_UValue=B
            WSET,win & erase
            TV,B
          ENDIF
          xloadct
          END
 

  'MODIFIED LR': begin

    WIDGET_CONTROL,info.sourcewin,GET_UValue=image
          IF N_ELEMENTS(image) GT 0 THEN BEGIN
          B=hr_label_region(image)
            WIDGET_CONTROL,info.destinationwin,GET_VALUE=win
            WIDGET_CONTROL,info.destinationwin,Set_UValue=B
            WSET,win & erase
            TV,B
          ENDIF
          xloadct
          END
  'ONE THRESHOLD': begin
    WIDGET_CONTROL,info.sourcewin,GET_UValue=image
    IF N_ELEMENTS(image) GT 0 THEN BEGIN
    siz=size(image)
    H=HISTOGRAM(image)
    WIDGET_CONTROL,info.drawBE,GET_VALUE=tem
    WSET,tem & erase

    PLOT,H,TITLE='Histogram',XTITLE='Gray level',YTITLE='Frequency',YRANGE=[0,1000]

    result=DIALOG_MESSAGE('Click a point on the histogram to get a threshold value!',/information,/cancel)
    IF 'Cancel' EQ RESULT THEN GOTO, CANCEL
    AGAIN:
    x1=intarr(1)
    CURSOR,X1,Y1,3,/DATA
    print,'gray level',fix(x1)

        REGION=WHERE(image GT x1,count )

    IF count Eq 0 THEN RESULT=DIALOG_MESSAGE('Out of range! Try again.',/cancel)
    IF RESULT EQ 'Cancel' THEN GOTO,CANCEL
    IF count eq 0  THEN GOTO,AGAIN
    OUT=FLTARR(SIZ(1),SIZ(2))
    OUT[REGION]=255
    WIDGET_CONTROL,info.destinationwin,GET_VALUE=tem1
    WIDGET_CONTROL,info.destinationwin,Set_UValue=out
    WSET,tem1 & erase
    TV,OUT
    CANCEL:PRINT,''
    endif
    end

'HISTOGRAM OF SOURCE WINDOW':begin
    WIDGET_CONTROL,info.sourcewin,GET_UValue=image
    IF N_ELEMENTS(image) GT 0 THEN BEGIN
    H=HISTOGRAM(image,binsize =1)
    WIDGET_CONTROL,info.drawBE,GET_VALUE=tem
    WSET,tem & erase

    PLOT,H,TITLE='Histogram of source window',XTITLE='Gray level',YTITLE='Frequency',YRANGE=[0,1000]
    ENDIF
    END
'HISTOGRAM EQUALIZATION':begin
    WIDGET_CONTROL,info.sourcewin,GET_UValue=image
    IF N_ELEMENTS(IMAGE) GT 0 THEN BEGIN
    WIDGET_CONTROL,info.destinationwin,GET_Value=tem
    WSET, tem &erase
    out=hist_equal(IMAGE)
    TVscl,out
    ENDIF
    END
'TWO THRESHOLDS': begin

    WIDGET_CONTROL,info.sourcewin,GET_UValue=image
    IF N_ELEMENTS(image) GT 0 THEN BEGIN
    siz=size(image)
    H=HISTOGRAM(image,binsize =1)
    WIDGET_CONTROL,info.drawBE,GET_VALUE=tem
    WSET,tem & erase

    PLOT,H,TITLE='Histogram',XTITLE='Gray level',YTITLE='Frequency',YRANGE=[0,1000]
    result=DIALOG_MESSAGE('Click two points on the histogram to get a threshold value!',/information,/cancel)
    IF 'Cancel' EQ RESULT THEN GOTO, CANCEL1
    AGAIN1:
    CURSOR,X1,Y1,3,/DATA
    CURSOR,X2,Y2,3,/DATA
   MAXX=X1>X2 & MINX=X1<X2
PRINT,'MAX HISTO=',MAX(H),'     MIN HISTO=',MIN(H)
;READ,MAXX,PROMPT='INPUT X1'
;READ,MINX,PROMPT='INPUT X2'
    REGION=WHERE((IMAGE LT MAXX) AND (IMAGE GT MINX))
    IF REGION(0) EQ -1 THEN RESULT=DIALOG_MESSAGE('Out of range! Try again.')
    IF REGION(0) EQ -1 THEN GOTO,AGAIN1
    OUT=FLTARR(SIZ(1),SIZ(2))
    OUT[REGION]=255
    WIDGET_CONTROL,info.destinationwin,GET_VALUE=tem1
    WIDGET_CONTROL,info.destinationwin,Set_UValue=out
    WSET,tem1 & erase
    TVSCL,OUT
    cancel1:print,''
    endif
    end
'COLOR TABLE' : begin
    XLOADCT
    END

'MANUAL'  : BEGIN
    WIDGET_CONTROL,info.sourcewin,GET_UValue=SOURCE_IMAGE
    w=[[-1,-1,-1],[-1,8,-1],[-1,-1,-1]] & s=1
    C=SOBEL(SOURCE_IMAGE);CONVOL(SOURCE_IMAGE,W,S)
    SIZ=SIZE(SOURCE_IMAGE) & N=SIZ(1) & M=SIZ(2)
    posi=where(c ne 0)
    XPTS=POSI MOD N
    YPTS=POSI / N
    theta=FINDGEN(51)/50*!PI-!pi/2
    ; Set up a vector in degrees for plotting
    degrees=theta*180/!pi
    ; Set up arrays of cosine and sine values
    cosv=cos(theta)
    sinv=sin(theta)
        LOADCT,39
    WIDGET_CONTROL,info.drawBE,GET_VALUE=tem
        WSET,tem & erase
        PLOT,degrees,xpts[0]*cosv+ypts[0]*sinv,xrange=[-90,90],$
        YRANGE=[-SQRT(N^2+M^2),SQRT(N^2+M^2)],xticklen=1,yticklen=1,$
        xticks=4,xtickv=[-90,-45,0,45,90],/nodata,$
        TITLE='Parameter Space (Polar coordinate)', Xtitle='Angle',Ytitle='Ro'
        kpts=MIN([N_ELEMENTS(xpts),N_ELEMENTS(ypts)])

      ; Plot the parametric curves for each data point
        FOR k=0,kpts-1 DO $
        OPLOT,degrees,xpts[k]*cosv+ypts[k]*sinv,color=FIX(k/FLOAT(KPTS)*255)

    QUAN_ang=2 & QUAN_RO=2; & THRESHOLD=30
    ;;;;;;;;;;;;;;
    BIN_ANG=180/QUAN_ANG
    ACC=FLTARR(kpts,BIN_ANG,QUAN_ANG) ;BIN_ANG IS HOW MANY CELL FOR ANGLE
     ;SIZE OF ANGLE FOR ACCUMULATOR CELL
    ANGLE=INDGEN(QUAN_ANG) ;QUANTIZE
    maxro=sqrt(n^2+m^2)
    PRINT,'MAXRO',MAXRO
    print,'angle',ANGLE
    FOR I=0, KPTS-1 DO BEGIN
    FOR J=0, BIN_ANG-1 DO BEGIN
    ACC[i,J,*]=XPTS[I]*COS((ANGLE+J*QUAN_ANG-90)*!PI/180.)+YPTS[I]*SIN((ANGLE+J*QUAN_ANG-90)*!PI/180.)
    ENDFOR
    ENDFOR

    HELP,ACC
    MIN_RO=MIN(ACC)
    MAX_RO=MAX(ACC)
    RO_RANGE=ABS(MIN(ACC))+ABS(MAX(ACC))
    BIN_RO=FIX(RO_RANGE/QUAN_RO)
    RE=INTARR(BIN_RO)

    ;LOC_CO=INTARR(KPTS)
    PRINT,'RO RANGE',RO_RANGE
    print,'BIN_ANG=',BIN_ANG,'   BIN_RO=',BIN_RO
    ;FOR I=0, BIN_RO-1 DO BEGIN
    COUNTED=INTARR(BIN_ANG,BIN_RO)

    FOR J=0, BIN_ANG-1 DO BEGIN
    FOR K=0,BIN_RO-1 DO BEGIN
    RE=WHERE((ACC[*,J,*] LT (QUAN_RO*(K+1)+MIN_RO)) AND (ACC[*,J,*] GE (QUAN_RO*(K)+MIN_RO)),COUNT)
    COUNTED[J,K]=COUNT
    ;PRINT,QUAN_RO*(K)+MIN_RO,QUAN_RO*(K+1)+MIN_RO
    ENDFOR
CASE J OF
0*FIX((BIN_ANG)/10)  : BEGIN
WIDGET_CONTROL,info.destinationwin,GET_VALUE=tem
        WSET,tem & erase
        fname=FILEPATH('NUM9.TIF',SUBDIRECTORY='DATA')
        IM=READ_TIFF(FNAME)
        TV,IM
        END
1*FIX((BIN_ANG)/10)  : BEGIN
WIDGET_CONTROL,info.destinationwin,GET_VALUE=tem
        WSET,tem & erase
        fname=FILEPATH('NUM8.TIF',SUBDIRECTORY='DATA')
        IM=READ_TIFF(FNAME)
        TV,IM
        END
2*FIX((BIN_ANG)/10)  : BEGIN
WIDGET_CONTROL,info.destinationwin,GET_VALUE=tem
        WSET,tem & erase
        fname=FILEPATH('NUM7.TIF',SUBDIRECTORY='DATA')
        IM=READ_TIFF(FNAME)
        TV,IM
        END
3*FIX((BIN_ANG)/10) : BEGIN
WIDGET_CONTROL,info.destinationwin,GET_VALUE=tem
        WSET,tem & erase
        fname=FILEPATH('NUM6.TIF',SUBDIRECTORY='DATA')
        TV, READ_TIFF(FNAME)
        END
4*FIX((BIN_ANG)/10) : BEGIN
WIDGET_CONTROL,info.destinationwin,GET_VALUE=tem
        WSET,tem & erase
        fname=FILEPATH('NUM5.TIF',SUBDIRECTORY='DATA')
        TV, READ_TIFF(FNAME)
        END
5*FIX((BIN_ANG)/10) : BEGIN
WIDGET_CONTROL,info.destinationwin,GET_VALUE=tem
        WSET,tem & erase
        fname=FILEPATH('NUM4.TIF',SUBDIRECTORY='DATA')
        TV, READ_TIFF(FNAME)
        END
6*FIX((BIN_ANG)/10) : BEGIN
WIDGET_CONTROL,info.destinationwin,GET_VALUE=tem
        WSET,tem & erase
        fname=FILEPATH('NUM3.TIF',SUBDIRECTORY='DATA')
        TV, READ_TIFF(FNAME)
        END
7*FIX((BIN_ANG)/10) : BEGIN
WIDGET_CONTROL,info.destinationwin,GET_VALUE=tem
        WSET,tem & erase
        fname=FILEPATH('NUM2.TIF',SUBDIRECTORY='DATA')
        TV, READ_TIFF(FNAME)
        END
8*FIX((BIN_ANG)/10) : BEGIN
WIDGET_CONTROL,info.destinationwin,GET_VALUE=tem
        WSET,tem & erase
        fname=FILEPATH('NUM1.TIF',SUBDIRECTORY='DATA')
        TV, READ_TIFF(FNAME)
        END
9*FIX((BIN_ANG)/10) : BEGIN
WIDGET_CONTROL,info.destinationwin,GET_VALUE=tem
        WSET,tem & erase
        fname=FILEPATH('NUM0.TIF',SUBDIRECTORY='DATA')
        TV, READ_TIFF(FNAME)
        END
ELSE:
ENDCASE
    ENDFOR
 

    MAX_COUNT=MAX(COUNTED)
    PRINT,'MAX COUNT =',MAX_COUNT

    b = COUNTED(UNIQ(COUNTED, REVERSE(SORT(COUNTED))))

    ;PRINT,'SORTED', B
    ;;;;;;;;;;;
    THRESHOLD=B[20]
    ;;;;;;;;;;;
    ANG=(WHERE(COUNTED GE THRESHOLD,COUNT1) MOD (BIN_ANG))*quan_ang
    RO=(WHERE(COUNTED GE THRESHOLD,COUNT2) / (BIN_ANG))*quan_ro
    ;LOC_CO=WHERE(COUNTED GE THRESHOLD)
    print,'count1',count1,'  count2',count2
    ANG=ANG-90 & RO=RO+MIN_RO
    REGION1=FLTARR(BIN_ANG,BIN_RO)
    ANG_REGION=(WHERE(COUNTED GE THRESHOLD)MOD (BIN_ANG))
    RO_REGION=(WHERE(COUNTED GE THRESHOLD)/ (BIN_ANG))
LOADCT,0
        WIDGET_CONTROL,info.DRAWBE,Get_Value=TEM
        WSET, tem &erase
    PLOT,ANG_REGION*QUAN_ANG-90,RO_REGION*QUAN_RO+MIN_RO,PSYM=2,XRANGE=[-90,80],$;color=0,BACKGROUND=255,$
        TITLE='Parameter Space (Polar coordinate)', Xtitle='Angle',Ytitle='Ro',xticklen=1,yticklen=1
        get_value,A,'INTERSECTION POINTS','Input the number of intersection points you want.'
    ANG=INTARR(A) & RO=INTARR(A)
    FOR I=0, A-1 DO BEGIN
    CURSOR,XX1,YY1,3,/DATA
    ANG[I]=XX1 & RO[I]=YY1
    ENDFOR
    PRINT,'ANG',ANG,'  RO',RO
   X=INDGEN(N)
      IMAGE=INTARR(N,M)

    Y_TEM=FLTARR(N)
    ;plot,x,Y_TEM,YRANGE=[0,m],xtitle='X',ytitle='Y',background=255,color=0;,XRANGE=[-100,100],YRANGE=[-100,100]
    FOR I=0,A-1 DO BEGIN
    CASE ANG[I] OF;SIN((ANG[I])*!PI/180) OF
       0 : BEGIN Y=INDGEN(N)
             IMAGE[REPLICATE(RO[I],N),Y]=255
            END
    ELSE : BEGIN
            Y=((RO[I])-X*COS((ANG[I])*!PI/180))/SIN((ANG[I])*!PI/180)
             IMAGE[X,Y]=255
           END
    ENDCASE

    CASE ABS(ANG[I]) OF;COS((ANG[I])*!PI/180) OF
      90  : BEGIN Y=REPLICATE(RO[I],N)
                 IMAGE[X,Y]=255
           END
    ELSE : BEGIN Y=((RO[I])-X*COS((ANG[I])*!PI/180))/SIN((ANG[I])*!PI/180)
                 IMAGE[X,Y]=255
           END
    ENDCASE
     IF ABS(ANG[I]) LT 5 AND ANG[I] NE 0 THEN BEGIN
          Y=INDGEN(N)
          X=(RO[I]-Y*SIN(ANG[I]*!PI/180))/COS(ANG[I]*!PI/180)
          IMAGE[X,Y]=255
          END
    ;IF ABS(ANG[I]) GT 80 THEN BEGIN
    ;      X=INDGEN(N)
    ;      Y=((RO[I])-X*COS((ANG[I])*!PI/180))/SIN((ANG[I])*!PI/180)
    ;      IMAGE[X,Y]=255
    ;      END
    ENDFOR
      WIDGET_CONTROL,info.destinationwin,GET_Value=tem
        WIDGET_CONTROL,info.destinationwin,Set_UValue=IMAGE
        WSET, tem &erase
 TV,IMAGE

      END

'AUTO' : begin
    WIDGET_CONTROL,info.sourcewin,GET_UValue=SOURCE_IMAGE
LOADCT,39
    w=[[-1,-1,-1],[-1,8,-1],[-1,-1,-1]] & s=1
    C=SOBEL(SOURCE_IMAGE);CONVOL(SOURCE_IMAGE,W,S)
    SIZ=SIZE(SOURCE_IMAGE) & N=SIZ(1) & M=SIZ(2)
    posi=where(c ne 0)
    XPTS=POSI MOD N
    YPTS=POSI / N
    theta=FINDGEN(51)/50*!PI-!pi/2
    ; Set up a vector in degrees for plotting
    degrees=theta*180/!pi
    ; Set up arrays of cosine and sine values
    cosv=cos(theta)
    sinv=sin(theta)
    WIDGET_CONTROL,info.drawTE,GET_VALUE=tem
        WSET,tem & erase
        PLOT,degrees,xpts[0]*cosv+ypts[0]*sinv,xrange=[-90,90],$
        YRANGE=[-SQRT(N^2+M^2),SQRT(N^2+M^2)],xticklen=1,yticklen=1,$
        xticks=4,xtickv=[-90,-45,0,45,90],/nodata,$
        TITLE='Parameter Space (Polar coordinate)', Xtitle='Angle',Ytitle='Ro'
        kpts=MIN([N_ELEMENTS(xpts),N_ELEMENTS(ypts)])

      ; Plot the parametric curves for each data point
        FOR k=0,kpts-1 DO $
        OPLOT,degrees,xpts[k]*cosv+ypts[k]*sinv,color=FIX(k/FLOAT(KPTS)*255)
    QUAN_ang=2 & QUAN_RO=2; & THRESHOLD=30

    BIN_ANG=180/QUAN_ANG
    ACC=FLTARR(kpts,BIN_ANG,QUAN_ANG) ;BIN_ANG IS HOW MANY CELL FOR ANGLE
     ;SIZE OF ANGLE FOR ACCUMULATOR CELL
    ANGLE=INDGEN(QUAN_ANG) ;QUANTIZE
    maxro=sqrt(n^2+m^2)
    PRINT,'MAXRO',MAXRO
    print,'angle',ANGLE
    FOR I=0, KPTS-1 DO BEGIN
    FOR J=0, BIN_ANG-1 DO BEGIN
    ACC[i,J,*]=XPTS[I]*COS((ANGLE+J*QUAN_ANG-90)*!PI/180.)+YPTS[I]*SIN((ANGLE+J*QUAN_ANG-90)*!PI/180.)
    ENDFOR
    ENDFOR

    HELP,ACC
    MIN_RO=MIN(ACC)
    MAX_RO=MAX(ACC)
    RO_RANGE=ABS(MIN(ACC))+ABS(MAX(ACC))
    BIN_RO=FIX(RO_RANGE/QUAN_RO)
    RE=INTARR(BIN_RO)
    ;LOC_CO=INTARR(KPTS)
    PRINT,'RO RANGE',RO_RANGE
    print,'BIN_ANG=',BIN_ANG,'   BIN_RO=',BIN_RO
    ;FOR I=0, BIN_RO-1 DO BEGIN
    COUNTED=INTARR(BIN_ANG,BIN_RO)

    FOR J=0, BIN_ANG-1 DO BEGIN
    FOR K=0,BIN_RO-1 DO BEGIN
    RE=WHERE((ACC[*,J,*] LT (QUAN_RO*(K+1)+MIN_RO)) AND (ACC[*,J,*] GE (QUAN_RO*(K)+MIN_RO)),COUNT)
    COUNTED[J,K]=COUNT
    ENDFOR
;print,'number',FIX((BIN_ANG)/10)
CASE J OF
0*FIX((BIN_ANG)/10)  : BEGIN
WIDGET_CONTROL,info.destinationwin,GET_VALUE=tem
        WSET,tem & erase
        fname=FILEPATH('NUM9.TIF',SUBDIRECTORY='DATA')
        IM=READ_TIFF(FNAME)
        TV,IM
        END
1*FIX((BIN_ANG)/10)  : BEGIN
WIDGET_CONTROL,info.destinationwin,GET_VALUE=tem
        WSET,tem & erase
        fname=FILEPATH('NUM8.TIF',SUBDIRECTORY='DATA')
        IM=READ_TIFF(FNAME)
        TV,IM
        END
2*FIX((BIN_ANG)/10)  : BEGIN
WIDGET_CONTROL,info.destinationwin,GET_VALUE=tem
        WSET,tem & erase
        fname=FILEPATH('NUM7.TIF',SUBDIRECTORY='DATA')
        IM=READ_TIFF(FNAME)
        TV,IM
        END
3*FIX((BIN_ANG)/10) : BEGIN
WIDGET_CONTROL,info.destinationwin,GET_VALUE=tem
        WSET,tem & erase
        fname=FILEPATH('NUM6.TIF',SUBDIRECTORY='DATA')
        TV, READ_TIFF(FNAME)
        END
4*FIX((BIN_ANG)/10) : BEGIN
WIDGET_CONTROL,info.destinationwin,GET_VALUE=tem
        WSET,tem & erase
        fname=FILEPATH('NUM5.TIF',SUBDIRECTORY='DATA')
        TV, READ_TIFF(FNAME)
        END
5*FIX((BIN_ANG)/10) : BEGIN
WIDGET_CONTROL,info.destinationwin,GET_VALUE=tem
        WSET,tem & erase
        fname=FILEPATH('NUM4.TIF',SUBDIRECTORY='DATA')
        TV, READ_TIFF(FNAME)
        END
6*FIX((BIN_ANG)/10) : BEGIN
WIDGET_CONTROL,info.destinationwin,GET_VALUE=tem
        WSET,tem & erase
        fname=FILEPATH('NUM3.TIF',SUBDIRECTORY='DATA')
        TV, READ_TIFF(FNAME)
        END
7*FIX((BIN_ANG)/10) : BEGIN
WIDGET_CONTROL,info.destinationwin,GET_VALUE=tem
        WSET,tem & erase
        fname=FILEPATH('NUM2.TIF',SUBDIRECTORY='DATA')
        TV, READ_TIFF(FNAME)
        END
8*FIX((BIN_ANG)/10) : BEGIN
WIDGET_CONTROL,info.destinationwin,GET_VALUE=tem
        WSET,tem & erase
        fname=FILEPATH('NUM1.TIF',SUBDIRECTORY='DATA')
        TV, READ_TIFF(FNAME)
        END
9*FIX((BIN_ANG)/10) : BEGIN
WIDGET_CONTROL,info.destinationwin,GET_VALUE=tem
        WSET,tem & erase
        fname=FILEPATH('NUM0.TIF',SUBDIRECTORY='DATA')
        TV, READ_TIFF(FNAME)
        END
ELSE:
ENDCASE
    ENDFOR
    MAX_COUNT=MAX(COUNTED)
    PRINT,'MAX COUNT =',MAX_COUNT
    b = COUNTED(UNIQ(COUNTED, REVERSE(SORT(COUNTED))))

    ;;;;;;;;;;;
    THRESHOLD=B[13]
    ;;;;;;;;;;;

    ANG=(WHERE(COUNTED GE THRESHOLD,COUNT1) MOD (BIN_ANG))*quan_ang
    RO=(WHERE(COUNTED GE THRESHOLD,COUNT2) / (BIN_ANG))*quan_ro
    ;LOC_CO=WHERE(COUNTED GE THRESHOLD)
    print,'count1',count1,'  count2',count2
    ANG=ANG-90 & RO=RO+MIN_RO
    REGION1=FLTARR(BIN_ANG,BIN_RO)
    ANG_REGION=(WHERE(COUNTED GE THRESHOLD)MOD (BIN_ANG))
    RO_REGION=(WHERE(COUNTED GE THRESHOLD)/ (BIN_ANG))

    REGION1[ANG_REGION,RO_REGION]=255
    REGION1[BIN_ANG-1,*]=0 & REGION1[BIN_ANG-2,*]=0 & REGION1[BIN_ANG-3,*]=0 & REGION1[BIN_ANG-4,*]=0
        LABELED=LABEL_REGION(REGION1,/EIGHT)
        VALUES = LABELED(UNIQ(LABELED, SORT(LABELED)))
    PRINT,'LABEL VALUES ',VALUES
    NO_POINTS=SIZE(VALUES)
    MED_ANG=FLTARR(NO_POINTS(1)-1) & MED_RO=FLTARR(NO_POINTS(1)-1)

    FOR I=1, NO_POINTS(1)-1 DO BEGIN
    LOC_ANG=WHERE(LABELED EQ VALUES[I]) MOD BIN_ANG
    LOC_RO=WHERE(LABELED EQ VALUES[I]) / BIN_ANG
    MED_ANG[I-1]=MEDIAN(LOC_ANG,/EVEN)*QUAN_ANG-90
    MED_RO[I-1]=MEDIAN(LOC_RO,/EVEN)*QUAN_RO+MIN_RO
    ENDFOR

LOADCT,0
    ;WINDOW,4
    WIDGET_CONTROL,info.drawBE,GET_VALUE=tem
        WSET,tem & erase
    PLOT,ANG_REGION*QUAN_ANG-90,RO_REGION*QUAN_RO+MIN_RO,PSYM=2,XRANGE=[-90,90],$
    TITLE='FINDED POINTS IN PARAMETER COORDINATE', Xtitle='Angle',Ytitle='Ro',xticklen=1,yticklen=1
    X=INDGEN(N)
    IMAGE=INTARR(N,M)
    WINDOW,6,TITLE='PLOT OF LINKED LINES',XPOS=600
    Y_TEM=FLTARR(N)

    plot,x,Y_TEM,YRANGE=[0,m],background=255,color=0;,XRANGE=[-100,100],YRANGE=[-100,100]
PRINT,'ANGLE =',MED_ANG
PRINT,'RO    =',MED_RO
    FOR I=0,NO_POINTS(1)-2 DO BEGIN
    CASE SIN((MED_ANG[I])*!PI/180) OF
       0 : BEGIN Y=INDGEN(M)
                  oplot,REPLICATE(MED_RO[I],N),Y,color=0
           END
    ELSE : BEGIN
            Y=((MED_RO[I])-X*COS((MED_ANG[I])*!PI/180))/SIN((MED_ANG[I])*!PI/180)
             oplot,X,y,color=0;,PSYM=3;,COLOR=I+1;IMAGE[*,I]=Y
           END
    ENDCASE

    CASE COS((MED_ANG[I])*!PI/180) OF
     0  : BEGIN Y=REPLICATE(MED_RO[I],N)
                 oplot,X,y,color=0;,PSYM=3;,COLOR=I+1;IMAGE[*,I]=Y
           END
    ELSE : BEGIN Y=((MED_RO[I])-X*COS((MED_ANG[I])*!PI/180))/SIN((MED_ANG[I])*!PI/180)
                 oplot,X,y,color=0;,PSYM=3;,COLOR=I+1;IMAGE[*,I]=Y
           END
    ENDCASE

    ENDFOR
    PRINT,'SIZE OF SOURCE IMAGE',SIZE(SOURCE_IMAGE)
    HELP,IMAGE
    FOR I=0,NO_POINTS(1)-2 DO BEGIN
    CASE SIN((MED_ANG[I])*!PI/180) OF
       0 : BEGIN Y=INDGEN(N)
             IMAGE[REPLICATE(MED_RO[I],N),Y]=255
            END
    ELSE : BEGIN
            Y=((MED_RO[I])-X*COS((MED_ANG[I])*!PI/180))/SIN((MED_ANG[I])*!PI/180)
             IMAGE[X,Y]=255
           END
    ENDCASE

    CASE COS((MED_ANG[I])*!PI/180) OF
      0  : BEGIN Y=REPLICATE(MED_RO[I],N)
                 IMAGE[X,Y]=255
           END
    ELSE : BEGIN Y=((MED_RO[I])-X*COS((MED_ANG[I])*!PI/180))/SIN((MED_ANG[I])*!PI/180)
                 IMAGE[X,Y]=255
           END
    ENDCASE
    IF ABS(MED_ANG[I]) LT 10 AND MED_ANG[I] NE 0 THEN BEGIN
          Y=INDGEN(N)
          X=(MED_RO[I]-Y*SIN(MED_ANG[I]*!PI/180))/COS(MED_ANG[I]*!PI/180)
          IMAGE[X,Y]=255
          END
    IF ABS(MED_ANG[I]) GT 70 THEN BEGIN
          X=INDGEN(N)
          Y=((MED_RO[I])-X*COS((MED_ANG[I])*!PI/180))/SIN((MED_ANG[I])*!PI/180)
          IMAGE[X,Y]=255
          END
    ENDFOR
 

        WIDGET_CONTROL,info.destinationwin,GET_Value=tem
        WIDGET_CONTROL,info.destinationwin,Set_UValue=IMAGE
        WSET, tem &erase
    TV,image
    end
 

'2 x': BEGIN
WIDGET_CONTROL,info.sourcewin,GET_UValue=SOURCE_IMAGE
SIZ=SIZE(SOURCE_IMAGE)
N=SIZ(1) & M=SIZ(2)
B=CONGRID(SOURCE_IMAGE,N*2,M*2)
WIDGET_CONTROL,info.destinationwin,GET_Value=tem
    WIDGET_CONTROL,info.destinationwin,Set_UValue=B
    WSET, tem &erase
    tvSCL,b

end
'3 x': BEGIN
WIDGET_CONTROL,info.sourcewin,GET_UValue=SOURCE_IMAGE
SIZ=SIZE(SOURCE_IMAGE)
N=SIZ(1) & M=SIZ(2)
B=CONGRID(SOURCE_IMAGE,N*3,M*3)
WIDGET_CONTROL,info.destinationwin,GET_Value=tem
    WIDGET_CONTROL,info.destinationwin,Set_UValue=B
    WSET, tem &erase
    tvSCL,b
end
'4 x': BEGIN
WIDGET_CONTROL,info.sourcewin,GET_UValue=SOURCE_IMAGE
SIZ=SIZE(SOURCE_IMAGE)
N=SIZ(1) & M=SIZ(2)
B=CONGRID(SOURCE_IMAGE,N*4,M*4)
WIDGET_CONTROL,info.destinationwin,GET_Value=tem
    WIDGET_CONTROL,info.destinationwin,Set_UValue=B
    WSET, tem &erase
    tvSCL,b
end
 

ENDCASE
IF what NE 'DONE' THEN WIDGET_CONTROL,event.top,SET_UVALUE=info
END

PRO IMAGEDEMO

; Create a base widget
tlb=WIDGET_BASE(TITLE='Image Processing Demonstration',COLUMN=1)

; Create a buton base
buttonBase=WIDGET_BASE(tlb,ROW=1,FRAME=1)
filebtn=WIDGET_BUTTON(buttonBase,VALUE='FILE',MENU=1)
newbtn=WIDGET_BUTTON(filebtn,VALUE='NEW')
save1=WIDGET_BUTTON(filebtn,VALUE='SAVE IMAGE')
switchbtn=WIDGET_BUTTON(buttonBase,VALUE='SWITCH',MENU=1)
onetwo=WIDGET_BUTTON(switchBtn,VALUE='1-2')
onethree=WIDGET_BUTTON(switchBtn,VALUE='1-3')
onefour=WIDGET_BUTTON(switchBtn,VALUE='1-4')
onefive=WIDGET_BUTTON(switchBtn,VALUE='1-5')
twothree=WIDGET_BUTTON(switchBtn,VALUE='2-3')
twofour=WIDGET_BUTTON(switchBtn,VALUE='2-4')
twofive=WIDGET_BUTTON(switchBtn,VALUE='2-5')
threefour=WIDGET_BUTTON(switchBtn,VALUE='3-4')
threefive=WIDGET_BUTTON(switchBtn,VALUE='3-5')
fourfive=WIDGET_BUTTON(switchBtn,VALUE='4-5')
filterBtn=WIDGET_BUTTON(buttonBase,VALUE='FILTER',MENU=2)
highPass=WIDGET_BUTTON(filterBtn,VALUE='HIGHPASS')
lowPass=WIDGET_BUTTON(filterBtn,VALUE='LOWPASS')
unsharp=WIDGET_BUTTON(filterBtn,VALUE='UNSHARP')
laplacian=WIDGET_BUTTON(filterBtn,VALUE='LAPLACIAN')
vedge=WIDGET_BUTTON(filterBtn,VALUE='VERTICAL EDGES')
hedge=WIDGET_BUTTON(filterBtn,VALUE='HORIZONTAL EDGES')
sobel=WIDGET_BUTTON(filterBtn,VALUE='SOBEL')
medianbtn=WIDGET_BUTTON(filterBtn,VALUE='MEDIAN')
processBtn=WIDGET_BUTTON(filterBtn,VALUE='CUSTOM')
arithBtn=WIDGET_BUTTON(buttonBase,VALUE='ARITHMETIC',MENU=1)
add12=WIDGET_BUTTON(arithBtn,VALUE='ADD 1+2')
addimg=WIDGET_BUTTON(arithBtn,VALUE='ADD 1+3')
add23=WIDGET_BUTTON(arithBtn,VALUE='ADD 2+3')
subimg=WIDGET_BUTTON(arithBtn,VALUE='SUBTRACT 1-3')
addnoise=WIDGET_BUTTON(buttonbase,VALUE='ADD NOISE')
;-------------------
labelbtn=widget_button(buttonbase,value='LABEL REGION',menu=1)
Hrlabelbtn=widget_button(labelbtn,value='LABEL REGION')
Mdlabelbtn=widget_button(labelbtn,value='MODIFIED LR')
histobtn=widget_button(buttonbase,value='HISTOGRAM',MENU=1)
hisSource=widget_button(histobtn,value='HISTOGRAM OF SOURCE WINDOW')
histoEqual=widget_button(histobtn,value='HISTOGRAM EQUALIZATION')
hisONE=widget_button(histobtn,value='ONE THRESHOLD')
hisTWO=widget_button(histobtn,value='TWO THRESHOLDS')
colortb=widget_button(buttonbase,value='COLOR TABLE')
houghbtn=widget_button(buttonbase,value='HOUGH',MENU=1)
houghMAN=widget_button(houghbtn,value='MANUAL')
houghAUTO=widget_button(houghbtn,value='AUTO')
zoombtn=widget_button(buttonbase,value='ZOOM',MENU=1)
zoom2=widget_button(zoombtn,value='2 x')
zoom3=widget_button(zoombtn,value='3 x')
zoom4=widget_button(zoombtn,value='4 x')
;-------------------
donebtn=WIDGET_BUTTON(buttonBase,VALUE='DONE')

; Build a set of exclusive buttons to select the source window
btnBase=WIDGET_BASE(tlb,ROW=2)
text1=WIDGET_LABEL(btnBase,VALUE='Source Window:      ')
btnNames=['ONE','TWO','THREE','FOUR','FIVE']
select1=CW_BGROUP(btnBase,btnNames,/EXCLUSIVE,ROW=1,/NO_RELEASE)
WIDGET_CONTROL,select1,SET_VALUE=0

; Build a set of exclusive buttons to select the destination window
text1=WIDGET_LABEL(btnBase,VALUE='Destination Window:')
select2=CW_BGROUP(btnBase,btnNames,/EXCLUSIVE,ROW=1,/NO_RELEASE)
WIDGET_CONTROL,select2,SET_VALUE=0

graphicsBase=WIDGET_BASE(tlb,ROW=2)
wid=320 & ht=300
DRAW1=WIDGET_DRAW(graphicsBase,XSIZE=wid,YSIZE=ht,UVALUE=BYTARR(wid,ht))
DRAW2=WIDGET_DRAW(graphicsBase,XSIZE=wid,YSIZE=ht,UVALUE=BYTARR(wid,ht))
DRAW3=WIDGET_DRAW(graphicsBase,XSIZE=wid,YSIZE=ht,UVALUE=BYTARR(wid,ht))
DRAW4=WIDGET_DRAW(graphicsBase,XSIZE=wid,YSIZE=ht,UVALUE=BYTARR(wid,ht))
DRAW5=WIDGET_DRAW(graphicsBase,XSIZE=wid,YSIZE=ht,UVALUE=BYTARR(wid,ht))
DRAW6=WIDGET_DRAW(graphicsBase,XSIZE=wid,YSIZE=ht,UVALUE=BYTARR(wid,ht))
info={drawTL:draw1,drawTR:draw2,drawBL:draw3,drawBR:draw4,drawTE:draw5,drawBE:draw6,new:newbtn,$
  done:donebtn,filterBtn:filterbtn,medianBtn:medianBtn,$
  processBtn:processBtn,SourceBtn:select1,sourcewin:draw1,$
  DestinationBtn:select2,destinationwin:draw1}
WIDGET_CONTROL,tlb,Set_UValue=info
WIDGET_CONTROL,TLB,/REALIZE
XManager,'IMAGEDEMO',tlb,/NO_BLOCK
END
 

Table of Contents | Thesis