[gdal-dev] Modifying a raster pixel by pixel with GDAL

Jorge Arevalo jorgearevalo at libregis.org
Thu Dec 13 10:58:50 PST 2012


Hello,

I want to modify every single pixel of a 1 band GeoTiff file,
following a formula (multiply each pixel for a value and then add
another value).

output_pixel[i][j] = input_pixel[i][j] * K[i][j] + C[i][j]

I can't apply a linear scale (it would be as easier as -scale option
in gdal_translate). Sounds more like applying a mask to the band's
data.

My first approach is to get every data block of the raster (IReadBlock
call), apply the transformation to every single pixel ( = apply a mask
to the data block), and put the block in the output raster.

Is there any other faster/smarter approach?

Many thanks in advance,

--
Jorge Arevalo
http://www.krop.com/jorgearevalo


More information about the gdal-dev mailing list