[Gdal-dev] how to get pixels' band vector efficiently
Andrew Finley
afinley at gis.umn.edu
Tue Sep 14 17:20:26 EDT 2004
Hi All,
I have written an image classification algorithm which uses gdal to fill
a vector of band values for each pixel. I'm looking for a better/faster
way of accessing these values. Two general ways I might think to speed
this up are:
1) move one tile at a time into memory then apply the loop below.
2) find a way to load my target vector more efficiently than one
pixel/layer at a time.
So I guess I'm looking for some ideas or example code. Could the
tileindex application offer any help? Does it load logical image blocks
(i.e., from a single page)?
Thanks a lot for suggestions.
-Andy
Current approach:
//every pixel loop
for (int row = 0; row < featureDataset->GetRasterYSize(); row++){
for (int col = 0; col < featureDataset->GetRasterXSize(); col++){
//fill targetBandVec
for (layer = 1; layer <= featureDataset->GetRasterCount(); layer++){
featureBand = featureDataset->GetRasterBand( layer );
featureBand->RasterIO(GF_Read, col, row, 1, 1, featurePixel, 1, 1,
GDT_Float32, 0, 0 );
targetBandVec[layer-1]=featurePixel[0];
}
Then classify the target vector...
}
}
--
Andrew Finley, Research Fellow
Department of Forest Resources
College of Natural Resources
University of Minnesota
305 Green Hall
1530 Cleveland Avenue N.
St. Paul, MN 55108
Ph 612-624-1714 office
www.cnr.umn.edu/FR/people/facstaff/finley/index.html
More information about the Gdal-dev
mailing list