MEASUREMENT OF SUB RESOLUTION EARTHQUAKE DISPLACEMENT USING ASTER DATASET BASED ON THE 2001 EARTHQUAKE OF KUNLUN, CHINA A dissertation submitted to the University College London for the award of the degree of MSc in Remote Sensing. Prepared by Sheikh Nasir B. Kamarudin Supervised by Dr. J.G. Liu UNIVERSITY COLLEGE LONDON DEPARTMENT OF GEOGRAPHY
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
MSc. Remote Sensing Dissertation September 2002
77
MEASUREMENT OF SUB RESOLUTION EARTHQUAKE
DISPLACEMENT USING ASTER DATASET BASED ON THE
2001 EARTHQUAKE OF KUNLUN, CHINA
A dissertation submitted to the University College London for the award of the degree of MSc in Remote Sensing.
Prepared by Sheikh Nasir B. Kamarudin
Supervised by Dr. J.G. Liu
UNIVERSITY COLLEGE LONDON
DEPARTMENT OF GEOGRAPHY
ACKNOWLEDGEMENTS Firstly, I would like to express my gratitude to my supervisors, Dr J.G. Liu and Dr. Philippa Mason of Earth and Resource Department at Imperial College London, for the extensive advice throughout the progress of the study. Thanks to Universiti Teknologi Malaysia and my Chief Department of Remote Sensing, Universiti Teknologi Malaysia, Dr. Mazlan Hashim for his support and encouragements for persueing my studys in United Kingdom. I would like to thank my friend, Issa Al-Qusaimi who has helped me in my dissertation. In the process of building the software, I have sought a lot of advised from Jimmy, PhD Student from Imperial College who has guided me in doing the prototypes. Last but not least, thanks to my family and espeacilly to my wife, Aida for their moral support and everyone who has given their effort to improve me in writing this dissertation.
MSc. Remote Sensing Dissertation September 2002
2
CONTENTS PAGE NUMBER
LIST OF FIGURES 4
LIST OF TABLES 5
ABSTRACT
6
CHAPTER 1 INTRODUCTION 7
1.1. PROJECT AIMS 7
1.2. SCOPE
8
CHAPTER 2 LITERATURE REVIEW 9
2.1. EARTHQUAKES AND PLATE TECTONICS. 9
2.2. MEASUREMENT OF SUB RESOLUTION TERRAIN DISPLACEMENTS USING SPOT PANCHROMATIC IMAGERY
10
2.3. IMAGE RECTIFICATION.
11
CHAPTER 3 DATA DESCRIPTION 12
3.1. BACKGROUND OF KUNLUN 12
3.2. DATA PREPARATION
12
CHAPTER 4 THEORY ON THE CROSS-CORRELATION COEFFICIENT
14
4.1. DEFINITION OF THE CORRELATION 14
4.2. CORRELATION COEFFICIENT 14
4.3. NORMALIZED CROSS CORRELATION (TEMPLATE MATCHING BY CROSS-CORRELATION )
16
4.3.1. DISADVANTAGES OF USING CORRELATION AND TEMPLATE MATCHING
16
4.4. AUTOMATED GCP LOCATION
17
CHAPTER 5 METHODOLOGY 18
5.1. EARTHQUAKE DETECTION ARCHITECTURE 18
5.2. ERMAPPER FORMAT DATASET STRUCTURED 19
5.2.1. ERMAPPER SOFTWARE DEVELOPMENT KIT (SDK) LIBRARY FUNCTION
6.1. STAGE 1 TESTING THE PROTOTYPE WITH THE SAME IMAGE
31
6.2. STAGE 2 TESTING THE PROTOTYPE WITH DIFFERENT IMAGES
32
6.3. COMPUTATIONAL COST 35
6.4. RESULT 36
6.4.1. AREA A GREEN 36
6.4.2. AREA B ORANGE 38
6.4.3. AREA C YELLOW 40
6.4.4. AREA D PURPLE 41
6.4.5. AREA E BLUE 42
6.4.6. SUMMARY 43
6.4.7. FAULT DETECTIONS 44
6.5. DISCUSSION
45
CHAPTER 7 CONCLUSION
46
REFERENCES 47
WEB REFERENCES 48
APPENDIX A : FLOWCHART OF THE SOURCE CODE 49
APPENDIX B : ERMAPPER DATA STRUCTURE 50
APPENDIX C : AREA A GREEN 51
APPENDIX D : SOURCE CODE 52
MSc. Remote Sensing Dissertation September 2002
4
LIST OF FIGURES PAGE NUMBER Figure 2.1 Earthquake structure formations 10 Figure 2.2 Normal Distribution Graph 11 Figure 3.1 A field photo of the damage-zone of the earthquake near
the National 109 road from Golmud to Lhasa, 200km east of the epicentre
13 Figure 3.2 East Kunlun Mountains, Western China 14 Figure 4.1 Correlation illustrated 16 Figure 5.1 Earthquake Detection Architecture 19 Figure 5.2 Interface design for this prototype 24 Figure 5.3 Area correlation for image cross correlation 25 Figure 5.4 Inferring displacement maps between image pairs 27 Figure 5.5 Histogram Delta X and Delta Y 29 Figure 5.6 Coefficient Histogram 29 Figure 6.1 RGB Kunlun pre-Earthquake overlay vector of fault 31 Figure 6.2 Vector Map for Same Image Using L = 1 32 Figure 6.3 Area D: - sample of an area from the North-West
Mountain in Kunlun
33 Figure 6.4 A generated vector of the displacement (shift) overlay to
the RGB Kunlun before Earthquake
33 Figure 6.5 Histogram of Delta X in meter using Non Cumulative Style 34 Figure 6.6 Histogram of Delta Y in meters using Non Cumulative
Style
34 Figure 6.7 Histogram of Coefficient 35 Figure 6.8 Delta Y in Green and Delta X in Red representing False
Colour Composite and for the colour in histograms for unrectified dataset
37 Figure 6.9 Displacement of the area A and the overlay of unrectified
dataset
38 Figure 6.10 Delta Y in Green and Delta X in Red representing False
Colour Composite and for the colour in histograms for rectified dataset
38 Figure 6.11 Delta Y in Green and Delta X in Red representing False
Colour Composite and for the colour in histograms for rectified dataset
39 Figure 6.12 Displacement of the area B and the overlay dataset using
pseudocolor
40 Figure 6.13 Delta Y in Green and Delta X in the histograms and RGB
FCC 321
41 Figure 6.14 Delta Y in Green and Delta X in Red representing False
Colour Composite (FCC) and for the colour in histograms for rectified dataset
42 Figure 6.15 Displacement of the area B and the overlay dataset on
pseudocolor
42 Figure 6.16 Delta Y in Green and Delta X in Red representing False
Colour Composite (FCC) and for the colour in histograms for rectified dataset
43 Figure 6.17 Displacement of the area E and the overlay dataset on
In order to obtain high precision and accuracy on pixel by pixel basis, the prototype will need
up to 8 days of processing time based on 2050 x 2050 pixels. Due to the limited time, next
section, will discuss the result based on the medium accuracy with result block by block.
6.4. RESULT
Each area has been processed according to the located area as shown in Table 1 and Figure
6.1. Since the prototype only measured the shift pixel by pixel or block by block, the trend
pattern will be too small to observe. So, angle and magnitude are calculated based on the
maximum individually shift using histogram for visibility of pattern and reducing processing
time for the whole image using delta X and delta Y. Therefore to accomplish the final result,
all this area results will be combined. Finally the Earthquake trend patterns were drawn
manually to show the shifting as illustrated in Figure 6.9.
6.4.1. AREA A (GREEN)
The areas cover at between 283420E and 4042385N to 314094 E and 4011553 N, near the
lake and the epicentre of Kunlun China (Appendix C). The process took 30 hours (on a
machine using 1 GHz speed CPU with a memory of 384 MB) each on unrectified and
rectified dataset of “before” and after the Earthquake using M = 9 and N= 15 and L= 9.
-120 0 35 100 130
-120 0 35 130
Figure 6.8 :- Delta Y in Green and Delta X in Red representing False Colour Composite and for the
colour in histograms for unrectified dataset.
Meter
Meter
CHAPTER 6 ANALYSIS AND RESULT
MSc. Remote Sensing Dissertation September 2002
37
Figure 6.10 :- Delta Y in Green and Delta X in Red representing False Colour Composite and for the
colour in histograms for rectified dataset.
-75 -50 -25 0 25 50
-75 -50 -25 0 25 50
Figure 6.9 :- Displacement of the area A and the overlay of unrectified dataset.
CHAPTER 6 ANALYSIS AND RESULT
Meter
Meter
MSc. Remote Sensing Dissertation September 2002
38
After the rectification the image of FCC delta X and delta Y (figure 6.8) has reduced the
amount pixel change which could be observed in Figure 6.10. By estimating the delta X and
delta Y using the histogram (Figure 6.10), the maximum possible shifts are -78 and -56
respectively based on the rectified datasets. Rectified dataset’s delta x and delta y histogram
were used because of their lower distortions less distortion and the shift are much clear.
Therefore the possible shift angle is 126 o with 96.02m (�6 pixel) magnitude as shown in
Figure 6.9.
Next other areas will only discuss on using the rectified image for the analyst of the angle and
magnitude.
6.4.2. AREA B: - ORANGE (ALLUVIAL FAN)
The areas cover at between 281098E and 4027517N to 291606 E and 4018226 N, near the
alluvial fan south of the lake. There are lots of shiftings and changes in the alluvial fan itself
as shown in Figure 6.9.
Y
X
126o
Figure 6.11 :- Delta Y in Green and Delta X in Red representing False Colour Composite and for the colour
in histograms for rectified dataset.
-60 0 75
-60 0 75
CHAPTER 6 ANALYSIS AND RESULT
Meter
Meter
MSc. Remote Sensing Dissertation September 2002
39
By estimating the delta X and delta Y using the histogram as shown in Figure 6.11, the
maximum possible shifts were -30 and 30 respectively. Therefore the possible shift angle is
315 o with 42.42m (�2.8 pixel) magnitude. These shiftings can be seen in Figure 6.12.
Figure 6.12 :- Displacement of the area B and the overlay dataset using pseudocolor.
CHAPTER 6 ANALYSIS AND RESULT
MSc. Remote Sensing Dissertation September 2002
40
6.4.3. AREA C :- YELLOW ( ALLUVIAL FAN )
This study area has very low correlation due to
saturation which caused this method not to be able to
detect the shifting clearly. However, this method was
successful on the top of alluvial fan.
By estimating delta X and delta Y using the histogram,
the maximum possible shifts were 30 or -30 for delta X
and -30 for delta Y. Therefore the possible shift angles
are between 225o to 315o with 42.42m (�2.8 pixel)
magnitude as shown in Figure 6.13.
-60 0 60
-60 0 60
Figure 6.13 :- Delta Y in Green and Delta X in the histograms and RGB FCC 321
CHAPTER 6 ANALYSIS AND RESULT
Meter
Meter
MSc. Remote Sensing Dissertation September 2002
41
6.4.4. AREA D: - PURPLE
In Figure 6.14, area D has a lot of movement as both colour (Red and Green) are coloured in
the image which may represent more than one direction. By estimating the delta X and delta
Y using the histogram; the maximum shifts possible were 30 and -30 respectively. Therefore
the possible shift angle is 315 o with 42.42m (�2.8 pixel) magnitude as shown in figure 6.9.
These shifting can be seen in the Figure 6.15.
-60 0 75
Figure 6.14 :- Delta Y in Green and Delta X in Red representing False Colour Composite (FCC) and for
the colour in histograms for rectified dataset
Figure 6.15 :- Displacement of the area B and the overlay dataset on pseudocolor.
CHAPTER 6 ANALYSIS AND RESULT
-60 0 75
-60 0 75
Meter
Meter
MSc. Remote Sensing Dissertation September 2002
42
6.4.5. AREA E :- BLUE
Figure 6.16 :- Delta Y in Green and Delta X in Red representing False Colour Composite (FCC) and for the colour in histograms for rectified dataset
-70 0 69
-70 0 69
Figure 6.17 :- Displacement of the area E and the overlay dataset on pseudocolor.
CHAPTER 6 ANALYSIS AND RESULT
Meter
Meter
MSc. Remote Sensing Dissertation September 2002
43
By estimating the delta X and delta Y using the histogram, the maximum shifts possible are
-30 and 30 respectively as shown in Figure 6.16. Therefore the possible shift angle is 315 o
with 42.42m (�2.8 pixel) magnitude. These shifting can be seen in the Figure 6.17.
6.4.6 SUMMARY
Based on the observation made by another on MSc colleague he suggested that the trend
pattern that has been created and his research have similarities. This prototype could be
improved to calculate the average angle and the magnitude automatically and then draw
average pattern trend for each specific size windows to show a greater accuracy of trend
pattern (Figure 6.18). Because of some the areas have moved in many directions and
angles, the actual displacements could not be represented very accurately.
Figure 6.18 : Displacement Pattern
CHAPTER 6 ANALYSIS AND RESULT
MSc. Remote Sensing Dissertation September 2002
44
6.4.7. FAULT DETECTIONS
NCC is very sensitive to shape and edges and because of it’s feature, faults are easily be
distinguished. One obvious process of great physical interest is the motion of surface faults
during the course of the earthquake. This detection can be clearly seen from Figure 6.19.
Observed analysis (blue vector) made were quite rigid and straight compares to the
generated vector displacements which follows the pixel by pixel changes. Significantly the
detections were much accurate. However, the final results still need the geologist to interpret
or ground truths for better understand of the features changes.
Figure 6.19 :-Fault Detection (In Blue is the observed fault drawn and red
arrow is the vector to show fault lines.)
CHAPTER 6 ANALYSIS AND RESULT
MSc. Remote Sensing Dissertation September 2002
45
6.5. DISCUSSION
Normalized Cross Correlation (NCC) has been used widely because it can cope with noisy
images and uniform change in brightness. But when the scene involves partial occlusion of
objects or saturation(highlight), this sum of multiplication- based correlation techniques
sometimes fails to capture true position, while it is good to measure some slight change in
brightness (S. Kaneko, et al 2002). For the effectiveness use of measuring Sub Pixel level of
earthquakes, sun-angle and view angle differences between imagery must be avoided.
Shadows will not match between scenes due to different sun positions. Likewise, radial
distortion of topographic features in images will differ between images different view angle.
The other major source of geometric noise, results arises from the sensor attitude and
altitude differences.
These techniques provide useful tools for measuring Earthquake. As for now, the detectable
shift or movement is 15 m or equivalent to 1 pixel. The vectors provide statistically significant
result that can be modelled to remove geometric noise and thereby obtain precise
displacement directions over a wide area. Fault breaks in remote location might be located by
the vector.
From the analysis, most displacements in the area are within 1 pixel. However, due to the
mismatch of the “before” and “after” Imagery, the final results there fore are spatially biased
correlated pattern. The measured displacement may not be necessarily the displacement
itself, whereby it could be also the geometric distortion or mismatch points. The images
supposed to be rectified from the beginning in order for an accurate matching to be achieved.
Unfortunately, images are degraded due to resampling. This problem could be solved using
image differencing and removed by the correlation procedures by image masking (Crippen,
1992). In areas where radiometric change is pervasive such as agricultural fields,
subresolution matching of edges in the image can form boundaries which may be possible as
an alternative procedure. But this procedure could not be implemented yet due to time
constraint.
Overall performance, the method used in this project is considered to be successful in
measuring the angle of the displacement. This displacement however needs ground truth in
order to access and understand the change and the movement. A part from that, the
prototype could also be improved to extract more accurate information automatically. Since in
this project, final stages of pattern trends were still done manually and the prototype could
also use the pixel (DN) resampling to increase the precision.
CHAPTER 6 ANALYSIS AND RESULT
MSc. Remote Sensing Dissertation September 2002
46
CHAPTER 7 CONCLUSION
With the implementation of this method, optical data could be used to obtain earth
displacement as a substitution to InSAR. However, this method needs more analysis for
stability and improvement. Realistically, this method could be used for any earth surface
displacements and able to measure the possible shift. In fact this method has an advantage
over InSAR, because it’s higher resolution. Moreover, this method is able to measure a
horizontal or vertical displacement as small as a size of pixel. With the available of along-
track band 3B stereo in ASTER, this method could also be implemented to measure the
displacement in heights (z axis) for a realistic 3D motion. For a higher demand of accuracy
and visualization, computation cost will also increase.
CHAPTER 7 CONCLUSION
MSc. Remote Sensing Dissertation September 2002
47
REFERENCES:
Crippen R.E. and Blom, R.G. 1992., Mapping of the Horizontal Strain Field of the 1992 Landers Earthquake by Imageodesy, EOS Transactions of the American Geophysical Union, 73(43):374.
Crippen, R. E. 1992, Measurement of subresolution terrain displacements using SPOT panchromatic imagery. EOS Transactions of the American Geophysical 15(1): 56-61.
Crippen, R. E. and Blom, R. G.1996., Detection, measurement, visualization, and analysis of seismic crustal deformation. In: Proc. 11th International Thematic Conference on Geologic Remote Sensing, (ERIM, Ann Arbor, Michigan). 1: I-298.
Dani P. and Chaudhuri S.1995, Automated Assembling of Images: Image Montage Preparation, Pattern Recognition 25(3):431-445.
Dury S.A.1993., Image Interpretation in Geology 2nd. Chapman and Hall, London. 290 pages
ER Mapper 6.0 2000, Software Development Kit, Earth Resource Mapping Pty Ltd. Lewis J. P. 1995., Fast Template Matching, Vision Interface, p. 120-123,.
Lillesand, T.M. and Kiefer, R.W. 2000., “Remote Sensing And Image Interpretation”, Fourth Edition John Wiley & Sons, New York. 724 pages.
Liu J.G. 2000., Smoothing Filter Band Based Intensity Modulation: a Spectral Preserve Image Fusion Technique for improving Spatial Details. IJRS, 21, No 18, 3461-3472
Hanssen R. F. 2001., Radar Interferometry:- Data Interpretation and error analysis, Optima Grafische Communicatte. 308 pages
Herbert S. 1987., Artificial Intelligence: Using C. McGraw-Hill. Inc. 411 pages.
Kaneko S and Satoh Y.I.S., 2002., Using selective correlation coefficient for robust image registration, Pattern Recognition, Pergamon p 1-9, 2002
Tierney K. 1998., Improving Earthquake Loss Estimation: Review, Assessment and Extension of Loss Estimation Methodologies, Uni. of Delaware. pages 1-14
David. K. 1998., Programming Microsoft Visual C++. Fifth Edition, Microsoft Press. 1153 pages.
David. W. 2000., Mathematic: Simple tool for geologist. Second Edition. Chapman and Hall, Inc. 201 pages
Richards, J. A (1995)., Remote Sensing Digital Image Analysis, Springer-Verlag, Berlin, pages. 54-57.
Schowengerdt.R.A 1997., Remote Sensing Model and Methods for Image Processing, Second Edition. Academic Press 522 pages.
Tsuneji S.R.R and Yukoo H. 1987., Applied Mathematic for Earth Scientist, Terra Scientific Pub Co. Tokyo. 435 pages.
Tom A. 1992., Earthquake Prediction: Science on Shaky Ground? The Scientist 6[14]:15,
MSc. Remote Sensing Dissertation September 2002
48
WEB REFERENCES:
Paul S., Dean C, Crippen R. and Blom R. 1999 http://www.cacr.caltech.edu/Publication/annreps/annrep95/earth1.htm Photographing Earthquakes from Space on Earth Sciences (Last seen on the 15 July 2002)
Paul S., Dean C, Crippen R. and Blom R. 1999, http://mishkin.jpl.nasa.gov/spacemicro/SCALABLE_PAPER Scalable Scientific Datamining on Massively Parallel Computer (Last seen on 2 June 2002)
QUAKEFINDER: Photographing Earthquakes from Space (Last seen on 2 June 2002)
An ER Mapper raster data file contains binary data in Band-Interleaved by Line (BIL) format. The type and amount of data is specifed in the header file. The figure above illustrated the ordering of data in an ER Mapper raster data file.
MSc. Remote Sensing Dissertation September 2002
51
APPENDIX C: AREA A GREEN
MSc. Remote Sensing Dissertation September 2002
52
APPENDIX D: SOURCE CODE
// Date September 2002 // Programme made by Sheikh Nasir Kamarudin // for Master Remote Sensing UCL // The basic technique of Imageodesy is to compare the "before" and "after" // image at each grid cell by iteratively interpolating one and testing its // correlation with the other. #include <stdio.h> #include <iostream.h> #include "stdafx.h" #include "Tasking.h" #include "math.h" #include <ERS.h> #include "TaskingDoc.h" #include "TaskingView.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif double total_b4=0, mean_b4=0, variance_b4=0, total_af=0, mean_af=0, variance_af=0; char *p_b4Name,*p_afName; INT32 nr_rows_b4,nr_rows_af; INT32 nr_columns_b4, nr_columns_af; Algorithm *p_alg_b4, *p_alg_af; LPTSTR lpsz1,lpsz2; UINT8 target[6000000],temp_target[900]; UINT8 search[6000000],temp_search[900]; INT deltaX[1]; INT deltaY[1]; INT cof[1]; char *p_errmsg_b4 =NULL; INT32 row_b4,column_b4; Correlation cross_cof[200]; CorrelationHeader EQ; int part_x, part_y, balance_x, balance_y, mid_x, mid_y; FILE *testfile; // a pointer to the output file FILE *outputfile1; // a pointer to the output file double afeasting ; double afnorthing; double afcellsizex; double afcellsizey; double b4easting ; double b4northing; double b4cellsizex; double b4cellsizey; double ll_col_end=0, ll_row_end=0; int mode = 1,stop=0,nr_x,nr_y; CString m_save1,m_delta1,m_deltaY1,m_coff1;
MSc. Remote Sensing Dissertation September 2002
53
CString dirsave; int m_nTimer; int m_nCount; enum {nMaxCount =1000}; char *datum,*projection,*b_order="LSBFirst",*CellTy="Unsigned8BitInteger",*CellTySign="Signed8BitInteger"; double rotate; CoordSysType CoordType; //variable declaration ....end // Internal (private) support functions // static void *allocate_memory(size_t size); static void handle_error(char *format,...); // Internal (private) support functions // ermapper void updatelpsz1(CString m_edit1); void updatelpsz2(CString m_edit2); void SetupAlgorithmDefaults1(LPTSTR lpsz,DatasetHeader *p_dsh, int alg_height, int alg_width,int mode); void read1 (Algorithm *p_alg,int nr_rows, int nr_columns,int a, int b,int shiftm,int shiftn, int mode); void statistic(int m,int dec, int mode); int conv_ll_xy(double a, double a1,int cellinfo); double conv_xy_ll(double a, int x , int cellinfo); //double b, ///////////////////////////////////////////////////////////////////////////// // CTaskingView IMPLEMENT_DYNCREATE(CTaskingView, CFormView) BEGIN_MESSAGE_MAP(CTaskingView, CFormView) //{{AFX_MSG_MAP(CTaskingView) ON_BN_CLICKED(IDC_CBONIDLE1, OnCbonidle) ON_BN_CLICKED(IDC_CBTHREAD1, OnCbthread1) ON_BN_CLICKED(IDC_CBTHREAD2, OnCbthread2) ON_WM_DESTROY() ON_BN_CLICKED(ID_BROWSE1, OnBrowse1) ON_BN_CLICKED(ID_BROWSE, OnBrowse) ON_BN_CLICKED(IDC_SAVE, OnSave) ON_BN_CLICKED(IDC_CHECK1, OnCheck1) ON_BN_CLICKED(IDCANCEL2, OnCancel2) ON_BN_CLICKED(IDOK2, OnOk) ON_EN_CHANGE(IDC_EDIT3, OnChangeEdit3) ON_EN_CHANGE(IDC_EDIT2, OnChangeEdit2) ON_EN_CHANGE(IDC_EDIT4, OnChangeEdit4) ON_EN_CHANGE(IDC_EDIT5, OnChangeEdit5) ON_EN_CHANGE(IDC_EDIT6, OnChangeEdit6) ON_EN_CHANGE(IDC_EDIT1, OnChangeEdit1) ON_BN_CLICKED(IDC_SAVE2, OnDeltaSave) ON_BN_CLICKED(IDC_SAVE3, OnSave3) ON_EN_CHANGE(IDC_EDIT7, OnChangeEdit7) ON_EN_CHANGE(IDC_EDIT8, OnChangeEdit8) ON_EN_CHANGE(IDC_EDIT9, OnChangeEdit9) ON_EN_CHANGE(IDC_EDIT10, OnChangeEdit10) ON_EN_CHANGE(IDC_EDIT12, OnChangeEdit12) ON_EN_CHANGE(IDC_EDIT11, OnChangeEdit11) ON_BN_CLICKED(IDC_SAVE4, OnCoff) ON_BN_CLICKED(IDC_CBONIDLE2, OnCbonidle) ON_EN_CHANGE(IDC_EDIT13, OnChangeShift) //}}AFX_MSG_MAP // Standard printing commands ON_COMMAND(ID_FILE_PRINT, CFormView::OnFilePrint) ON_COMMAND(ID_FILE_PRINT_DIRECT, CFormView::OnFilePrint) ON_COMMAND(ID_FILE_PRINT_PREVIEW, CFormView::OnFilePrintPreview) END_MESSAGE_MAP()
CFormView::OnInitialUpdate(); GetParentFrame()->RecalcLayout(); ResizeParentToFit(); } ///////////////////////////////////////////////////////////////////////////// // CTaskingView printing BOOL CTaskingView::OnPreparePrinting(CPrintInfo* pInfo) { // default preparation return DoPreparePrinting(pInfo); } void CTaskingView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) { // TODO: add extra initialization before printing } void CTaskingView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) { // TODO: add cleanup after printing } void CTaskingView::OnPrint(CDC* pDC, CPrintInfo* /*pInfo*/) { // TODO: add customized printing code here } ///////////////////////////////////////////////////////////////////////////// // CTaskingView diagnostics #ifdef _DEBUG void CTaskingView::AssertValid() const { CFormView::AssertValid(); } void CTaskingView::Dump(CDumpContext& dc) const { CFormView::Dump(dc); } CTaskingDoc* CTaskingView::GetDocument() // non-debug version is inline { ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTaskingDoc))); return (CTaskingDoc*)m_pDocument; } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CTaskingView message handlers void CTaskingView::OnCbonidle() { // TODO: Add your control notification handler code here /////////////////////// // MY CODE STARTS HERE /////////////////////// // Sync the variables with the dialog UpdateData(TRUE); /////////////////////// // MY CODE ENDS HERE /////////////////////// }
MSc. Remote Sensing Dissertation September 2002
56
void CTaskingView::OnCbthread1() { // TODO: Add your control notification handler code here /////////////////////// // MY CODE STARTS HERE /////////////////////// // Sync the variables with the dialog UpdateData(TRUE); // Get a pointer to the document CTaskingDoc* pDocWnd = (CTaskingDoc*)GetDocument(); // Did we get a valid pointer? ASSERT_VALID(pDocWnd); // Suspend or start the spinner thread pDocWnd->SuspendSpinner(0, m_bThread1); /////////////////////// // MY CODE ENDS HERE /////////////////////// } void CTaskingView::OnCbthread2() { // TODO: Add your control notification handler code here /////////////////////// // MY CODE STARTS HERE /////////////////////// // Sync the variables with the dialog UpdateData(TRUE); // Get a pointer to the document CTaskingDoc* pDocWnd = (CTaskingDoc*)GetDocument(); // Did we get a valid pointer? ASSERT_VALID(pDocWnd); // Suspend or start the spinner thread pDocWnd->SuspendSpinner(1, m_bThread2); /////////////////////// // MY CODE ENDS HERE /////////////////////// } void CTaskingView::OnDestroy() { CFormView::OnDestroy(); // TODO: Add your message handler code here /////////////////////// // MY CODE STARTS HERE /////////////////////// // Is the first thread running? if (m_bThread1) { // Specify to stop the first thread m_bThread1 = FALSE; // Get a pointer to the document CTaskingDoc* pDocWnd = (CTaskingDoc*)GetDocument(); // Did we get a valid pointer? ASSERT_VALID(pDocWnd); // Suspend the spinner thread pDocWnd->SuspendSpinner(0, m_bThread1); } // Is the second thread running? if (m_bThread2) { // Specify to stop the second thread
MSc. Remote Sensing Dissertation September 2002
57
m_bThread2 = FALSE; // Get a pointer to the document CTaskingDoc* pDocWnd = (CTaskingDoc*)GetDocument(); // Did we get a valid pointer? ASSERT_VALID(pDocWnd); // Suspend the spinner thread pDocWnd->SuspendSpinner(1, m_bThread2); } /////////////////////// // MY CODE ENDS HERE /////////////////////// } static void handle_error(char *format, ...) { } static void *allocate_memory(size_t size) { void *p_memory=malloc(size); if (p_memory==NULL){ handle_error ("Could not allocate %d bytes", size); } return (p_memory); } void read1 (Algorithm *p_alg, int nr_rows, int nr_columns,int col_quit, int row_quit,int col_x,int row_x, int mode) { VDataset *pVds = (VDataset *)NULL; int iRowIndex; INT32 iColIndex; char *pBufArray = (char *)NULL; RasterLineSeg **ppRlsegArray = (RasterLineSeg **)NULL; BOOLEAN process_vectors=TRUE; char *pErrMsg = (char *)NULL; UINT8 *pBuf = (UINT8 *)NULL; UINT32 *p_buffer = NULL; int cy; int rval; int band=1; int tempx=col_x; int tempy=row_x; UINT8 TEMO; if (p_alg == (Algorithm *)NULL) return; rval = PE_initialise("Quake Finder 1.0"); if ( rval != ERS_SUCCESS) { //exit(1); handle_error ("Could not initialise bytes"); } // if // pVds = vds_open_alg_rgbh(p_alg, &pErrMsg); ASSERT(pVds != NULL); if (pVds == (VDataset *)NULL) { //exit(1); handle_error ("Data set is NULL bytes"); } else { // vds_read() will return a buffer of RGBh values which represent // the output generated by the currently loaded algorithm, Read // algorithm line by line
MSc. Remote Sensing Dissertation September 2002
58
cy=0; p_buffer=(UINT32 *)allocate_memory(nr_columns * sizeof(UINT32)); for (iRowIndex = 0;((iRowIndex<nr_rows)); ++iRowIndex) { if (vds_read (pVds,(char **) &p_buffer,(RasterLineSeg **)NULL,FALSE) ) { handle_error ("Data set is null 1 bytes"); } else { for (iColIndex = 0;((iColIndex<nr_columns)); ++iColIndex) { TEMO=p_buffer[iColIndex]>>DFLT_RED_SHIFT &0xff; if ((iRowIndex==row_x)&&(iColIndex==col_x)) { if (mode==1) target[cy]=p_buffer[iColIndex]>>DFLT_RED_SHIFT &0xff; else if (mode==2) search[cy]=p_buffer[iColIndex]>>DFLT_RED_SHIFT &0xff; cy=cy+1; col_x++; if ((col_x>=nr_columns)||(col_x>=col_quit)) {row_x++; col_x=tempx; if ((row_x>=row_quit)) return; } else if ((row_x>=row_quit)) return; } } //end for else if for Vds Open }//end for loop icolindex } // end for loop irowIndex } // if pVds not null // free(p_buffer); vds_close(&pVds); //********************************************************** //********************statistic***************************** //********************************************************** } void SetupAlgorithmDefaults1( LPTSTR lpsz,DatasetHeader *p_dsh, int alg_height, int alg_width, int mode) /////////////////////////////////////////////////////////////////////////////////// // FUNCTION: SetupAlgorithmDefaults // // PURPOSE: // This function sets up basic algorithm defaults. Most importantly it sets the // dimensions (in pixels) of the output to be displayed by the algorithm. /////////////////////////////////////////////////////////////////////////////////// { Algorithm *m_pAlgorithm; //****************************************************************** //read algotithms file and check the file algorithms for after image //****************************************************************** if (EXTENT_IS_ALG(lpsz)) { if (eg_algorithm (&m_pAlgorithm, lpsz) !=ERS_SUCCESS) { handle_error("Error read %s", lpsz); }//end if } else {// create am algorithms based on the image double limit_clip_percentage; double transform_clip_percentage;
MSc. Remote Sensing Dissertation September 2002
59
if (p_dsh->u.ri.celltype==CT_UINT8) { limit_clip_percentage =0.0; transform_clip_percentage=0.0; } else {//rescale limit_clip_percentage=100.0; //apply a 99% clip transform_clip_percentage =99.0; }//end if //else //create the algorithms if (ERM_create_algorithm (&m_pAlgorithm,lpsz, limit_clip_percentage, transform_clip_percentage)!=ERS_SUCCESS) { handle_error ("Unable to create algorithms: %s",ERS_error_text()); } } //m_pAlgorithm->canvas_width = (INT32)alg_width; //m_pAlgorithm->canvas_height= (INT32)alg_height; m_pAlgorithm->output_width = (INT32)alg_width; m_pAlgorithm->output_height= (INT32)alg_height; m_pAlgorithm->x_dpi = 72.0; m_pAlgorithm->y_dpi = 72.0; m_pAlgorithm->colour24flag = TRUE; setup_color24(m_pAlgorithm); m_pAlgorithm->enforce_aspect_ratio=1; adjust_for_aspect(m_pAlgorithm,m_pAlgorithm->x_dpi,m_pAlgorithm->y_dpi); m_pAlgorithm->do_compilation=FALSE; m_pAlgorithm->processvectors=PV_NONE; if (mode== 1) p_alg_b4=m_pAlgorithm; else if (mode ==2) p_alg_af=m_pAlgorithm; return; } void statistic(int m, int dec, int mode) { double variance=0; double total=0; double max=0, min=0; if (mode==1) { max=target[0]; min=target[0]; for (int i=0;i <(m*m);i++) { total=temp_target[i]+total; } mean_b4 = total/(m*m); } else if (mode ==2) { max=search[0]; min=search[0]; for (int i=0;i <(m*m);i++)
MSc. Remote Sensing Dissertation September 2002
60
{ total=temp_search[i]+total; } mean_af = total/(m*m); } for (int i=0;i<m*m;i++) { if(mode ==1) variance = variance + pow((temp_target[i]-mean_b4),2); else if (mode ==2) variance = variance + pow((temp_search[i]-mean_af),2); } if(mode ==1) variance_b4 = variance; else if (mode ==2) variance_af = variance; } // a for the topleft coordinate, // b bottom right coordinate // x for the x or y coordinate needs to convert to ll // cellinfo for pixel size eg. 15 metres double b, int conv_ll_xy(double a, double a1, int cellinfo) { return (( a1-a)/cellinfo); } // a for the topleft coordinate, b bottom right coordinate // x for the x or y coordinate needs to convert to ll // cellinfo for pixel size eg. 15 metres double conv_xy_ll(double a, int x , int cellinfo) { return (a + (x*cellinfo)); } void CTaskingView::OnBrowse1() { // TODO: Add your control notification handler code here UpdateData(); CFileDialog dlg(TRUE, "ers","*.ers"); if (dlg.DoModal() ==IDOK){ m_edit1=dlg.GetPathName(); CFile file; updatelpsz1(m_edit1); m_startLong=b4easting; m_startLat=b4northing; m_endLong=b4easting + (b4cellsizex*100); m_endLat=b4northing+ (b4cellsizey*100); } UpdateData(FALSE); } void CTaskingView::OnBrowse() { // TODO: Add your control notification handler code here UpdateData(); CFileDialog dlg(TRUE, "ers","*.ers"); if (dlg.DoModal() ==IDOK){ m_edit2=dlg.GetPathName(); CFile file; updatelpsz2(m_edit2); }
MSc. Remote Sensing Dissertation September 2002
61
UpdateData(FALSE); } void updatelpsz1(CString m_edit1) { DatasetHeader *p_b4Dsh ; //Get the header info //********************************************************** //********************************************************** //... modify lpsz as much as you want lpsz1 = new TCHAR[m_edit1.GetLength()+1]; _tcscpy(lpsz1, m_edit1); //before images if (eg_dshdr (&p_b4Dsh, lpsz1) !=ERS_SUCCESS){ handle_error ("Unable to get the image header before EQ:%s", ERS_error_text()); }//end if //before images nr_rows_b4=p_b4Dsh->u.ri.nr_lines; nr_columns_b4=p_b4Dsh->u.ri.cells_per_line; b4easting =p_b4Dsh->u.ri.origin.en.eastings; b4northing=p_b4Dsh->u.ri.origin.en.northings; b4cellsizex= p_b4Dsh->u.ri.cellinfo.x; b4cellsizey= p_b4Dsh->u.ri.cellinfo.y*-1; SetupAlgorithmDefaults1(lpsz1,p_b4Dsh,nr_rows_b4,nr_columns_b4,1); } void updatelpsz2(CString m_edit2) { DatasetHeader *p_afDsh; //... modify lpsz as much as you want lpsz2 = new TCHAR[m_edit2.GetLength()+1]; _tcscpy(lpsz2, m_edit2); //after images if (eg_dshdr (&p_afDsh, lpsz2) !=ERS_SUCCESS){ handle_error ("Unable to get the image header after EQ:%s", ERS_error_text()); }//end if nr_columns_af=p_afDsh->u.ri.cells_per_line; nr_rows_af=p_afDsh->u.ri.nr_lines; afeasting =p_afDsh->u.ri.origin.en.eastings; afnorthing=p_afDsh->u.ri.origin.en.northings; afcellsizex= p_afDsh->u.ri.cellinfo.x; afcellsizey= p_afDsh->u.ri.cellinfo.y*-1; datum=p_afDsh->cspace.datum; projection=p_afDsh->cspace.projection; rotate=p_afDsh->cspace.rotation; CoordSysType CoordType=p_afDsh->cspace.coordsystype; SetupAlgorithmDefaults1(lpsz2,p_afDsh,nr_rows_af,nr_columns_af,2); } void CTaskingView::OnSave() { // TODO: Add your control notification handler code here UpdateData(); CFileDialog dlg(FALSE, "erv","*.erv"); if (dlg.DoModal() ==IDOK){ m_save=dlg.GetPathName(); int x=m_save.GetLength(); m_save1=m_save.Left(x-4); CFile file; } UpdateData(FALSE); }
MSc. Remote Sensing Dissertation September 2002
62
void CTaskingView::OnCheck1() { // TODO: Add your control notification handler code here if (m_checklimit==0) { GetDlgItem(IDC_EDIT7)->EnableWindow(TRUE); GetDlgItem(IDC_EDIT8)->EnableWindow(TRUE); GetDlgItem(IDC_EDIT9)->EnableWindow(TRUE); GetDlgItem(IDC_EDIT10)->EnableWindow(TRUE); GetDlgItem(IDC_STATICSL)->EnableWindow(TRUE); GetDlgItem(IDC_STATICSLA)->EnableWindow(TRUE); GetDlgItem(IDC_STATICELA)->EnableWindow(TRUE); GetDlgItem(IDC_STATICEL)->EnableWindow(TRUE); } if (m_checklimit==1) { GetDlgItem(IDC_EDIT7)->EnableWindow(FALSE); GetDlgItem(IDC_EDIT8)->EnableWindow(FALSE); GetDlgItem(IDC_EDIT9)->EnableWindow(FALSE); GetDlgItem(IDC_EDIT10)->EnableWindow(FALSE); GetDlgItem(IDC_STATICSL)->EnableWindow(FALSE); GetDlgItem(IDC_STATICSLA)->EnableWindow(FALSE); GetDlgItem(IDC_STATICELA)->EnableWindow(FALSE); GetDlgItem(IDC_STATICEL)->EnableWindow(FALSE); } // TODO: Add your control notification handler code here UpdateData(); //UpdateData(FALSE); } void CTaskingView::OnCancel2() { // TODO: Add your control notification handler code here exit(0); } void CTaskingView::OnOk() { //*************The starting of all the proccess******************* //***************that check for all the information need are ***** //******************enough to start the current process*********** //**************************************************************** int shift_col_limit=0; int shift_row_limit=0; int test_value=0; MSG Message; if (SHIFTED>m_edit3) { UpdateData(TRUE); MessageBox("Invalid Shift Value Enter","ERROR",MB_OK); test_value=1; } if ((m_edit1=="")&&(m_edit2=="")&&(m_save=="")&&(m_delta="")&&(m_deltaY=="")&&(test_value==0)&&(m_coffiecient=="")) { MessageBox("Please insert the file name","ERROR",MB_OK); } else {
MSc. Remote Sensing Dissertation September 2002
63
stop=1; m_nTimer=SetTimer(1,100,NULL); ASSERT(m_nTimer!=0); UpdateData(); updatelpsz1(m_edit1); updatelpsz2(m_edit2); GetDlgItem(IDOK2)->EnableWindow(FALSE); GetDlgItem(ID_BROWSE1)->EnableWindow(FALSE); GetDlgItem(IDC_SAVE)->EnableWindow(FALSE); GetDlgItem(ID_BROWSE)->EnableWindow(FALSE); GetDlgItem(IDC_EDIT1)->EnableWindow(FALSE); GetDlgItem(IDC_EDIT2)->EnableWindow(FALSE); GetDlgItem(IDC_EDIT3)->EnableWindow(FALSE); GetDlgItem(IDC_EDIT4)->EnableWindow(FALSE); GetDlgItem(IDC_EDIT5)->EnableWindow(FALSE); GetDlgItem(IDC_EDIT6)->EnableWindow(FALSE); GetDlgItem(IDC_EDIT11)->EnableWindow(FALSE); GetDlgItem(IDC_EDIT12)->EnableWindow(FALSE); GetDlgItem(IDC_EDIT14)->EnableWindow(FALSE); //********************************************************** //********************************************************** double b4easting_end=b4easting+(nr_columns_b4*b4cellsizex); double afeasting_end=afeasting+(nr_columns_af*afcellsizex); double b4northing_end=b4northing+(nr_rows_b4*b4cellsizey); double afnorthing_end=afnorthing+(nr_rows_af*afcellsizey); if (b4easting_end>=afeasting_end) ///makna nya b4 easting = shift_x_col // makna nya shift_x_col tamat pada if (b4northing_end<=afnorthing_end) { ll_col_end=afeasting_end; // after image easting ll_row_end=afnorthing_end; //after image northing } else { ll_col_end=afeasting_end; // after image easting ll_row_end=b4northing_end; //after image northing } else if (b4northing_end<=afnorthing_end) { ll_col_end=b4easting_end; // after image easting ll_row_end=afnorthing_end; //after image northing } else { ll_col_end=b4easting_end; // after image easting ll_row_end=b4northing_end; //after image northing } //**************The source below control the ********************* //***************out put file for all the data ******************* //******************that needs to be process********************** //**************************************************************** FILE *outputfile; // a pointer to the output file outputfile = fopen(m_save, "w"); // open text2.txt fprintf(outputfile, "DatasetHeader Begin \n"); fprintf(outputfile, "\tVersion = \"6.2\" \n "); fprintf(outputfile, "\tName = \"test2.erv\" \n "); fprintf(outputfile, "\tLastUpdated = Sun Jul 21 17:38:54 GMT 2002\n"); fprintf(outputfile, "\tDataSetType = None \n"); fprintf(outputfile, "\tDataType = Vector \n");
{ shift_col_b4=0; // before image easting shift_row_b4=0; //before image northing } else { shift_col_b4=0; // before image easting shift_row_b4=conv_ll_xy(b4northing,afnorthing,b4cellsizey); } else { if ((b4northing<=afnorthing)&&(b4northing<=afnorthing_end)) { shift_col_b4=sqrt(pow(conv_ll_xy(b4easting,afeasting, b4cellsizex),2)); shift_row_b4=0; //before image } else { shift_col_b4=sqrt(pow(conv_ll_xy(b4easting,afeasting, b4cellsizex),2)); shift_row_b4=sqrt(pow(conv_ll_xy(afnorthing,b4northing, b4cellsizey),2)); } } //**************************************************************** mid_x=m; mid_y=m; balance_x=nr_rows_b4 % mid_x/2; balance_y=nr_columns_b4 % mid_y/2; int nr_rows_limit,nr_cols_limit; //*************This if loop control the specify ****************** //****************windows size to be search and******************* //***************re duce the size of the memory for fast******** //*********************************data access******************** if (m_checklimit==1) { shift_row_limit=(m_startLong-b4easting)/b4cellsizex; shift_col_limit=(m_startLat-b4northing)/b4cellsizey; nr_rows_limit=(m_endLong-b4easting)/b4cellsizex; nr_cols_limit=(m_endLat-b4northing)/b4cellsizey; } else { nr_rows_limit=nr_rows_b4; nr_cols_limit=nr_columns_b4; } shift_row_b4=shift_row_b4+mid_x; shift_col_b4=shift_col_b4+mid_y; part_x=shift_row_b4; part_y=shift_col_b4;
MSc. Remote Sensing Dissertation September 2002
66
//**************************************************************** int a=0,b=0; int mark; double max,x,y; //*******************Start*of the read of the data image********* //**********************************and ************************** //****************kept the DN value in the memory for fast******** //*********************************data access******************** int counti=0; int max_col=(ll_col_end-b4easting)/b4cellsizex;; int max_row=(ll_row_end-b4northing)/b4cellsizey;; shift_row_b4=0; shift_col_b4=0; shift_row_af=0; shift_col_af=0; int m1=n; int ctr_tt=0; int ctr_tt_af=0; int point_row_b4=shift_row_b4; int point_col_b4=shift_col_b4; int point_row_af=0,point_col_af=0; int ctr_a=0 ,ctr_b=0; int yh=0; int s_p=0; int s_p1=0; { { mode =1; //setting mode kepada target array int cx = shift_col_b4+nr_columns_b4;//size col bemrhenti int cy = shift_row_b4+nr_rows_b4;//size row berhenti read1(p_alg_b4,nr_rows_b4,nr_columns_b4,cx,cy,shift_col_b4, shift_row_b4,mode); mode=2; int cx1 = shift_col_af +nr_columns_af;; int cy1 = shift_row_af +nr_rows_af;; read1(p_alg_af,nr_rows_af,nr_columns_af,cx1,cy1,shift_col_af, shift_row_af,mode); ctr_b=ctr_b+m1; s_p=m/2; s_p1=m/2; //**************************************************************** //*******************************Before image********************* //*************Start* reading of the data image for block target* //**************************************************************** for (int z_b4=0; (z_b4<(nr_columns_b4*nr_rows_b4) &&point_col_b4<nr_columns_b4&&point_row_b4+m<=nr_rows_b4); z_b4++) { if (point_row_af+m>=nr_rows_af) break; ctr_tt=0; for (int i=0; i<=nr_rows_b4;i++)
MSc. Remote Sensing Dissertation September 2002
67
{ for (int j=0;j<=nr_columns_b4;j++) { if ((j>=0+s_p)&&(j<m+s_p)&&(i>0+s_p1)&&(i<=m+s_p1)&&(ctr_tt!=(m*m))) { temp_target[ctr_tt]=target[j+((i-1)*nr_columns_b4)]; ctr_tt++; } }// for loop j }// for loop i point_col_b4=shift_col_b4+s_p; point_row_b4=shift_row_b4+s_p1; mode=1; double Tmn=0; double Smn=0; statistic(m,1,mode); //**************************************************************** //**************************After Image*************************** //*************Start* reading of the data image for block search* //**************************************************************** mode =2; shift_col_af=0; shift_row_af=0; //***************************************************************************** //********************setting the actual cordinate for after image************ x=(((point_row_b4-(mid_x/2))*b4cellsizex)+b4easting); y=(((point_col_b4-(mid_x/2))*b4cellsizey)+b4northing); shift_row_af=conv_ll_xy(afeasting,x,afcellsizex); shift_col_af=conv_ll_xy(afnorthing,y,afcellsizey); //***************************************************************************** //***************************************************************************** int s_p_af=shift_col_af; int s_p1_af=shift_row_af; int l_c=0,l_r=0; int jum=0; int fc=0; int harap=0; for (int z_af=0; (z_af<(nr_columns_af*nr_rows_af) &&point_col_af<nr_columns_af &&point_row_af+m<=nr_rows_af) &&(harap<(m1-m+1)); z_af++) { ctr_tt=0; CProgressCtrl* pBar = (CProgressCtrl*) GetDlgItem(IDC_PROGRESS2); pBar->SetPos(m_nCount * 100/nMaxCount); for (int i=0; i<=nr_rows_af;i++) { for (int j=0;j<=nr_columns_af;j++) { if ((j>=0+s_p_af)&&(j<m+s_p_af)&&(i>0+s_p1_af)&&(i<=m+s_p1_af)&&(ctr_tt!=(m*m))) { temp_search[ctr_tt]=search[j+((i-1)*nr_columns_b4)]; ctr_tt++; } }// for loop j }// for loop i
MSc. Remote Sensing Dissertation September 2002
68
point_col_af=s_p_af; point_row_af=s_p1_af; /////////////////////////////////////////////////////// //////////////////////begin/of///////////////////////// ////////////the acual calculation is here ///////////// /////////////////////////////////////////////////////// if (::PeekMessage(&Message,NULL,0,0,PM_REMOVE)) { ::TranslateMessage(&Message); ::DispatchMessage(&Message); } mode=2; statistic(m,1,mode); Smn=0; Tmn=0; double sumProduct=0; double co_variance=0; for (int ctr=0;ctr<m*m;ctr++) { Tmn=(temp_target[ctr]); Smn=(temp_search[ctr]); sumProduct=sumProduct+((Smn-mean_b4)*(Tmn-mean_af)) }//for loop ctr co_variance=sumProduct;//(m*m)-mean_af*mean_b4; cross_cof[jum].cross_cof =((co_variance)/(sqrt(variance_b4)*sqrt(variance_af))); cross_cof[jum].easting_af =point_col_af; cross_cof[jum].northing_af =point_row_af; cross_cof[jum].easting_b4 = point_col_b4; cross_cof[jum].northing_b4 =point_row_b4; double te=cross_cof[jum].cross_cof; te=sqrt(pow(te,2)); if (te==1) { mark=jum; } jum++; /////////////////////////////////////////////////////// //////////////////////end/of/////////////////////////// ////////////the acual calculation is here ///////////// /////////////////////////////////////////////////////// /////////////////////////////////////////////////////// /////////////////////////////////////////////////////// s_p_af=s_p_af+1; if /**/ ((s_p_af>(m1-m+1+shift_col_af))||(s_p_af==nr_columns_af)||((nr_columns_af-s_p_af)<m)) { s_p1_af++; s_p_af=shift_col_af; harap++; } }// for loop z..... int hg=0; mark=-2; max=0; for (hg=1;hg <(m*m-1);hg++) {double semen=sqrt(pow(cross_cof[hg].cross_cof,2)); if (semen<=1.0000009) {
MSc. Remote Sensing Dissertation September 2002
69
if ((semen>=max)&&(cross_cof[hg].cross_cof>=-1) &&(cross_cof[hg].cross_cof<=1.1) &&(semen>=m_edit5)) { max=sqrt(pow(cross_cof[hg].cross_cof,2)); mark =hg; } if (semen==1) { mark=hg; break; } } else {
} } if (mark>-1) { EQ.cross_cof=cross_cof[mark].cross_cof; EQ.easting_b4=(cross_cof[mark].easting_b4*b4cellsizex)+b4easting; EQ.easting_af=(cross_cof[mark].easting_af*afcellsizex)+afeasting; EQ.northing_b4=(cross_cof[mark].northing_b4*b4cellsizey)+b4northing; EQ.northing_af=(cross_cof[mark].northing_af*afcellsizey)+afnorthing; EQ.shift_x =EQ.easting_b4-EQ.easting_af; EQ.shift_y =EQ.northing_b4-EQ.northing_af; if ((EQ.shift_x==0)&&(EQ.shift_y==0)) fprintf(outputfile1,"point(,%lf,%lf,-1,-1,-1,0).\n",
(EQ.easting_b4+(2*b4cellsizex)+b4cellsizex/2),(EQ.northing_b4+(2*b4cellsizey)+b4cellsizey/2)); else if ((EQ.shift_x<b4cellsizex*20)&&(EQ.shift_y<b4cellsizey*20*-1))
mode =2; //setting mode kepada target array int cx1 = shift_col_af+m;//size col bemrhenti int cy1 = shift_row_af+m;//size row berhenti read1(p_alg_af,nr_rows_af,nr_columns_af,cx1,cy1,shift_col_af, shift_row_af,mode); } void CTaskingView::OnChangeEdit3() { // TODO: If this is a RICHEDIT control, the control will not // send this notification unless you override the CFormView::OnInitDialog() // function and call CRichEditCtrl().SetEventMask() // with the ENM_CHANGE flag ORed into the mask. // TODO: Add your control notification handler code here UpdateData(); } void CTaskingView::OnChangeEdit2() { // TODO: If this is a RICHEDIT control, the control will not // send this notification unless you override the CFormView::OnInitDialog() // function and call CRichEditCtrl().SetEventMask() // with the ENM_CHANGE flag ORed into the mask. // TODO: Add your control notification handler code here UpdateData(); } void CTaskingView::OnChangeEdit4() { // TODO: If this is a RICHEDIT control, the control will not // send this notification unless you override the CFormView::OnInitDialog() // function and call CRichEditCtrl().SetEventMask() // with the ENM_CHANGE flag ORed into the mask. // TODO: Add your control notification handler code here UpdateData(); } void CTaskingView::OnChangeEdit5() { // TODO: If this is a RICHEDIT control, the control will not // send this notification unless you override the CFormView::OnInitDialog() // function and call CRichEditCtrl().SetEventMask() // with the ENM_CHANGE flag ORed into the mask. // TODO: Add your control notification handler code here UpdateData(); } void CTaskingView::OnChangeEdit6() { // TODO: If this is a RICHEDIT control, the control will not // send this notification unless you override the CFormView::OnInitDialog() // function and call CRichEditCtrl().SetEventMask() // with the ENM_CHANGE flag ORed into the mask. // TODO: Add your control notification handler code here UpdateData(); } void CTaskingView::OnChangeEdit1() { // TODO: If this is a RICHEDIT control, the control will not // send this notification unless you override the CFormView::OnInitDialog() // function and call CRichEditCtrl().SetEventMask() // with the ENM_CHANGE flag ORed into the mask. // TODO: Add your control notification handler code here UpdateData(); } void CTaskingView::OnDeltaSave() {
MSc. Remote Sensing Dissertation September 2002
74
// TODO: Add your control notification handler code here // TODO: Add your control notification handler code here UpdateData(); CFileDialog dlg(FALSE, "ers","*.ers"); if (dlg.DoModal() ==IDOK){ //dirsave=dlg.GetFileExt(); m_delta=dlg.GetPathName(); int x=m_delta.GetLength(); m_delta1=m_delta.Left(x-4); CFile file; } UpdateData(FALSE); } void CTaskingView::OnSave3() { // TODO: Add your control notification handler code here // TODO: Add your control notification handler code here UpdateData(); CFileDialog dlg(FALSE, "ers","*.ers"); if (dlg.DoModal() ==IDOK){ //dirsave=dlg.GetFileExt(); m_deltaY=dlg.GetPathName(); int x=m_deltaY.GetLength(); m_deltaY1=m_deltaY.Left(x-4); CFile file; } UpdateData(FALSE); } void CTaskingView::OnChangeEdit7() { // TODO: If this is a RICHEDIT control, the control will not // send this notification unless you override the CFormView::OnInitDialog() // function and call CRichEditCtrl().SetEventMask() // with the ENM_CHANGE flag ORed into the mask. // TODO: Add your control notification handler code here } void CTaskingView::OnChangeEdit8() { UpdateData(); // send this notification unless you override the CFormView::OnInitDialog() // function and call CRichEditCtrl().SetEventMask() // with the ENM_CHANGE flag ORed into the mask. // TODO: Add your control notification handler code here } void CTaskingView::OnChangeEdit9() { UpdateData(); // send this notification unless you override the CFormView::OnInitDialog() // function and call CRichEditCtrl().SetEventMask() // with the ENM_CHANGE flag ORed into the mask. // TODO: Add your control notification handler code here } void CTaskingView::OnChangeEdit10() { UpdateData(); // send this notification unless you override the CFormView::OnInitDialog() // function and call CRichEditCtrl().SetEventMask() // with the ENM_CHANGE flag ORed into the mask.
MSc. Remote Sensing Dissertation September 2002
75
// TODO: Add your control notification handler code here } void CTaskingView::OnChangeEdit12() { UpdateData(); // send this notification unless you override the CFormView::OnInitDialog() // function and call CRichEditCtrl().SetEventMask() // with the ENM_CHANGE flag ORed into the mask. // TODO: Add your control notification handler code here } void CTaskingView::OnChangeEdit11() { UpdateData(); // send this notification unless you override the CFormView::OnInitDialog() // function and call CRichEditCtrl().SetEventMask() // with the ENM_CHANGE flag ORed into the mask. // TODO: Add your control notification handler code here } void CTaskingView::OnCoff() { // TODO: Add your control notification handler code here UpdateData(); CFileDialog dlg(FALSE, "ers","*.ers"); if (dlg.DoModal() ==IDOK){ //dirsave=dlg.GetFileExt(); m_coffiecient=dlg.GetPathName(); int x=m_coffiecient.GetLength(); m_coff1=m_coffiecient.Left(x-4); CFile file; } UpdateData(FALSE); } void CTaskingView::OnChangeShift() { // TODO: If this is a RICHEDIT control, the control will not // send this notification unless you override the CFormView::OnInitDialog() // function and call CRichEditCtrl().SetEventMask() // with the ENM_CHANGE flag ORed into the mask. // TODO: Add your control notification handler code here UpdateData(TRUE); }