etl-0442 'classification of selected radar imagery

32
UG470 USd no . 04 42 U S-CE-CProperty of United States Governmen TL-0442 Classification of selected radar imagery patterns using a binary tree classifier Neil D. Fox October 1986 APPROVED FOR PUBLIC RELEASE; DISTRIBUTION IS UNLIMITED Prepared for Library Branch Technical Informati on Center U.S. Anny Engineer Waterways Experiment Station Vicksburg, Mississippi U.S. ARMY CORP OF ENGINEERS ENGINEER TOPOGRAPHIC LABORATORIES FORT BELVOIR, VIRGINIA 22060-5546

Upload: others

Post on 21-May-2022

10 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: ETL-0442 'Classification of selected radar imagery

UG470 USd no . 0442 U S-CE-CProperty of

United States Governmen

TL-0442

Classification of selected radar imagery patterns using a binary tree classifier

Neil D. Fox

October 1986

APPROVED FOR PUBLIC RELEASE; DISTRIBUTION IS UNLIMITED

Prepared for

Library Branch Technical Information Center

U.S. Anny Engineer Waterways Experiment Station Vicksburg, Mississippi

U.S. ARMY CORP OF ENGINEERS ENGINEER TOPOGRAPHIC LABORATORIES FORT BELVOIR, VIRGINIA 22060-5546

Page 2: ETL-0442 'Classification of selected radar imagery

UNCLASSIFIED SECURITY CLASSIFICATION OF THIS PAGE (When Data Entered)

REPORT DOCUMEN.T A TION PAGE READ INSTRUCTIONS BEFORE COMPLETING FORM

1. REPORT NUMBER r GOVT ACCESSION NO. 3. RECIPt EN T'S CATALOG NUMBER

ETL-0442

4. TITLE (and Subtitle) 5. TYPE OF REPORT & PERIOD COVERED

CLASSIFICATION OF SELECTED RADAR IMAGERY PATTERNS I Research Note USING A BINARY TREE CLASSIFIER n.::>(" A':\ - SPn AL..

6. PERFORMING ORG. REPORT NUMBER

7. AUTHOR(•) 8. CONTRACT OR GRANT NUMBER(•)

Neil D. Fox

9. PERFORMING ORGANIZATION NAME AND ADDRESIS 10. PROGRAM ELEMENT, PROJECT, TASK AREA & WORK UNIT NUMBERS

u. s. Army Engineer Topographic Laboratories Fort Belvoir, Virginia 22060-5546

·-11. CONTROLLING OFFICE NAME AND ADDRESS 12. REPORT DATE

U.S. Army Engineer Topographic Laboratories October 1986 Fort Belvoir, Virginia 22060-5546 13. NUMBER OF PAGES

31 14. MONITORING AGENCY NAME & ADDRESS(lf dllterent from Controllln/l Oltlce) 1S. SECURITY CLASS. (of thl• report)

Unclassified

1Sa. DECLASSI FICATlON/ DOWNGRADING SCHEDULE

16. DISTRIBUTION STATEMENT (of th/a Report)

·-17. DISTRIBUTION STATEMENT (of the ebetract entered In Block 20, If different from Report)

18. SUPPLEMENTARY NOTES

19. KEY WORDS (Continue on revere• aide If nec .. Hry and Identify by block number) Binary Decision Tree Bayes Classifier Radar Imagery Feature Selection

2Q. ABS~ACT (Coatlml• ..., reYerea el.tlo ff,..,.,.. • ..,.. - ldenlllT by block number) This report details the results of classifying radar i!llagery using a binary tree classifier. It was found that this classification algorithm works well with radar imagery, which would indicate a normal (Gaussian) feature vector distribution. The number of elements in each feature vector is the limiting factor, classification time is negligible once the tree structure has been created.

DD FORM IJAN'n 1'73 EDITION OF I NOV 6S IS OBSOLETE UNCLASSIFIED

SECURITY CLASSIFICATION OF THIS PA'>E (lf'hen Date Entered)

Page 3: ETL-0442 'Classification of selected radar imagery

PREFACE

This work reported on was done under DA Project 4A 161102B52C, Task B, Work Unit 0015, "Automated Radar Feature Extraction."

The work was performed during the period December 1983 to September 1984 under the supervision of Dr. Frederick W. Rohde, Team Leader, Center for Physical Sciences, and Dr. Robert D. Leighty, Director, Research Institute.

COL Alan L. Laubscher, CE, was Commander and Director, and Mr. Walter E. Boge was Technical Director of the U.S. Army Engineer Topographic Laboratories during the report preparation.

Page 4: ETL-0442 'Classification of selected radar imagery

PREFACE

ILLUSTRATIONS

INTRODUCTION

DESIGN

IMAGERY USED FOR TEST

RESULT

CONCLUSIONS

REFERENCES

CONTENTS

APPENDIX A. Data for Creation of Decision Tree APPENDIX B. Software Listing

ii

PAGE

ii i

l

l

4

5

5

5

10 14

Page 5: ETL-0442 'Classification of selected radar imagery

ILLUSTRATIONS

FIGURE TITLE PAGE

Creating the Binary Decision Tree 1

2 Flowchart of Classifier 3

3 Decision Tree for Image samples from Huntsville, AL 6

4 Decision Tree for Image Samples from Elizabeth City, NC 7

5 Classified Results for Image Samples from Huntsville, AL 8

6 Classified Results for Image Samples from Elizabeth City, NC 9

iii

Page 6: ETL-0442 'Classification of selected radar imagery

CLASSIFICATION OF SELECTED RADAR IMAGERY PATTERNS USING A BINARY TREE CLASSIFIER

INTRODUCTION

By using hierarchical clustering, it is possible to improve the classification results of a single-stage classifier. The inefficiency of the single-stage classifier is in part due to the simultaneous use of all feature vector components. By using a decision tree, only the features best suited to separate the classes at a node are used.

A decision tree is a set of nodes that represent a set offeature vectors in the training set. The root node contains all the vectors in the set. This root node is then clustered into two new nodes (called "sons"), and hence, two new "subclasses" are formed. The subclasses are further clustered until only terminal nodes (those with a dominant class) remain.

An unknown sample enters the tree at the root node. A decision rule is used to classify the feature vector downward in the tree to either the left or right son. This process of sending the sample down the tree is repeated until it reaches a terminal node. It then is classified to be the same class as the dominant class of that node.

Feature selection is done at each node. Ideally, all combinations of feature vector components should be tested, but this becomes impractical owing to time constraints when the number of feature vector components become large. Fortunately, the number of feature vector components necessary to classify radar imagery can be small.

Since an assumption of hierarchical classes is made, a Bayes classifier was chosen to take advantage of the normal distribution one expects in such a system. Also, only the mean vector and covariance matrix need be computed for each node.1

DESIGN

The feature vector components chosen for the tree are

1. Covariance. 2. Skewness. 3. The number of lines detected by a Hough transform. 4. The average pixel value. 5. The number of pixels over a threshold value.

The clustering was done with a K-means algorithm, (k=2).

The decision rule2 is

XE wi iff d 1 (X) > d2 (X), i=l, 2 and j=2,l

di(X) = 1 n p(wi) - Yi 1 n I ~i I - Yi (X-gi) T ~ c1 (X-g i)

Where wi is class i,

X is the unknown sample,

~i is the covariance matrix of the ith class, and

µ· is the mean vector of the ith class, -1

p( wi) is the a priori probability of X EW i.

1 Jack K. Mui and King-Sun Fu, "Automated Classification of Nucleated Blood Cells Using a Binary Tree Classifier," IEEE Transactions on Pattern Analysis and Machine Intelligence, Vol. PAMI-2, No. 5, Sep, pp. 429-442, 1980.

2 J. T. Tou and R. C. Gonzales, "Pattern Recognition Principles", Addison-Wesley Publishing Company, Reading, Massachusetts, 1974.

Page 7: ETL-0442 'Classification of selected radar imagery

INPUT TRAINING SET

FEATURE SELECTION

K-MEANS CLUSTERING ALGORITHM

STORE LEFT AND RIGHT SONS

CREATE MEAN VECTOR AND COVARIANCE MATRIX FOR

EACH NODE

STORE TREE STRUCTURE, MEAN VECTORS, AND COVARIANCE MATRICES

ON FILE

FIGURE 1. Creating the Binary Decision tree.

2

UPDATE PRESENT

NODE

Page 8: ETL-0442 'Classification of selected radar imagery

Ci)

1

INPUT VECTOR (unknown classification)

SET PRESENT NODE TO ROOT NODE OF

TREE

BAYES CLASSIFIER AT PRESENT NODE

SET PRESENT NODE TO LEFT SON

SET PRESENT NODE TO RIGHT SON

PRINT THE CALCULATED CATAGORY TO WHICH THE UNKNOWN SAMPLE

BELONG

FIGURE 2. Flowchart of classifier.

3

NO

Page 9: ETL-0442 'Classification of selected radar imagery

The program was automated to execute all feature selection. The selection was done on the basis of how well classes were separated after clustering. The formula used is

where

I k J k I+J I In log In+ I+J I Jn log Jn

n=l n=l

I = number of vectors at left son from category n n

J = number of vectors at right son from category n n

I = number of vectors at left son

J = number of vectors at right son

k = number of categories in training set

A good separation is indicated by a large number.

The four categories of samples used for testing the tree classifier are

1. forest. 2. field. 3. water. 4. city.

The algorithms used in creating the tree and the flowchart of the tree classifier are shown in figures 1 and 2, respectively.

IMAGERY USED FOR TEST

The proposed binary tree classifier was applied to two selected sets of high resolution synthetic aperture radar imagery taken over the Huntsville, Alabama, and the Elizabeth City, North Carolina, areas with the APD-10 and the UPD-4 radar systems, respectively. Sections of the radar imagery were digitized and stored on a disk unit. A Lexidata System 3400 display processor was used to display the images on a cathode ray tube. Software was written to take 100 samples for each of four terrain classes from imagery displayed on the screen. Each image sample consisted of 32 by 32 pixels that were located within a section of one particular terrain class. The four classes considered were (1) cities (combination of commercial and residential structures, DLMS category #504 FIC 301 and #505 FIC 401), (2) fields (agriculture used primarily for crop and pasture land, DLMS category #510 FIC 950), (3) water (rivers with smooth fresh water, DLMS category #510 FIC 940 and fresh water subject to ice, lakes and reservoirs, DLMS category #510 FIC 943), and (4) forests (mixed trees, deciduous and evergreens, DLMS category #510 FIC 954). A feature vector consisting of 15 components was computed for each sample. These 15 components were made up of the first- and second-order gray level histogram statistics computed from each sample. These components were then used as the input for the binary tree classifier.

4

Page 10: ETL-0442 'Classification of selected radar imagery

RESULTS

Two sets of radar imagery (Huntsville, Alabama and Elizabeth City, North Carolina) were used to create two binary decision trees. The resulting trees are shown in figures 3 and 4, and the results of classifying the training sets are shown in figures 5 and 6.

Often, only one or two feature vector components were used at a node, which illustrates the advantage of using a hierarchical approach rather than the traditional single-stage classifier. For example, although thresholding was an excellent feature vector component when separating water from field, forest, and city, it was a poor feature with respect to the separation of city and forest.

The overall classification accuracy for the Huntsville image samples was 99.25 percent and for the Elizabeth City samples, 98.50 percent.

CONCLUSIONS

1. A binary tree classifier can be used to classify a selected set of radar images with high accuracy as illustrated. However, a new tree hierarchy will be needed if a new set of images from a different geographical area is to be classified optimally with a reasonably high accuracy.

2. Only the most pertinent feature vector components should be used at each node. This reduces processing time and improves classification accuracy.

3. An automated classifier is practical if a small set of feature vector components is used. For vectors with a large number of features, some human interaction in feature selection may be necessary to avoid lengthy processing time. The create-tree program took approximately 11 minutes to finish a tree using five features.

4. This work represents an application of a recently developed statistical classification method. A possible limitation is_ the_requirement_tncreate_anew tru_hierarchyfor_training,__ whenever a new set of images is to be classified with a reasonably high accuracy.

REFERENCES

1. Jack K. Mui and King-Sun Fu, "Automated Classification of Nucleated Blood Cells Using a Binary Tree Classifier," IEEE Transactions on Pattern Analysis and Machine Intelligence, Vol. PAMI-2, No. 5, Sep, pp. 429-442, 1980.

2. J. T. Tou and R. C. Gonzales, Pattern Recognition Principles, Addison-Wesley Publishing Company, Reading, Massachusetts, 1974.

5

Page 11: ETL-0442 'Classification of selected radar imagery

FIGURE 3. Decision tree for image samples from Huntsville, AL.

6

Page 12: ETL-0442 'Classification of selected radar imagery

' I ""@

. ·mage samples tree for i Decision FIGURE 4. 7 beth City, NC. from Eliza

Page 13: ETL-0442 'Classification of selected radar imagery

~~UE CA~ CIT I FIE T WAT FOR

!REC~ I ' I FIE -

-· t - . -

I ' l

98 0 I 1 0

I -

00 WAT 2 100 0 0 I •

I I I

' -~ i -I

I i

FOR 0 0 99 0 (

!

'

I ' •

I i i

I I

CIT 0 ---r- 0 0 100 l

L-......L...-_-....1-_ ___,,__ _____ ,_J FIGURES. CJassified results for image S&JI\plc$,f,rom Huntsville, AL.

Page 14: ETL-0442 'Classification of selected radar imagery

\0

---.------WAT FOR CIT

FIE 100 0 1 0

I

I -i-

WAT 0 100 0 I 0

FOR t- 0 0 96 2 I

--------------------- -+-------------------

i I

I .

CIT 0 0 3 98

----------------· --------------- ---------------·-- --------·------FIGURE 6. Classififd results for image samples from Elizabeth City, NC.

Page 15: ETL-0442 'Classification of selected radar imagery

Node#

2

3

4

5

6

9

10

11

12

17

22

24

27

Appendix A. Data for Creation of Decision Tree

Key: HOU

SKW

COY

THRSH

AVV

Huntsville, Alabama

Features Used in Separation of Node

THRSH, HOU, COY

THRSH, HOU

HOU

AVV, THRSH, HOU

AVV, SKW, THRSH

SKW

SKW

SKW

HOU

THRSH

HOU

'THRSH, HOU

AVV

AVV

- Hough Transform

- Skewness

- Covariance

- Threshold

- Average Pixel Value.

10

Page 16: ETL-0442 'Classification of selected radar imagery

Appendix A. (Cont'd)

Elizabeth City, North Carolina

Node# Features Used in Separation of Node

1 SKW

2 THRSH

4 HOU

5 AVV, THRSH

6 AVV, COV

7 AVV, HOU

8 AVV

9 SKW,HOU

10 AVV,SKW

11 SKW, HOU, COV

13 THRSH

15 AVV

19 AVV

20 cov 21 SKW

24 SKW

27 SKW

28 AVV, THRSH

31 AVV,SKW

11

Page 17: ETL-0442 'Classification of selected radar imagery

Appendix A. (Con't)

Elizabeth City, North Carolina

NODE# WATER FOREST CITY FIELD

1 100 100 100 100 2 0 100 100 100 3 100 0 0 0 4 0 12 0 100 5 0 88 100 0 6 0 63 2 0 7 0 25 98 0 8 0 19 24 0 9 0 6 74 0

10 0 9 21 0 11 0 10 3 0 12 0 5 0 0 13 0 7 0 100 14 0 1 17 0 15 0 8 4 0 16 0 1 0 100 17 0 6 0 0 18 0 0 67 0 19 0 6 7 0 20 0 2 2 0 21 0 4 5 0 22 0 8 1 0 23 0 0 3 0 24 0 2 5 0 25 0 2 0 0 26 0 8 0 0 27 0 2 3 0 28 0 45 2 0 29 0 18 0 0 30 0 17 0 0 31 0 28 2 0 32 0 27 0 0 33 0 1 2 0 34 0 0 5 0 35 0 2 0 0 36 0 2 0 0 37 0 0 3 0 38 0 0 2 0 39 0 2 0 0

Vector Distribution at Each Node of Decision Tree

12

Page 18: ETL-0442 'Classification of selected radar imagery

Appendix A. (Con't)

Huntsville, Alabama

NODE# WATER FOREST CITY FIELD 1 100 100 100 100 2 5 100 100 97 3 95 0 0 3 4 5 10 88 95 5 0 90 12 2 6 0 10 88 95 7 5 0 0 0 8 0 0 0 95 9 0 10 88 0

10 0 7 12 0 11 0 83 0 2 12 0 10 25 0 13 0 0 63 0 14 0 10 0 0 15 0 0 25 0 16 0 4 0 0 17 0 3 12 0 18 0 0 0 2 19 95 0 0 1 20 0 3 0 0 21 0 0 12 0 22 0 62 0 2 23 0 21 0 0 24 0 13 0 2 25 0 49 0 0 26 0 2 0 0 27 0 11 0 2 28 0 10 0 0 29 0 1 0 2

Vector Distribution at Each Node of Decision Tree

13

Page 19: ETL-0442 'Classification of selected radar imagery

Appendix B. Software Listing

~TRECJ T=00004 IS ON CR00024 USING 00030 BLKS R=OOOO

or·"t FTN4X ~ 2 PROGRAM TREC3 0003 c 0004 c ooos 0006 0007 0008 0009 0010 0011 0012 0013 0014

c c c

0015 C 0016 c 0017 c 0018 c 0019 c 0020 c 0021 0022 0023 0024 0025 0026 o~ 7

Oi.-8 0029 0030 0031 0032 0033 0034 0035 0036 0037 0038 0039 0040 0041 0042 0043 0044 0045 0046 0047 0048 0049 0050 0051 or-~ 0 L ..i 0054

c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c c

0055 0056 0057 c 0058 c

THIS PROGRAM READS DATA OFF THE DISK WHICH WAS CREATED BY PROGRAM "TREEF". THIS DATA IS USED TO IMPLEMENT A DECISION TREE.

DIMENSION COV<5.5.61>.MEAN<S.61>.IDCB<l44).ITREE<61.2> DIMENSION XIN<400,5>~1DCB4<144>.LABS<4> .INP2<400> DIMENSION LUOT<S>.LL(4.61>.LABL<4>.WV<S.61>.XS<S> DIMENSION INAME<3~ 1 X<5~~INbEX<61) . . . DIMENSION NODEC61>,MEAN1C5),COV1(5~5>,COV2C25) DIMENSION MEANS<S>,NAME<3> REAL MEAN,MEANl,MEANS

VARIABLE ARRAYS

COV - COVARIANCE MATRICES OF ALL NODES COVl - COVARIANCE MATRIX FOR A NODE BEFORE MASK COV2 - COVARIANCE MATRIX FOR A NODE AFTER MASK INDEX - NUMBER OF VECTORS AT EACH NODE INP2 - LABELS OF VECTORS AT A NODE ITREE - TREE STRUCTURE READ FROM TREE FILE LABL - THE CLASS LABELS READ FROM TREE FILE LABS - THE CLASS LABELS READ FROM PRP FILE <NOT USED> LL - NUMBER OF VECTORS IN A CLASS AT A NODE HEAN - MEANS OF ALL NODES CREAL> MEANl - HEAN OF A NODE BEFORE MASK CREAL> MEANS - HEAN OF A NODE AFTER MASK <REAL> NODE - THE NODE NUMBERS OF THE TREE <NOT USED> WV - THE MASKS FOR ALL NODES READ FROM TREE FILE X - THE VECTOR BEING CLASSIFIED BEFORE MASK XIN - THE VECTORS TO BE CLASSIFIED READ FROM PRP FILE XS - THE VECTOR BEING CLASSIFIED AFTER MASK

VARIABLES

IANS - USER INPUT: ANSWER INDXl - INDEX USED IN PACKING VECTOR VIA THE MASK INDX2 - INDEX USED IN PACKING VECTOR VIA THE MASK IRGT - THE RIGHT NODE OF NODEP KLAC - THE NUMBER OF CLASSES <READ FROM PROPERTY FILE> KLAS - THE NUMBER OF CLASSES <READ FROM TREE FILE> LEFT - THE LEFT NODE OF NODEP LVEC - THE NUMBER OF VECTORS IN THE PROPERTY FILE MAX - THE INDEX NUMBER OF THE DOMINANT CLASS OF A NODE HAXN - THE NUMBER OF VECTORS IN THE DUMINANT CLASS OF A NUDE NELE - NUMBER OF ELEMENTS BEFORE PACKING <USING MASK> NODEP - THE NODE AT WHICH THE VECTOR IS BEING T~STED NUMND - THE NUMBER OF NODES IN THE TREE STRUCTURE

CALL RHPAR<LUOT> CALL ERLUCLUOT>

OPEN FILES AND READ TREE STRUCTURE

14

Page 20: ETL-0442 'Classification of selected radar imagery

0059 c 0060 0061 774 0 n '-2 L ,3 776 0064 0065 778 0066 0067 0 068 1 so 0069 0070 250 0071 0072 0073 0074 0075 0076 0077 0078 0079 0080 0081 0082 0083 0084 0085 0086 0087 2 or""e 0 • . i 3 0090 1 0091 c 0092 0093 c 0094 c 0095 c 0096 c 0097 0098 0099 0100 0101 0102 0103 0104 0105 5 0106 0107 99 0108 c 0109 c 0110 c 0111 0112 c 01~1 c 0. 4 c 0115 10 0116 0117 c 0118 c

Appendix B. (Con't)

WRITECLUOT.774) FORMAT<" ENTER NAHE OF TREE-FILE"> READ<LUOT 1 776>INAME FORMAT<3A2> WRITECLUOT 1 77B> FORMAT<" ENTER PROPERTY FILE TO BE CLASSIFIED"> READCLUOT,776>NAHE WR I TE C LUOT .• 15 0 ) FORMAT<" DO YOU WANT A HARD COPY ?") READ<LUOT.2SO>IANS FOl'tMAT<tAi> IFCIANS.EQ.tHY> LUOT=38 CALL OPEN <IDCB,IERR.INAHE> CALL READF<IDCB 1 IERR 1 KLAS> CALL READFCIDCB,IERR~NUMND> CALL READF<IDCB,IERR,LABL> CALL READF<IDCB,IERR,LL> CALL READFCIDCB,IERR~ITREE> CALL READF<IDCB~IERR,WV> CALL READF<IDCB,IERR,INDEX> DO 1 N=t .• NUMND

CALL READF<IDCB~IERR,NODE<N>> CALL READF<IDCB,IERR,NELE> CALL READF<IDCB,IERR,MEAN1> CALL READF<IDCB,IERR,COVl)

DO 2 I=1,NELE DO 2 J=t ,NELE

COV<I.J.N>=COVt<I.J> DO 3 1~1~NELE .

MEANCI,N>=HEAN1CI> CONTINUE

CALL CLOSECIDCB>

IN~trr THE iolECTORS TO BE CtASSlFIED-

CALL OPENCIDCB4.IERR.NAME> CALL READF<IDCB4,IERR,LVEC> CALL READFCIDCB4,IERR,LELE> CALL READF<IDCB4,IERR,KLAC> CALL READFCIDCB4.IERR.LABS> CALL READF<IDCB4~1ERR~XIN> CALL READFCIDCB4.IERR.INP2> CALL CLOSE<IDCB4) . DO 1223 IVEC=(.LVEC DO 99 IP=t .. NELE X<IP>=XIN<IVEC 1 IP>

PRESENT NODE OPERATED ON IS SET TO "1"

NODEP=t

THE LEFT AND RIGHT CHILD OF EACH NODE IS FOUND

LEFT=ITREE<NODEP~l> IRGT=ITREE<NODEP,2>

SEE IF NODE IS TERMINAL

15

Page 21: ETL-0442 'Classification of selected radar imagery

0119 c 0120 0121 c r ~2 c li.~3 c 0124 012S 0126 so 012? 0128 SS 0129 0130 0131 0132 0133 0134 0135 0136 013? 0138 0139 0140 0141 0142 20 0143 0144 0145 0146 0147 0 8 60 0149 01SO 6S 0151 0152 0153 0154 0155

_ll 1-5-6 0157 0158 01S9 0160 0161 0162 0163 0164 2000 016S c 0166 0167 0168 c 0169 c 01?0 c 01 ?1 c 0172 0. -1 0 •• 4 01?5 0176 01?? c 0178 c

Appendix B. (Con't)

IF< <LEFT.EQ.0).0R.<IRGT.EQ.0) >GOTO 200

FIND DISTANCE FOR LEFT AND RIGHT NODES

DO SO I=1~NELE DO SO J=t .• NELE COV1(I,J>•COV<I.J.LEFT> DO SS i=t,NELE .. HEAN1<I>=HEAN<I,LEFT> INDX1=0 INDX2=0 DO 20 ITEL=t,NELE IF<WV<ITEL.NODEP>.NE.O.O> THEN

INDX1=INDX1+1 HEANS<INDX1>•HEAN1<ITEL> XS<INDX1>=X<ITEL>

END IF DO 20 JTEL=t,NELE IFCWVCITEL~NODEP>.NE.O.AND.WV<JTEL,NODEP>.NE.O> THEN

INDX2=INDX2+1 COV2<INDX2>=COV1CITEL~JTEL>

END IF CONTINUE RLFT=INDEX<ITREECNODEP~1>> ALLV=INDEX<NODEP) CALL HDSTCCOV2~NELE,HEANs~xs~wt~INDX1~N~LE••2~ALLV~RLFT> DO 60 I=1~NELE DO 60 J=t~NELE COV1<I,J>=COV<I,J,IRGT> DO 65 let .• NELE HEANt<I>=HEAN<I,IRGT> INDXt=O INDX2=0 DO 2000 ITEL=t~NELE IF<WV<ITEL~NODEP>.NE.O> THEN

INDX1=1NDX1+1 - tt£ANSC-INDX-t.>-=HE-AK1-( I "!"EL) XS(INDX1>=X<ITEL>

END IF DO 2000 JTEL=1~NELE IF<WVCITEL,NODEP>.NE.O.AND.WV<JTEL,NODEP>.NE.O> THEN

INDX2=1NDX2+1 COV2CINDX2>=COV1CITEL~JTEL>

END IF CONTINUE

RRGT=INDEXCITREECNODEP,2>> CALL HDSTCCOV2,NELE~HEANS,XS,W2~INDX1~NELE••2~ALLV~RRGT>

HAKE THE DECISION OF WHETHER TO HAKE TO LEFT OR RIGHT NODE THE PRESENT NODE

IF<W1.LE.W2> THEN NODEP=LEFT

ELSE NODEP=IRGT

END IF

CLEAR COV2 AND MEANS

16

Page 22: ETL-0442 'Classification of selected radar imagery

0179 c 0180 0181 9000

' l2 0183 9001 0184 c 0185 c 0186 c 0187 0188 c 0189 c 0190 c 0191 200 0192 0193 0194 0195 0196 0197 0198 220 0199 0200 101 0201 c 0202 c 0203 c 0204 1223 0205 c 0206 O?I\? 0 a c 0209 0210 c 0211 c 0212 c 0213 0214 0215 0216 0217 c 0218 c 0219 0220 0221 0222 0223 0224 c 0225 c 0226 c 0227 0228 0229 0230 0231 0232 0 3 0234 0235 0236 0237

DO 9000 I=l~NELE••2 COV2<I>=O .. O DO 9001 I=l~NELE HEANS<I>=O.O

GO TO NEXT NODE

GOTO 10

Appendix B. (Con't)

WRITE THE FINAL DESTINATION OF THE VECTOR

HAX=l MAXN=LL<l~NODEP> DO 220 I=l ~KLAS

IF <MAXN.LT.LL<I,NODEP>> THEN MAX=I MAXN=LLCI,NODEP>

END IF CONTINUE WRITE<LUOT.101) LABLCMAX>.NODEP FORMAT<" CLASS: ",1A2,3X,~3)

REPEAT BY ASKING FOR ANOTHER VECTOR

CONTINUE

STOP END

SUBROUTINE M"DST < COV, NELE .•MEAN~ X 1 W1 INDX1 .• NELEr.1, ALLV .• RORL >

THIS IMPLEMENTS THE MINIMUM DISTANCE CLASSIFIER

DIMENSION COV<NELEQ>,MEAN<NELE>,X<NELE> DIMENSION R<5>,TR<S>,R1<5> DIMENSION L<S>,M<S> REAL HEAN

CALL INV<COV,INDXl,DET,L,M> CALL SUHATCX.MEAN.R.INDXl .1> CALL TRMATCR~TR,IND~l,1,0) CALL PRMAT<TR 1 COV~Rl,1,INDX1,INDX1> CALL PRMAT<R1,R,W,1,INDX1,1>

CALCULATE PROBABLITY

PROB=RORL/ALLV IF<DET.NE.O.O> THEN

W=PROB-<ALOGCABS<DET>>>l2.0-W/2.0 W=-W

ELSE W=PROB+20E20/2.0-W/2.0 W=-W

END IF RETURN END ENDS

17

Page 23: ETL-0442 'Classification of selected radar imagery

Appendix B. (Con't)

TREEF T=00~04 IS ON CR00024 USING 00072 8LKS R=OOOO

1""1 FTN4X t. ~

003 c 004 c 005 c 006 c 007 c 008 c 009 c 010 c 011 c

1012 c 013 c 014 c ;015 C 016 c

.017 c 018 c

1019 c 020 c

1021 c ·022 c

c c c c c c c c c c c

1023 1024 1025 1026 Ir .., lfl-.J 1029 1030 1031 ")032 1033

-JGJ-4 )035 1036 1037 )038 )039 )040 ) 041 J042 )043 1044 )045 1046 )047 )048 l049 JOSO I 051 10-"' Iii , .)Q54 JOSS lOS6 !)057 1058

-c c c c c c c c c c c c c c c c c c c c c c c c c

PROGRAM TREEF

THIS PROGRAM CREATES A BINARY TREE. STRUCTURE AND STORES IT ON DISK. AT EACH NODE A K-MEANS ALGORITHM IS CALLED TO SEPARATE THE VE.CTORS INTO"TWO NEW NODES.

THIS PROGRAM READS IN A PROPERTY FILE CREATED BY PROGRAM 'MKPRP'. THE FORMAT OF THIS FILE IS:

VARIABLE SIZE --------NVEC 1

NELE 1

KLAS 1

LABL KLAS

xx NVEC X NELE x 2

IN1 NVEC

VARIABLE ARRAYS

-Ci -- -woRI< -ARR"AY roR HVCOU C2 -- WORK ARRAY FOR HVCOV COV - COVARIANCE MATRIX IN MVCOV INt - LABEL BUFFER FOR LEFT NODE IN2 - LABEL BUFFER FOR RIGHT NODE IN8 - LABEL BUFFER FOR INPUT TO CLUS INDEX - THE NUMBER 0.F VECTORS Al EACH NODE

DESCRIPTION -----------• OF VE.CTORS

• OF ELEMENTS

• OF CLASSES

NAMES OF CLASSES

VECTORS

VECTOR LABELS I THE.Y IN THE SAHE ORDER AS THE VE.CTORS IN XX.

IREC - STORAGE FOR RECORD THAT CORRESPONDS TO A NUDE NUM~ER ITREE - THE TREE STRUCTURE LABL - THE NAMES <LABELS> OF THE CLASSES LL -- THE NUMBER OF VECTORS IN EACH CLASS AT EACH NODE MEAN - THE MEAN CALCULATED IN HVCOV, THIS IS A REAL ARRAY. MEANt - THE TWO MEANS CALCULATED FROM CLUS, THIS IS A REAL AHRAY. OLDM -- THE OLD HEAN VALUES IN CLUS W -- THE HASKS FOR ALL NODE.S WOLD -- THE PREVIOUS MASK VALUE WHEN IN "SQ" ROUTINE WORTH - STORES HOW WELL SEPARATED EACH NODE IS WPRIH - THE BEST MASK IS STORED HERE AFTER w5gw ROUTINE Xt THE VECTOR BUFFER FOR THE LEFT NODE X2 THE VECTOR BUFFER FOR THE R!GHT NODE XX -- THE VECTOR BUFFER FOR THE NODE BEING CLUSTERED

VARIABLES

1 8

Page 24: ETL-0442 'Classification of selected radar imagery

)059 0060 )061

2

c c c c

)0b3 c 0064 c J065 c 0Q66 c .) 067 c )068 c 0069 c J070 c ·)0'71 c 'l072 c )073 c l074 c 0075 c )076 c 0077 c 1078 c J079 0080 )081 0082 )083 0084 l085 0086 c ·)l\~'7 c 0 3 c )089 0090 c 0091 c 0092 c ~093 0094 0095 0096 c J097 c 0098 c 0099 010 0 c

c c c

) 101 .l102 0103 J104 0105 )106 J107 c l108 c J109 3 )110 c ) 111 c lJ112 c ) : J 114 1115 ) 116 J 117 0118

333

335

Appendix B. (Con't)

ICMND - INPUT FROM USER IN COMMAND LOOP INDt - NUMBER OF VECTORS IN LEFT NODE IND2 - NUMBER OF VECTORS IN RIGHT NODE KLAS - TOTAL NUMBER OF CLASSES KNODE - MAXIMUM NUMBER OF NODES ALLOWED KREC -- PRESENT NUMBER OF RECORDS Nl -- LEFT NODE NUMBER N2 -- RIGHT NODE NUMBER NELE - MAXIMUM NUMBER.OF ELEMENTS NODE - NUMBER OF NODE TO BE CLUSTERED OR OPERAlED ON NVEC - NUMBER OF VECTORS IN PROPERTY FILE OLDVL - THE OLD VALUE OF THE VARIABLE "VALUE" PCLAS - NUMBER OF VECTORS IN DOMINANT CLASS AT A NODE SMSH1 - INTERMEDIATE VARIABLE FOR CALCULATING "VALUE" SMSH2 - INTERMEDIATE VARIABLE FOR CALCULATING "VALUE" VALUE - MEASURE OF THE CLUSTER. LARGE VALUES ARE GOOD. VIN1 - INTERMEDIATE VARIABLE FOR CALCULATING "VALUE" VIN2 - INTERMEDIATE VARIABLE FOR CALCULATING "VALUE" WMIN - THE MINIMUM VALUE OF WORTH<NODE>. THIS IS THE BEST VALUE.

DIMENSION LUOT<S>.XX(400, S>.OLDM( 2. S>.C1( 5. S> DIMENSION IN1<400>,C2<5,5>,COV<S,5>,~EANi<2,5>~1N2<400> DIMENSION LABL<4>,INAME<3>,MEAN<5>,LL(4 1 61>,INB<400>,W<5,61) DIMENSION X1<400,5>,X2<400,5>,ITREE<6t,2>,1NOEX<6t>,WPRIM(~) DIMENSION INAM1<3>,WOLD<5>,WORTH<61) REAL HEAN,MEAN1 DIMENSION IDCB<144>,IDCB1<144>,IDCB2<144>,IREC<100>

SET OLD VALUE TO 0

OLDVL=0.0

SET LEFT, RIGHT, AND STARTING NODE TO INITIAL VALUES

NODE=1 Nt=O N2=1

SET MAX. NODES

KNODE=61

INIT. LU

CALL RMPAR<LUOT> LU=LUOT(1) CALL ERLUCLU>

FORMAT<1A2>

READ FILES

WRITE<LUOT,333) FORMAT<" ENTER NAME OF PROPERTY FILE"> READ<LUOT,334>INAME WRITE<LUOT,335> FORMAT<" ENTER THE FILE-NAME FOR THE TREE STRUCTURE"> READCLUOT,334>INAM1

19

Page 25: ETL-0442 'Classification of selected radar imagery

ll 19 334 l120 0. "'1 )._2 0123 J124 0125 )126 0127 1128 c 1129 c 0130 c J 131 0132 J133 3134 l135 0136 c )137 c J13B C J139 0140 l141 0142 l143 0144 l145 J146

c c c

1192 c c

0 , c J' ~0 0149 c J150 c 0151 c J152 015-3 . c !)154 c 0155 c IJ156 0157 0158 0159 c 0160 c 0161 c 0162 c 0163 c J164 c 0165 c J166 c J167 96 J16B 250 0169 J 170 0171 ,J·-~

iJ. .3 :J 174 3000 0175 0176 0177 0178 c

Appendix B. (Con't)

FORMATC3A2> CALL OPENCIDCB.IERR.INAHE> CALL READF~IDC~ 1 IERk,NVEC> CALL READFCIDCB,IERR,NELE> CALL READF<IDCB,IERR,KLAS> CALL READF<IDCB,IERR,LABL> CALL READF<IDCB,IERR,XX> CALL READF<IDCB,IERR,INl) CALL CLOSE<IDCB>

PURGE OLD AND CREATE NEW SCRATCH FILE

CALL PURGE<IDCB1,IERR,SHXBUFR> CALL PURGE<IDCB2,IERR,SHIBUFC> CALL CREAT<IDCB1,IERR,5HXBUFR,500,3,0,-24) CALL CREAT<IDCB2,IERR,5HIBUFC,500,3,0,-24> IF<IERR.LT.O> WRITE<LUOT,SO>IERR

SET FIRST INDEX

INDEX<NODE>=NVEC

FILL LABEL ARRAY FOR NODE 1

DO 1192 I=1,KLAS LL<I,1>=100

STORE VECTOR NAMES ON SCRATCH FILE

CALL WRITF<IDCB2,IERR,IN1,NVEC>

INITIALIZE RECORD NUMBER

KREC=t

STORE DATA ON SCRATCH FILE

CALL WRITF<IDCB1.IERR.XX.2•NVEC•NELE> IF<IERR.LT.O> WRITE<LUOT~SO>IERR IREC<1>=KREC

ENTER COMMAND LOOP. THE POSSIBLE COMMANDS ARE

LU -- CHANGE OUTPUT DEVICE TR -- TERMINATE PROGRAM SQ -- SEQUENCE W-MASK THROUGH ALL COMBINATIONS AND CREATE TREE CT -- CREATE TREE USING A W-HASK UF ALL l'S <ALL FEATURES USED>

WRITE<LUOT.250) FORMAT<" ENTER COMMAND",/,"??") READ<LUOT,3>ICHND IF<ICHND.EQ.2HSQ> GOTO 252 IF<ICHND.EQ.2HCT> THEN

DO 3000 I=1 .NELE DO 3000 J=1,KNODE W<I.J>=t.O GOTO 252

ENDIF IF<ICHND.EQ.2HTR> STOP

20

Page 26: ETL-0442 'Classification of selected radar imagery

1179 0180 ) 1 O.d2 ·)183 J184 0185 1186 0187 l188 :)189 l190 0191 )192 1193 l194 l19S l196 )197 l19B J199 )200 0201 1202 0203 )204 J205 02'06 ) ?

0~118 1209 J210 0211 J212 '1213 0214 '.)215 •)216 0217 0218 0219 J220 :i221 ll222 0223

256

c c c

c c c 252 4444

7721

5994

c c c

c c c

c

so c

c c c

c c c 770

i224 c

Appendix B. (Con't)

IF<ICMND.EQ.2HLU> THEN READ<LUOT,•>LU

IF<LU.LE.O.OR.LU.GE.39> GOTO 256 END IF

IF NO RECOGNIZABLE COMMAND IS ENTERED, THEN ASK FOR ANOTHER

GOTO 96

SPLIT THE NODE SELECTED INTO TWO NEW NODES

NODE=t IF<ICMND.EQ,2HSQ) THEN

DO 7721 I=t.NELE W<I,NODE>=O.O CALL SEQUN<WOLD,W,NODE,KNODE,NELE>

END IF FORMAT<l,tox,•w MASK =•> ",SF2.0>

N1=N1+2 N2=N2+2

STORE LEFT AND RIGHT CHILD IN ARRAY, "ITREE•

ITREE<NODE.1>=N1 ITREE <NODE .• 2) •N2

FIND CORRECT RECORDS

CALL POSNT<IDCBt.IERR.IREC<~ODE>.t> CALL POSNT<IDCB2,IERR~IREC<NODE>~1>

IF<IERR.LT.O> WRITE<LUOT.50>IERR FORMAT<" FILE-ERROR t",I~>

CALL READF<IDCB1~IERR,XX> IF<IERR.LT.O> WRITE<LUOT,SO>IERR

READ LABELS FOR VECTORS AT THIS NUDE

CALL READF<IDCB2,IERR,INB>

CLUSTER THE VECTORS,

CALL CLUS<XX.NELE.INDEX<NODE>.Xt.IND1.X2.IND2.NODE.N1.N2.MEAN1 S,OLDM,KNODE,~VEC,iNB,IN1,IN2,~> . . . . . . .

J22S IF<ICMND.EQ.2HNX> WRITE<LU,5994><W<K,NODE>~K=t,NELE> 1226 IFCICMND.EQ.2HCT> WRITE<LU,5994><W<K,NODE>,K=1,NELE> l227 c l228 c J229 c J230 ')231 )' ~ c i:: ... J c J234 c j235 l236 J237 J238 29

STORE LEFT AND RIGHT NODE NAMES IN LIST

INDEX<Nt>=INDt INDEX<N2>=IND2

PRINT THE RESULTS OF THE CLUSTERING AND ASK IF IT IS TO BE STORED

DO 27 I=Nt.N2 IF<ICMND.EQ.2HNX> WRITE<LU,29>I IF<ICMND.EQ.2HCT> WRITE<LU~29)1 FORMAT<16X,"NODE t",13)

21

Page 27: ETL-0442 'Classification of selected radar imagery

1239 0 "-A 0 J, 1 )242 1243 0244 J245 0246 1247 J24B 1249 30 0250 c 1251 J252 27 1253 32 Q2S4 C J255 J256 c 1257 c J258 c J259 c )260 0261 l262 0263 J264 0265 J?. c, .:>;:_/ 0268 J269 7225 0270 c 0271 0272 0273 0274 c 0275 c 0276 c 0277 0278 c 0279 c 1.)280 c 0281 c 0282 0283 !)284 6461 028~ 1)286 0287 c 0288 0289 ()290 1)2-. l 055 o::. ~ c 0293 0294 0295 0296 0297 0298 9911

Appendix B. (Con't)

IFCICMND.EQ.2HNX> WRITE<LU,26) <LABLCJ).J=l .KLAS> IF<ICMND.EQ.2HCT) WRITE<LU~26) <LABL<J>~J=t,KLAS> DO 30 NUMK=t,KLAS LL<NUMK .•I >=O DO 30 J=1,INDEXCI) IFCI.EQ.N1> THEN IFCIN1CJ),EQ.LABLCNUMK>>LLCNUMK,I>=LLCNUMK~I>+1

ELSE IFCIN2CJ).EQ.LABL<NUMK>>LL<NUMK,I>=LLCNUMK,I>+1

ENDIF CONTINUE

IFCICMND.EQ.2HNX> WRITECLU.32>CLLCINUMB.I>.INUMB=t.KLAS> IFCICMND.EQ.2HCT) WRITECLU~32)CLL(INUMB~I>~INUMB=1~KLAS> FORMATC12X,4C1X~IJ)~/)

IFCICMND~EQ.2HSQ> THEN

HERE IS THE IMPLEMENTATION OF A· FORMULA THAT WILL TELL HOW GOOD A SEPARATION IS

SMSHl=O.O SHSH2=0. 0 DO 7225 IJ=t .KLAS IFCLL<IJ,Nl>.NE.O> THEN

SMSHl=FLOATCLLCIJ,Nl>>*ALOGT<FLOATCLLCIJ.Nt>>>+SMSHl END IF . . IF<LLCIJ,N2>.NE.O> THEN

SMSH2=FLOATCLLCIJ,N2>>•ALOGTCFLOAT<LLCIJ,N2>>>+SMSH2 END IF . . CONTINUE

JLINJ =F--LOATCIND-1->-IF'l.OA-T< !ND1-+IND2) VIN2=FLOATCIND2>1FLOATCIND1+IND2> VALUE=VINl*SMSH1+VIN2•SMSH2

SET VALUE TO 0 IF IND1 OR 1ND2 IS 0 OR l

IFCINDt.EQ.O.OR.IND2.EQ.O.OR.IND1 .EQ.1.0R.IND2.EQ.1) VALUE=O.O

IF THIS IS THE LARGEST VALUE YET, THEN SAVE THE CORRESPONDING W MASK

IF<VALUE.GT.OLDVL> THEN DO 6461 ISW=l.NELE

WPRIM<ISW>=W<ISW,NODE> OLDVL=VALUE

END IF

CALL SEQUNCWOLD,W,NODE~KNODE,NELE> IGIUIT=l DO toss I=t .NELE IF<WCI.NODE>.EQ.l) IQUIT=O

IFCIQUIT.EQ.l) THEN ICMND=2HNX VALUE:=O.O OLDVL=O. 0 DO 9911 I=t .NELE WCI,NODE>=WPRIM<I>

22

Page 28: ETL-0442 'Classification of selected radar imagery

l299 )- "0 )._,, 1 .)302 c )303 c )304 c 0305 c l306 c J307 c J308 1)309 •)310 c 1311 c 0312 c )313 J314 c )315 c J316 c 1317 0318 c )319 0320 c )321 c 0322 c )323 0324 l325 c )" ; O~c7 C )328 c 0329 c 0330 0331 c )332 c 0333 c 1334 0335 c Q336 c 0337 c 0338 0339 '1340 c J341 0342 c )343 c :;344 c )345 u346 J347 J348 :)349 1350 j;'_l'.... 881

0353 l354 0355 882 B56 24 0357 26 ,)359 c

Appendix B. (Con't)

ENDIF GOTO '770 ENDIF

STORE INFORMATION ON FILE

HOVE TO EDF

CALL POSNT<IDCBl~IERR~KREC+l,1) CALL POSNT<IDCB2,IERR,KREC+1,1>

INCREMENT RECORD NUMBER

KREC=KREC+l

STORE RECORD t

IREC<Nl>=KREC

IF<IERR.LT.O> WRITE<LUOT,SO>IERR

WRITE CLASS ONE VECTORS TO FILE <THESE ARE FROM THE LEFT NODE>

CALL WRITF<IDCB1.IERR,Xl,2*NVEC*NELE> CALL WRITF<IDCB2,IERR,IN1,NVEC>

IF<IERR.LT.O>WRITE<LUOT,SO>iERR

INCREMENT RECORD t

KREC=KREC+t

STORE RECORD t

IREC<N2>=KREC

WRITE CLASS TWO VECTORS ro FILE <RIGHT NODE VECTORS)

CALL WRITFCIDCB1.IERR,X2,2*NVEC*NELE> CALL WRITF<IDCB2,IERR,IN2,NVEC>

IF<IERR.LT.O> WRITECLUOT,SO>IERR

CALCULATE THE STATUS OF EACH NODE

DO 882 I=1.N2 WORTH<I>=O.O PINDX=INDEXCI> IF<INDEX<I>.NE.O> THEN

PCLAS=O. 0 DO 881 J=l.KLAS IF<PCLAS.LT.LLCJ,I>> PCLAS=LL<J,I)

IF<PCLAS.NE.O> WORTH<I>=PCLAS*ALOGT<PCLAS/PINDX> IF<INDEX<I>-PCLAS.EQ.1) WORTH<I>=O .• END IF

CONTINUE FORMAT<3X.20I3,/) FORHATC13X,4<2X,1A2>

23

Page 29: ETL-0442 'Classification of selected radar imagery

0359 c ')360 c 0 1 c ibo2 C 0363 c 0364 0365 c 0366 1)367 0368 1369 0370 0371 9933 J372 IJ373 4923 3374 0375 1)376 c )377 c 0378 c •)379 100 1)380 0381 0382 0383 0384 0385 0386 0 7 0388 0389 0-39-0 -c 0391 c 0392 c 0393 0394 0395 c 0396 c 0397 c 0398 0399 1)400 c 0401 c 0402 c 0403 'J404 c :)405 !)406 91 •)407 0408 1409 ..J410 )411 6119 ij I

>4.J 6117 iJ414 6116 •)415 0416 )417 i)418 c

Appendix B. (Con't)

THE INITIAL MINIMUM VALUE IS SET TO THE PROVIOUSLY CREATED LEFT NODE. THIS IS DONE TO INSURE THAT A NODE WITH ITREE ROOTS OF 0 IS SELECTED.(EG. NO NODES ALREADY DONE CAN 9E DONE AGAlN.>

WMIN=WORTH<Nl>

DO 9933 I=2.N2 IF<ITREE<I.1>.EQ.O.AND.ITREE<l.2>.EQ.O.AND.WORTH<l>.LE.WHIN>THEN

WHIN=WORTH<I> . NODE=I

ENJ>IF CONTINUE IF<ICHND.EQ.2HNX> ICHND=2HSQ FORMAT<15X,"THE NEXT NODE IS",13./> IF<N2.LT.KNODE.AND.WMIN.NE.O.O> WRITE<LU,4923> NODE IF<N2.LT.KNODE.AND.WHIN.NE.O.O> GOTO 4444

PURGE OLD FILES AND STORE NEW DATA IN THEH

CALL PURGE<IDCB,IERR,INAHl> CALL CREAT<IDCB,IERR,INAH1,500,J,0,-24) CALL WRITF<IDCB.IERR.KLAS.1> CALL WRITF<IDCB~IERR~N2,1) CALL WRITF<IDCB,IERR,LABL,KLAS> CALL WRITF<IDC9.IERR.LL.KLAS*KNODE> CALL WRITF<IDCB:IERR~IT~EE.2•KNODE> CALL WRITF<IDCB~IERR:W,2•KNODE•NELE> CALL WRITF<IDCB,IERR,INDEX,KNODE> DO 91 NODE=l .N2 INND=INDEX<NODE>

POSITION AND READ FILES

CALL POSNT<IDCBl,IERR.IREC<NODE>.1> CALL READF<IDCB1~1ERR~XX> .

WRITE NODE t AND t OF FEATURES AT THAT NODE

CALL WRITF<IDCB,IERR,NODE,1> CALL WRITF<IDCB,IERR,NELE,1>

CREATE HEAN VECTOR AND COVARIANCE MATRIX CALL HVCOV<XX,HEAN,COV,C1,C2,NELE,INND,NVEC>

CALL WRITF<IDCB.IERR.HEAN.NELE*2> CALL WRITF<IDCB,IERR~COV,~NELE•*2)•2) CALL CLOSE<IDCB1> CALL CLOSE<IDCB2) CALL CLOSE<IDCB> WRITE<LU,6119><LABL<I>,I=1,KLAS> FORMAT<57X.4<2X.1A2>> DO 6117 I=i.N2. WRITE<LU,61i6> l,<ITREE<I;J>,J=l,2>,<LL<INUH,I>,INUH=l,KLAS> FORMAT<10X,"NODEt",13,SX,"LEFT-->",I3,SX,"RlGHT-->",I3,7X,

f4<1X.I3>> STOP. END

24

Page 30: ETL-0442 'Classification of selected radar imagery

Appendix B. (Con't)

0419 C SUBROUTINE HVCOV 0420 c ( ~1 c ti .. 22 c 0423 C A ----- HEAN VECTOR 0424 C NFC --- DIMENSION OF VECTORS 0425 c c1.c2 - BUFFERS 0426 C C ----- COVARIANCE MATRIX 0427 C NDATA-- NUMBER OF DATA POINTS 0428 C X ----- INPUT VECTORS 0429 c 0430 C SUBROUTINE TO COMPUTE HEAN VECTOR AND COVARIANCE MATRIX 0431 C BASED ON THE INCOMING TEXTURE MEASUREMENT VECTOR,X 0432 c 0433 SUBROUTINE MVCOV<X,A,C,C1,C2,NFC,NDATA,NVEC> 0434 DIMENSION C<NFC,NFC>,C1<NFC,NFC>,C2<NFC,NFC>,A<NFC> 0435 DIMENSION X<NVEC,NFC> 0436 DO 100 1=1,NFC 0437 DO 100 J•1,NFC 0438 Cl<I,J>=O.O 0439 100 C2<I,J>=O.O 0440 DO 10 1=1,NFC 0441 A<I>•O.O 0442 Z=NDATA 0443 DO 20 J=1,NDATA 0444 20 A<I>=A<I>+X(J,1> 0445 10 A<I>=A<I>IZ 0446 DO SO 1=1,NFC 0 7 DO 40 J•t,NFC o~~a C<l,J)•O.O 0449 DO 30 K=l,NDATA 0450 30 C1CI,Ji=C1CI,J>+XCK,I>•XCK,J) 0451 Ct<I,J>•Cl<I,J>IZ 0452 40 CONT!NUE 0453 SO CONTINUE 0454 DO 70 I=1.NFC 0455 DO 60 J=t~NFC 0456 C2CI.J>=A<I>•ACJ) 0457 60 CONTiNUE 0458 70 CONTINUE 0459 DO 90 1=1.NFC 0460 DO 80 J=t.NFC , 0461 C<I,J>=C1Cl,J>-C2<1,J> 0462 80 CONTINUE 0463 90 CONTINUE 0464 RETURN 0465 END 0466 c ~467 C THIS SUBROUTINE TAKES ~ GROUP OF VECTORS AND SEPARATES THEM 0468 C INTO TWO CLASSES. THIS IS DONE WITH A K-HEANS ALGORITHM. 0469 c 0470 SUBROUTINE CLUSCX,NELE,NVEC,X1,INDt,X2,IND2,NODE,N1,N2,MEAN 0471 S,OLDH,KNODE,NVE2,INB,IN1.,IN2,W> :)/ , c J4.J C THIS SUBROUTINE TAKES AN INPUT VECTOR SET." X •,AND 0474 C CLASSIFIES IT'S MEMBERS INTO ONE UF TWO REGIONS. 0475 C DEFINED BY "Xt" AND "X2• VIA A K-HEANS ALG, THIS ROUTINE 0476 C ALSO RETURNS THE TWO HEAN VECTORS IN THE ARRAY "HEAN". )477 c 0478 DIMENSION X<NVE2,NELE>,Xt<NVE2,NELE>,X2CNVE2,NELE)

25

Page 31: ETL-0442 'Classification of selected radar imagery

Appendix B. (Con't)

0479 DIMENSION MEAN<2,NELE>.OLDM<2,NELE>,INB<NVE2) 0480 DIMENSION IN1<NVE2>,IN2CNVE.2>,W<NELE,KNOD~> 0 1 REAL MEAN 04d2 c 0483 c 0484 c 0485 0486 0487 0488 99 0489 0490 0491 10 0492 )493 J494 11 0495 c J496 c 1)497 c )498 c )499 0500 )501 1001 0502 ~503 c 0504 c J50S C 0506 c )~ 100 o5ue lS09 0510 1)511 1)512 JS13 0514 30 l515 0516 )517 0518 )519 0520 )521 40 0522 )523 c \J524 c )525 50 >1526 J527 J528 60 l529 c 1530 20 0531 c J: c i:Lj C 0534 c )535 c l536 0537 J538 5

INITIAL VALUES ARE CHOSEN FOR THE H~AN

DO 99 I•l,2 DO 99 J=1,NELE HEANCI,J>=O.O OLDM< I .. J>=O. 0 DO 10 IELE=l,NELE HEAN<1,IELE>=XC1,IELE) HEANC2,IELE>=X<2,IELE> OK=O. 0 DO 11 1=1,NELE IF<MEAN<1.I>•W<I,NODE>.NE.M~ANC2,I>*W<I,NODE>>OK=1.0

IF THE MEANS ARE THE SAME, INCREMENT THE E.LEH£NTS OF THE FIRST HEAN BY ONE.

IF<OK.EQ.0.0) THEN DO 1001 I=t,NELE HEANC1,I>=HEANC1,I>~1.0

END IF

INITIALIZE INDICES FOR THE TWO NEW CLASSES

IND1=0 IND2=0 DO 20 J=l.NVE.C SQt=O.O SQ2=0. 0 DO 30 I=t .• NELE SQ1=SQ1+<X<J,I>*W<I,NODE>-HEANC1,I>*W<I,NODE.))**2 SQ2=SQ2+CXCJ,I>•W<I,NODE>-MEAN<2,I>•W<I,NODE>>**2 SQ1=SQRTCSQ1) SQ2=SQRTCSQ2) IF < SQ2 .LE. SQl > GOTO SO INDt=INDl+t DO 40 I=l ,NELE IN1CIND1>~INBCJ> X1CIND1,I>=X<J,I> GOTO 20

IND2=IND2+1 DO 60 I=t,NELE IN2 < IND2) :sINB < J> X2CIND2,I>=XCJ,l)

CONTINUE

THE HEAN IS COPIED FOR COMPARISON

DO 5 IELE=t .NELE OLDHC1,IELE>=MEANC1,IELE> OLDHC2,IELE>=HEANC2,IELE)

26

Page 32: ETL-0442 'Classification of selected radar imagery

0539 c ')540 c 0 1 c

0543 )544 14 0545 )546 JS47 tS 0548 0'549 •J5SO 16 0551 c 0552 c 0'553 c 0554 c 0555 0556 0557 oss0 4S 0559 0560 0561 0562 c 0563 c 0564 c 0565 c 0566 c o· ., c O~b8 C 0569 c 0570 c 0571 0572 0573 c 0574 c 0575 c 0576 0577 10 0578 c 0579 0580 0581 0582 1583 0'584 c 1585 0586 J587 0588 30 1)'589 0590 0591 ;):"' ~

o~,J

:1594 1)'595 ·1596 20 0597 0598

Appendix B. (Con't)

A NEW MEAN IS CREATED FOR THE TWO NEW CLASSES

DO 14 K=1,2 DO 14 1=1,NELE MEANCK,I>=0,0 DO 15 i=t,IND1 DO 15 J=1,NELE MEANC1,J>=X1<I,J)/FLOATCIND1>+MEAN<1,J) DO 16 I=l ,IND2 DO 16 J=l,NELE MEAN<2.J>=MEAN<2,J>+X2<I~J)/FLOATCIND2>

IF THE LAST ITERATION IS THE SAME AS THE PRESENT VALUE THEN THE SOLUTION HAS BEEN REACHED AND THE SUBR. RETURNS,

FLAG=O.O DO 45 K•t .2 DO 45 I=1.NELE IF<OLDM<K,I>*W<I,NODE>.NE.MEAN<K,I>*W<I,NODE>>FLAG=1,0 IF <FLAG.EQ.l.O> GOTO 100 RETURN END

THIS SUBROUTINE DOES A BINARY COUNT OF THE W-HASK. THE SEQUENCE IS: 00 CON INITIAL ENTRY>

10 01 11 00

FOR A TWO BIT MASK.

SUBROUTINE SEQUN<WOLD,W,NODE,KNODE,NELE> DIMENSION WCNELE,KNODE>,WOLD<NELEJ

STORE OLD MASK

DO 10 I=t .• NELE WOLD<I>=W<I,NODE>

IFCWOLD<t>.EQ.0.0) THEN W<l,NODE>=t.O

ELSE W < 1 .•NODE> =O. 0

END IF

DO 20 J=2,NELE ITOG=t DO 30 I::st ,J-1 IFCWOLD<I>.EQ.0) ITOG=O IF<ITOG.EQ.1) THEN

IFCWOLD<J>.EQ.0) THEN W<J,NODE>=t

ELSE W(J .• NODE>=O

END IF END IF CONTINUE RETURN END

27