[gdal-dev] How to make my GDAL code faster?
Nicolas DEGARNE
nicolas.degarne at gmail.com
Wed Apr 15 10:54:55 EDT 2009
Hello,
Just to introduce, I am a student in internship in French Guyana.I'm French
and I have not wrote in English thing's for a wile so sorry for my bad
English.
I'm a beginning in GDAL in c (for the moment) with Ubuntu
I am trying to make a program extracting target from pictures in
tif(geotiff) for example Size X: 17553 // Size Y: 15226 ..
To detect target,I used a algorithm which get the mean of a windows 5x5 and
compare the energies off the windows with the central pixel.
I wants to improve my software in order to be faster because for the moment
it spend 200s
To run through every pixel I used the process below
hScanBloc1 = (GByte *) CPLMalloc(sizeof(GByte)*5);
hScanBlocOut = (GByte *) CPLMalloc(sizeof(GByte)*1);
for( iLine = 0; iLine < nYSize-5; iLine++)
> {
> for( iCol = 0; iCol < nXSize-5; iCol++ )
> {
>
> //Get line from the windows
> eErr1 = GDALRasterIO( hBand1, GF_Read,
> iCol, iLine , 5, 1, hScanBloc1, 5,1, GDT_Byte, 1, 1);
> eErr2 = GDALRasterIO( hBand1, GF_Read, iCol,
> (iLine+1), 5, 1, hScanBloc2, 5,1, GDT_Byte, 1, 1);
> eErr3 = GDALRasterIO( hBand1, GF_Read, iCol,
> (iLine+2), 5, 1, hScanBloc3, 5,1, GDT_Byte, 1, 1);
> eErr4 = GDALRasterIO( hBand1, GF_Read, iCol,
> (iLine+3), 5, 1, hScanBloc4, 5,1, GDT_Byte, 1, 1);
> eErr5 = GDALRasterIO( hBand1, GF_Read, iCol,
> (iLine+4), 5, 1, hScanBloc5, 5,1, GDT_Byte, 1, 1);
>
> //Get all value in the Windows
> for(iWindows=0;iWindows<5;iWindows++)
> {
> Value=Value+hScanBloc1[iWindows];
> Value=Value+hScanBloc2[iWindows];
> Value=Value+hScanBloc3[iWindows];
> Value=Value+hScanBloc4[iWindows];
> Value=Value+hScanBloc5[iWindows];
> }
>
> hScanBlocOut[0]=FinalValue;
> eErr = GDALRasterIO( hBandOut1,
> GF_Write,iCol,iLine ,1,1 , hScanBlocOut, 1,1, GDT_Byte, 1, 1);
>
>
>
> CPLErr eErr;
> eErr = GDALRasterIO( hBandOut1,
> GF_Write,iCol,iLine ,1,1 , hScanBlocOut, 1,1, GDT_Byte, 1, 1);
>
I read on help and *gdal.h* File Reference that it could exist faster way so
I have some ideas like :
Merging the code to c++
Using Read/Write block
Use Tile/Block to accelerate the process
Use the Warpprocess to calulate windows mean's faster
I hope you understand my request and it was clear
Thanks for advance
Best Regards
Nicolas
--
Nicolas Degarne
76 rue de Nancy
94170 Le Perreux
06 84 93 80 94
nicolas.degarne at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20090415/400b93e4/attachment-0001.html
More information about the gdal-dev
mailing list