[gdal-dev] Re: TIFF write and comparison

Akhil Jaggarwal axj4159 at cs.rit.edu
Mon Sep 13 23:54:35 EDT 2010


Hi,

Thank you for the reply.

Calls to GDALRasterIO() are OK. Which I assume in a line interleaved
format look like this:

 GDALRasterIO(hBand, GF_Read, 0,0, i, j, pafScanline,
                        nBlockXSize, nBlockYSize,
                        GDT_Int16,
                        0, 0);

Is that correct?

Also, the statement: if(pafScanline[j] == pixel_value), is that a
correct way to check if a pixel value at the jth col is equal to some
constant?

pafScanline is declared as follows: short int * pafScanline. In the
API, pdata is a void *.

Is this way to substitute the value of a pixel (of short int type)
according to a rule, and then writing the pixel back to the TIFF a
correct way? -

short int rule1 = 1;
void *change = malloc(sizeof(short int));
change1 = &rule1;
...
...
...
GDALRasterIO( hDestDS, GF_Write, 0,0, i,j, change1,
nBlockXSize,nBlockYSize , GDT_Int16, 0,0);

Thanks.

On Mon, Sep 13, 2010 at 4:40 PM, Chaitanya kumar CH
<chaitanya.ch at gmail.com> wrote:
> Akhil,
>
> Check which of the GDALRasterIO() calls are made.
>
> Also, I noticed that you are calling GDALRasterIO() to read the data pixel
> by pixel. Line by line will be faster, especially if the data is line
> interleaved.
>
> On Mon, Sep 13, 2010 at 8:30 PM, Akhil Jaggarwal <axj4159 at cs.rit.edu> wrote:
>>
>> Hi,
>>
>> I've shortened my questions to exactly this part of the code:
>>
>>  // read datasets, compare data and write
>>                       if ( (pafScanline2[j] > 6 || pafScanline3[j] > 950)
>> &&
>>                                       pafScanline[j] == 2) {
>>                               GDALRasterIO( hDestDS, GF_Write, 0,0, i,j,
>>                                               change1, i, j, GDT_Byte,
>> 0,0);
>>                       }
>>                       else if( (pafScanline4[j] < -700) &&
>>                                       pafScanline[j] == 6 ) {
>>                               GDALRasterIO( hDestDS, GF_Write, 0,0, i,j,
>>                                               change2, i, j, GDT_Byte,
>> 0,0);
>>                       }
>>                       else if( (pafScanline2[j] > 6) && pafScanline[j] ==
>> 3 ) {
>>                               GDALRasterIO( hDestDS, GF_Write, 0,0, i,j,
>>                                               change2, i, j, GDT_Byte,
>> 0,0);
>>                       }
>>                       else if((pafScanline3[j]>1500) && pafScanline[j] ==
>> 6) {
>>                               GDALRasterIO( hDestDS, GF_Write, 0,0, i,j,
>>                                               change1, i, j, GDT_Byte,
>> 0,0);
>>                       }
>>                       else
>>                               GDALRasterIO( hDestDS, GF_Write, 0,0, i,j,
>>                                               &pafScanline[j], i, j,
>> GDT_Byte, 0,0);
>>               //      printf("%u\n", pafScanline[j]);
>>
>>
>> 1) Am I writing pixels the correct way?
>>
>> As of now I am getting just the exact copy of the input TIFF without
>> any pixel modifications. Where step am I doing wrong.
>>
>> Any help would be great!
>>
>> Thanks.
>> _______________________________________________
>> gdal-dev mailing list
>> gdal-dev at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>
>
>
> --
> Best regards,
> Chaitanya kumar CH.
> /tʃaɪθənjə/ /kʊmɑr/
> +91-9494447584
> 17.2416N 80.1426E
>


More information about the gdal-dev mailing list