Skip to content

Commit 8edff55

Browse files
committed
update
1 parent 19d6c14 commit 8edff55

File tree

9 files changed

+25
-33
lines changed

9 files changed

+25
-33
lines changed

Code/FSDAF.cpp

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11

2-
#include<algorithm>
3-
#include<fstream>
2+
#include <algorithm>
3+
#include <fstream>
44
#include "gdal_priv.h"
55
#include "ogr_core.h"
66
#include "ogr_spatialref.h"
7-
#include"dataanalysis.h"
7+
#include "dataanalysis.h"
88

9-
#include"FSDAF.h"
9+
#include "FSDAF.h"
1010

1111

1212
int getPerPixSize(size_t &mnDatalength, GDALDataType datatype)
@@ -136,24 +136,22 @@ double stddev(double *dif, int a_size)
136136
return result;
137137
}
138138

139-
/* Read size and projection information of input fine image at t1 */
139+
/* Read size and projection information of image InputF1 */
140140
int readImgSize(char InputF1[], size_t &ns, size_t &nl, size_t &nb)
141141
{
142142
GDALAllRegister();
143143
CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "NO"); //support Chinese path
144144
GDALDataset *ImgBef = (GDALDataset*)GDALOpen(InputF1, GA_ReadOnly);
145145
if (ImgBef == NULL)
146146
{
147-
printf("load error! The file name may be wrong.\n");
147+
printf("load error! The file name \" %s \" may be wrong.\n", InputF1[]);
148148
exit(0);
149149
}
150-
ns = ImgBef->GetRasterXSize(); //samples of each line
151-
nl = ImgBef->GetRasterYSize(); //lines of fineImg1
152-
nb = ImgBef->GetRasterCount(); //band number
153-
150+
ns = ImgBef->GetRasterXSize(); //samples of each line
151+
nl = ImgBef->GetRasterYSize(); //number of lines
152+
nb = ImgBef->GetRasterCount(); //band number
154153
GDALClose(ImgBef);
155154
ImgBef = NULL;
156-
157155
return 0;
158156
}
159157

@@ -193,15 +191,14 @@ int writeImg(char InputC2[], short* Img)
193191
size_t ns = ImgBef->GetRasterXSize();
194192
size_t nl = ImgBef->GetRasterYSize();
195193
size_t nb = ImgBef->GetRasterCount();
196-
197194
double* fNoDataV = new double[nb]();
198195
for (size_t i = 0; i < nb; i++)
199196
fNoDataV[i] = ImgBef->GetRasterBand(i + 1)->GetNoDataValue();
200197
double geoTransform[6];
201198
char projref[2048];
202199

203200
ImgBef->GetGeoTransform(geoTransform);
204-
const char *sProRef = ImgBef->GetProjectionRef(); //»ñȡͶӰÐÅÏ¢
201+
const char *sProRef = ImgBef->GetProjectionRef();
205202
strcpy(projref, sProRef);
206203
GDALClose(ImgBef);
207204
ImgBef = NULL;

Code/FSDAF.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ int resultSummary(int ns, int nl, int nb, int iblock, int* location_block, int l
3939

4040
int blockComputing(parameter* p1, int ns, int nl, int nb, int iblock, int* location_block, int location_block_neighbor[4], float* fineImg2_block);
4141

42-
/* CUDA version of some steps */
42+
/* CUDA version of parallel steps */
4343
int getBlockLine(parameter* p1, int &nL, int ns, int nb, int num_similar_pixel);
4444

4545
int cuGetHetIndex(parameter* p1, int scale_d, int ns_block, int nl_block, short* L1_class, float* het_index);

Code/Parameters.txt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
cuFSDAF_PARAMETER_START
22

33
# The input fine image at t1
4-
# IN_F1_NAME = F:\\Datasets\\Daxing_Test\\L-2019-6-14.tif
5-
# IN_F1_NAME = F:\\Datasets\\AHB_Test\\L_2018-3-25_4bands.tif
6-
IN_F1_NAME = F:\\Datasets\\Tianjin_Test\\L-2018-10-1_4bands.tif
4+
# IN_F1_NAME = F:\\Testdata\\Daxing\\L-2019-6-14.tif
5+
# IN_F1_NAME = F:\\Testdata\\AHB\\L_2018-3-25_4bands.tif
6+
IN_F1_NAME = F:\\Testdata\\Tianjin\\L-2018-10-1_4bands.tif
77

88

99
# The input coarse image at t1
10-
# IN_C1_NAME = F:\\Datasets\\Daxing_Test\\M-2019-6-14.tif
11-
# IN_C1_NAME = F:\\Datasets\\AHB_Test\\M_2018-3-25_4bands.tif
12-
IN_C1_NAME = F:\\Datasets\\Tianjin_Test\\M-2018-10-1_4bands.tif
10+
# IN_C1_NAME = F:\\Testdata\\Daxing\\M-2019-6-14.tif
11+
# IN_C1_NAME = F:\\Testdata\\AHB\\M_2018-3-25_4bands.tif
12+
IN_C1_NAME = F:\\Testdata\\Tianjin\\M-2018-10-1_4bands.tif
1313

1414

1515
# The input coarse image at t2
16-
# IN_C2_NAME = F:\\Datasets\\Daxing_Test\\M-2019-8-17.tif
17-
# IN_C2_NAME = F:\\Datasets\\AHB_Test\\M_2018-5-12_4bands.tif
18-
IN_C2_NAME = F:\\Datasets\\Tianjin_Test\\M-2018-12-4_4bands.tif
16+
# IN_C2_NAME = F:\\Testdata\\Daxing\\M-2019-8-17.tif
17+
# IN_C2_NAME = F:\\Testdata\\AHB\\M_2018-5-12_4bands.tif
18+
IN_C2_NAME = F:\\Testdata\\Tianjin\\M-2018-12-4_4bands.tif
1919

2020

2121
# The classified image for the fine image at t1
22-
# IN_F1_CLASS_NAME = F:\\Datasets\\Daxing_Test\\class
23-
# IN_F1_CLASS_NAME = F:\\Datasets\\AHB_Test\\class_AHB_180325
24-
IN_F1_CLASS_NAME = F:\\Datasets\\Tianjin_Test\\class
22+
# IN_F1_CLASS_NAME = F:\\Testdata\\Daxing\\class_daxing
23+
# IN_F1_CLASS_NAME = F:\\Testdata\\AHB\\class_AHB
24+
IN_F1_CLASS_NAME = F:\\Testdata\\Tianjin\\class_Tianjin
2525

2626

2727

Code/kernel.cu

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include<iostream>
1+
#include <iostream>
22
#include <stdio.h>
33

44
#include "cuda_runtime.h"
@@ -375,7 +375,6 @@ int cuFinalCalculation(parameter* p1, float* fine2, float *FineImg1, float* Coar
375375
size_t nThread = dimGrid.x * dimBlock.x; //size of 1 cycle
376376
size_t nWindowSize = (w + 1 + w) * (w + 1 + w); //size of window, and w is the length of the searching window
377377

378-
379378
size_t *col_wind = new size_t[(w + 1) * (w + 1) * (w + 1 + w) * (w + 1 + w)]();
380379
size_t *row_wind = new size_t[(w + 1) * (w + 1) * (w + 1 + w) * (w + 1 + w)]();
381380
for (size_t i = 0; i < w + 1; i++)
@@ -415,11 +414,9 @@ int cuFinalCalculation(parameter* p1, float* fine2, float *FineImg1, float* Coar
415414
cudaMalloc((void**)&CoarseImg2_d, sizeof(float) * imgSize);
416415
cudaMalloc((void**)&change_21_d, sizeof(float) * imgSize);
417416
cudaMalloc((void**)&similar_th_d, sizeof(float) * imgSize);
418-
419417
cudaMalloc((void**)&D_D_all_d, sizeof(float) * nWindowSize);
420418
cudaMalloc((void**)&col_wind_d, sizeof(size_t) * (w + 1) * (w + 1) * nWindowSize);
421419
cudaMalloc((void**)&row_wind_d, sizeof(size_t) * (w + 1) * (w + 1) * nWindowSize);
422-
423420
cudaMalloc((void**)&positionCand_orderDis_d, sizeof(size_t) * nWindowSize * nThread);
424421
cudaMalloc((void**)&mmap_order_dis_d, sizeof(float) * nWindowSize * nThread);
425422
cudaMalloc((void**)&D_D_cand_d, sizeof(double) * p1->num_similar_pixel * nThread);
@@ -432,12 +429,10 @@ int cuFinalCalculation(parameter* p1, float* fine2, float *FineImg1, float* Coar
432429
cudaMemcpy(CoarseImg2_d, CoarseImg2, sizeof(float) * imgSize, cudaMemcpyHostToDevice);
433430
cudaMemcpy(change_21_d, change_21, sizeof(float) * imgSize, cudaMemcpyHostToDevice);
434431
cudaMemcpy(similar_th_d, similar_th, sizeof(float) * imgSize, cudaMemcpyHostToDevice);
435-
436432
cudaMemcpy(D_D_all_d, D_D_all, sizeof(float) * nWindowSize, cudaMemcpyHostToDevice);
437433
cudaMemcpy(col_wind_d, col_wind, sizeof(size_t) * (w + 1) * (w + 1) * nWindowSize, cudaMemcpyHostToDevice);
438434
cudaMemcpy(row_wind_d, row_wind, sizeof(size_t) * (w + 1) * (w + 1) * nWindowSize, cudaMemcpyHostToDevice);
439435

440-
441436
for (size_t iCycle = 0; iCycle * dimGrid.x * dimBlock.x < ns_block * nl_block; iCycle++)
442437
{
443438
size_t nCyl = (ns_block * nl_block / dimGrid.x / dimBlock.x + 20 - 1) / 20;

Code/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ int main(int argc, char* argv[])
99
/* Parameters setting */
1010
parameter *p1 = new parameter[1];
1111
parseParameters(argv[1], p1);
12-
dim3 iDimGrid(512); //Dimension of threads for CUDA
12+
dim3 iDimGrid(512); //Dimension of threads for CUDA
1313
dim3 iDimBlock(256);
1414
p1->dimGrid = iDimGrid;
1515
p1->dimBlock = iDimBlock;
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)