[gdal-dev] Re: 254 into 255

Jay L. jzl5325 at psu.edu
Thu Oct 27 06:46:11 EDT 2011


Thanks for posting this!  I had to no idea that this functionality existed.
 Is this documented somewhere?

On Thu, Oct 27, 2011 at 4:58 AM, Chaitanya kumar CH
<chaitanya.ch at gmail.com>wrote:

> J,
>
> A vrt file[1] can implement your requirements. It can create a 'lookup
> table' to translate your pixel values.
> Start by running gdalbuildvrt on your raster file and modify it to contain
> the LUT element. It will look something like this:
>
> <VRTDataset rasterXSize="512" rasterYSize="512">
>   <VRTRasterBand dataType="Byte" band="1">
>
>     <ComplexSource>
>       <SourceFilename relativeToVRT="1">utm.tif</SourceFilename>
>       <SourceBand>1</SourceBand>
>       <ScaleOffset>0</ScaleOffset>
>
>       <ScaleRatio>1</ScaleRatio>
>       <LUT>0:0,253:253,254:255</LUT>
>       <SrcRect xOff="0" yOff="0" xSize="512" ySize="512"/>
>
>       <DstRect xOff="0" yOff="0" xSize="512" ySize="512"/>
>
>     </ComplexSource>
>   </VRTRasterBand>
>   <VRTRasterBand dataType="Byte" band="2">
>     <ComplexSource>
>
>       <SourceFilename relativeToVRT="1">utm.tif</SourceFilename>
>       <SourceBand>2</SourceBand>
>       <ScaleOffset>0</ScaleOffset>
>
>       <ScaleRatio>1</ScaleRatio>
>       <LUT>0:0,253:253,254:255</LUT>
>       <SrcRect xOff="0" yOff="0" xSize="512" ySize="512"/>
>
>       <DstRect xOff="0" yOff="0" xSize="512" ySize="512"/>
>
>     </ComplexSource>
>   </VRTRasterBand>
>   <VRTRasterBand dataType="Byte" band="3">
>     <ComplexSource>
>
>       <SourceFilename relativeToVRT="1">utm.tif</SourceFilename>
>       <SourceBand>3</SourceBand>
>       <ScaleOffset>0</ScaleOffset>
>
>       <ScaleRatio>1</ScaleRatio>
>       <LUT>0:0,253:253,254:255</LUT>
>       <SrcRect xOff="0" yOff="0" xSize="512" ySize="512"/>
>
>       <DstRect xOff="0" yOff="0" xSize="512" ySize="512"/>
>
>     </ComplexSource>
>   </VRTRasterBand>
> </VRTDataset>
>
>
> The LUT element is the key here. It tells the VRT driver to keep the values
> from 0 to 253 as they are and change 254 to 255.
> Remember to replace the appropriate parts.
>
> [1]: http://www.gdal.org/gdal_vrttut.html
>
> On Thu, Oct 27, 2011 at 12:40 PM, joolek <joolek.o at gmail.com> wrote:
>
>> Yes, this is exactly what I am struggling to do. Gdal is so powerful - but
>> I can't get it working.
>> J
>>
>>
>> On 26 Oct 2011, at 17:10, "Chaitanya kumar CH [via OSGeo.org]"<[hidden
>> email] <http://user/SendEmail.jtp?type=node&node=6935299&i=0>> wrote:
>>
>> Do you want to convert just the pixels with the values (254,254,254)?
>>
>> On Wed, Oct 26, 2011 at 9:33 PM, joolek <[hidden email]<http://user/SendEmail.jtp?type=node&node=6933215&i=0>
>> > wrote:
>>
>>> Hi I basically want to convert all the 254 254 254 into 255 255 255... is
>>> this possible?
>>>
>>> --
>>> View this message in context:
>>> http://osgeo-org.1803224.n2.nabble.com/254-into-255-tp6931988p6933182.html
>>> Sent from the GDAL - Dev mailing list archive at Nabble.com.
>>> _______________________________________________
>>> gdal-dev mailing list
>>> [hidden email] <http://user/SendEmail.jtp?type=node&node=6933215&i=1>
>>> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>>>
>>
>>
>>
>> --
>> Best regards,
>> Chaitanya kumar CH.
>>
>> +91-9494447584
>> 17.2416N 80.1426E
>>
>> _______________________________________________
>> gdal-dev mailing list
>> [hidden email] <http://user/SendEmail.jtp?type=node&node=6933215&i=2>
>> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>>
>> ------------------------------
>>  If you reply to this email, your message will be added to the discussion
>> below:
>> http://osgeo-org.1803224.n2.nabble.com/254-into-255-tp6931988p6933215.html
>>  To unsubscribe from 254 into 255, click here.
>>
>>
>> ------------------------------
>> View this message in context: Re: 254 into 255<http://osgeo-org.1803224.n2.nabble.com/254-into-255-tp6931988p6935299.html>
>>
>> Sent from the GDAL - Dev mailing list archive<http://osgeo-org.1803224.n2.nabble.com/GDAL-Dev-f2022644.html>at Nabble.com.
>>
>> _______________________________________________
>> gdal-dev mailing list
>> gdal-dev at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>>
>
>
>
> --
> Best regards,
> Chaitanya kumar CH.
>
> +91-9494447584
> 17.2416N 80.1426E
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20111027/f8173650/attachment.html


More information about the gdal-dev mailing list