[Gdal-dev] Ecw and MrSID performance.

Nacho brodin_ign at gva.es
Wed Feb 2 07:11:50 EST 2005


Hi,
I have downloaded the latest CVS version of GDAL and I have been doing some 
tests with MrSID and Ecw images in linux with different window sizes (without 
using overviews). I am testing Ecw and Mrsid accesing by lines and also 
reading the full window. The latest version of GDAL give me (with Ecw) very 
good results reading by window and very bad results reading lines. In MrSID 
reading data is very slow at any case.
These are the tests results.
------------------------
Ecw image size 8400x6000
Reading lines (in px) 	500x1 =  0.165 s
			8400x1 = 0.872 s
			4000x10 = 0.860 s
			1x10 =	0.840 s
			1x500 = 57.151 s
			1x6000 =  s
			2048x2048 =
Ecw image size 8400x6000
Reading window (in px) 	500x1 =  0.251 s
		 	8400x1 = 0.169 s
			4000x10 = 0.146 s
			1x10 =	0.066 s
			1x500 = 0.093 s
			1x6000 = 0.316 s
			2048x2048 = 1.442 s
Ecw image size 45899x37169
Reading window (in px) 	500x1 =  0.691 s
		 	45899x1 = 0.454 s
			4000x10 = 0.367 s
			1x10 =	0.313 s
			1x500 = 0.349 s
			1x37169 = 4.624 s
			2048x2048 = 1.477 s
MrSID image size 7100x4800
Reading lines (in px) 	500x1 =  0.426 s
		 	7100x1 = 0.425 s
			4000x10 = 0.453 s
			1x10 =	0.405 s
			1x500 = 2.799 s
			1x4000 = 39.06 s
			2048x2048 = 10.775 s
MrSID image size 7100x4800
Reading window (in px) 	500x1 =  0.426 s
		 	7100x1 = 0.393 s
			4000x10 = 0.420 s
			1x10 =	0.423 s
			1x500 = 8.095 s
			1x4000 = 1m 0.834 s
			2048x2048 = 32.391 s
------------------------

This is the code for the probes. It's only a simple test code for
images with three bands.

READING LINES

#include <stdio.h>
#include "gdal.h"
#include "cpl_conv.h"

int main( int argc, char **argv ){

    GDALDatasetH		hDataset;
    GDALRasterBandH 	*band1,*band2,*band3;
    const char          		*pszFilename = NULL;
    void           			*pData1,*pData2,*pData3;
    int 				nXSize,nYSize,nBandas,iLine;
    CPLErr       			eErr1,eErr2,eErr3;
    GDALDataType 		eType;
    int 				tx,ty;

    pszFilename=argv[1];
    tx=atoi(argv[2]);
    ty=atoi(argv[3]);

    GDALAllRegister();
    hDataset = GDALOpen( pszFilename, GA_ReadOnly );

    nXSize=GDALGetRasterXSize( hDataset );
    nYSize=GDALGetRasterYSize( hDataset );
    nBandas=GDALGetRasterCount(hDataset);
    tx=nXSize;
    ty=nYSize;

    band1=GDALGetRasterBand( hDataset,1);
    band2=GDALGetRasterBand( hDataset,2);
    band3=GDALGetRasterBand( hDataset,3);

    eType = GDALGetRasterDataType(band1);
    pData1=CPLMalloc(tx * GDALGetDataTypeSize(eType) / 8);
    pData2=CPLMalloc(tx * GDALGetDataTypeSize(eType) / 8);
    pData3=CPLMalloc(tx * GDALGetDataTypeSize(eType) / 8);

    for( iLine = 0; iLine < ty; iLine++ ){
    	eErr1 = GDALRasterIO( band1, GF_Read, nXSize-tx, iLine, tx, 1,
                                        pData1, tx, 1, eType, 0, 0 );
        eErr2 = GDALRasterIO( band2, GF_Read, nXSize-tx, iLine, tx, 1,
                                        pData2, tx, 1, eType, 0, 0 );
        eErr3 = GDALRasterIO( band3, GF_Read, nXSize-tx, iLine, tx, 1,
                                        pData3, tx, 1, eType, 0, 0 );

        if( eErr1 != CE_None || eErr2 != CE_None || eErr3 != CE_None){
            printf("Error ...\n");
            return -1;
        }
    }

    CPLFree( pData1 );
    CPLFree( pData2 );
    CPLFree( pData3 );
    return 0;
}

------------------------
READING WINDOW

#include <stdio.h>
#include "gdal.h"
#include "cpl_conv.h"

int main( int argc, char **argv ){

    GDALDatasetH		hDataset;
    GDALRasterBandH 	*band1,*band2,*band3;
    const char         		*pszFilename = NULL;
    void           			*pData1,*pData2,*pData3;
    int 				nXSize,nYSize,nBandas,iLine;
    CPLErr       			eErr1,eErr2,eErr3;
    GDALDataType 		eType;
    int 				tx,ty;

    pszFilename=argv[1];
    tx=atoi(argv[2]);
    ty=atoi(argv[3]);

    GDALAllRegister();
    hDataset = GDALOpen( pszFilename, GA_ReadOnly );

    nXSize=GDALGetRasterXSize( hDataset );
    nYSize=GDALGetRasterYSize( hDataset );
    nBandas=GDALGetRasterCount(hDataset);
    tx=nXSize;
    ty=nYSize;

    band1=GDALGetRasterBand( hDataset,1);
    band2=GDALGetRasterBand( hDataset,2);
    band3=GDALGetRasterBand( hDataset,3);

    eType = GDALGetRasterDataType(band1);
    pData1=CPLMalloc(ty * tx * GDALGetDataTypeSize(eType) / 8);
    pData2=CPLMalloc(ty * tx * GDALGetDataTypeSize(eType) / 8);
    pData3=CPLMalloc(ty * tx * GDALGetDataTypeSize(eType) / 8);

    eErr1 = GDALRasterIO( band1, GF_Read, 0, 0, tx, ty,
                                       pData1, tx, ty, eType, 0, 0 );
    eErr2 = GDALRasterIO( band2, GF_Read, 0, 0, tx, ty,
                                        pData2, tx, ty, eType, 0, 0 );
    eErr3 = GDALRasterIO( band3, GF_Read, 0, 0, tx, ty,
                                        pData3, tx, ty, eType, 0, 0 );

    if( eErr1 != CE_None || eErr2 != CE_None || eErr3 != CE_None){
      	printf("Error ...\n");
        return -1;
    }

    CPLFree( pData1 );
    CPLFree( pData2 );
    CPLFree( pData3 );
    return 0;
}

Thanks for all.

-- 
  Nacho Brodin
  Equipo de desarrollo gvSIG
  http://www.gvsig.gva.es




More information about the Gdal-dev mailing list