MapInfo Pro

Expand all | Collapse all

Raster Rendering Deep Dive – Part 3 – RGBColor Layers

  • 1.  Raster Rendering Deep Dive – Part 3 – RGBColor Layers

    Pitney Bowes
    Posted 06-28-2019 01:00
    Edited by Sam Roberts 07-19-2019 01:15
      |   view attached

    The previous articles demonstrated default algorithms and LUTColor layers. This article demonstrates the RGBColor layer and shows you how to drape satellite imagery on hill shaded terrain using color contrast enhancement.

    Previous article - Raster Rendering Deep Dive – Part 2 – LUTcolor Layers

    An RGBColor layer is much like a LUTColor layer. In a LUTColor layer a single data is transformed to acquire an RGB color from a table. In an RGBColor layer the Red, Green and Blue color components are acquired individually by transforming three data bands. In each component, the transformed data is scaled to a value between 0 and 255, representing the component color. The three components are then combined into an RGB color value for each pixel.

    You must design a data transform for each of these Red, Green and Blue components. You do not need to provide a color look-up table. Like the LUTColor layer, you can also use an Intensity component to provide hill shading and an Opacity component to implement opacity modulation.

    The following example is a scene acquired from the Sentinel-2 satellite. The scene has been supplied as a collection of JPEG2000 rasters – one for each band. The source rasters have been brought together in a MapInfo Virtual Raster to combine these 13 source rasters into a single multi-banded raster. This is the source raster referred to in the rendering algorithm. Below are the XML files for the virtual raster and for the rendering algorithm.

    <?xml version="1.0" encoding="utf-8"?>
    <VirtualRaster>
    	<Raster File="SE_20171103T102201_B01.jp2" Name="RasterSource0" />
    	<Raster File="SE_20171103T102201_B02.jp2" Name="RasterSource1" />
    	<Raster File="SE_20171103T102201_B03.jp2" Name="RasterSource2" />
    	<Raster File="SE_20171103T102201_B04.jp2" Name="RasterSource3" />
    	<Raster File="SE_20171103T102201_B05.jp2" Name="RasterSource4" />
    	<Raster File="SE_20171103T102201_B06.jp2" Name="RasterSource5" />
    	<Raster File="SE_20171103T102201_B07.jp2" Name="RasterSource6" />
    	<Raster File="SE_20171103T102201_B08.jp2" Name="RasterSource7" />
    	<Raster File="SE_20171103T102201_B8A.jp2" Name="RasterSource8" />
    	<Raster File="SE_20171103T102201_B09.jp2" Name="RasterSource9" />
    	<Raster File="SE_20171103T102201_B10.jp2" Name="RasterSource10" />
    	<Raster File="SE_20171103T102201_B11.jp2" Name="RasterSource11" />
    	<Raster File="SE_20171103T102201_B12.jp2" Name="RasterSource12" />
    	<RasterInfo>
    		<FieldInfo Name="Field">
    			<BandInfo Name="Band 1">
    				<Raster Name="RasterSource0" Field="0" Band="0" PrimaryRaster="true" />
    			</BandInfo>
    			<BandInfo Name="Band 2">
    				<Raster Name="RasterSource1" Field="0" Band="0" />
    			</BandInfo>
    			<BandInfo Name="Band 3">
    				<Raster Name="RasterSource2" Field="0" Band="0" />
    			</BandInfo>
    			<BandInfo Name="Band 4">
    				<Raster Name="RasterSource3" Field="0" Band="0" />
    			</BandInfo>
    			<BandInfo Name="Band 5">
    				<Raster Name="RasterSource4" Field="0" Band="0" />
    			</BandInfo>
    			<BandInfo Name="Band 6">
    				<Raster Name="RasterSource5" Field="0" Band="0" />
    			</BandInfo>
    			<BandInfo Name="Band 7">
    				<Raster Name="RasterSource6" Field="0" Band="0" />
    			</BandInfo>
    			<BandInfo Name="Band 8">
    				<Raster Name="RasterSource7" Field="0" Band="0" />
    			</BandInfo>
    			<BandInfo Name="Band 8A">
    				<Raster Name="RasterSource8" Field="0" Band="0" />
    			</BandInfo>
    			<BandInfo Name="Band 9">
    				<Raster Name="RasterSource9" Field="0" Band="0" />
    			</BandInfo>
    			<BandInfo Name="Band 10">
    				<Raster Name="RasterSource10" Field="0" Band="0" />
    			</BandInfo>
    			<BandInfo Name="Band 11">
    				<Raster Name="RasterSource11" Field="0" Band="0" />
    			</BandInfo>
    			<BandInfo Name="Band 12">
    				<Raster Name="RasterSource12" Field="0" Band="0" />
    			</BandInfo>
    		</FieldInfo>
    	</RasterInfo>
    </VirtualRaster>


    <?xml version="1.0" encoding="UTF-8"?>
    <RenderAlgorithm Version="1.0" Enable="True">
    	<Name>RGBColor Layer Algorithm</Name>
    	<Description>RGBColor layer from a Sentinel-2 scene</Description>
    	<ValidCellByComponentRule>All</ValidCellByComponentRule>
    
    	<Raster>
    		<Name>Raster01</Name>
    		<File>SE_20171103T102201.xml</File>
    	</Raster>
    
    	<DataTransform Name = "Transform01">
    		<Type>NBitColor</Type>
    		<Bits>12</Bits>
    	</DataTransform>
    
    	<DataTransform Name = "Transform02">
    		<Type>Linear</Type>
    		<RangeMin>0</RangeMin>
    		<RangeMax>1500</RangeMax>
    		<RangeType>Value</RangeType>
    	</DataTransform>
    
    	<DataTransform Name = "Transform03">
    		<Type>EqualAreaNonLinear</Type>
    		<EqualAreaPercent>0.25</EqualAreaPercent>
    	</DataTransform>
    
    	<Layer Type = "RGBColor" Name = "Natural colors 4 3 2">
    		<Component Type = "Red" Enable = "TRUE">
    			<Raster Name = "Raster01" Field = "0" Band = "3"/>
    			<DataTransform Name = "Transform03"/>
    		</Component>
    		<Component Type = "Green" Enable = "TRUE">
    			<Raster Name = "Raster01" Field = "0" Band = "2"/>
    			<DataTransform Name = "Transform03"/>
    		</Component>
    		<Component Type = "Blue" Enable = "TRUE">
    			<Raster Name = "Raster01" Field = "0" Band = "1"/>
    			<DataTransform Name = "Transform03"/>
    		</Component>
    		<Component Type="Intensity" Enable="False"/>
    		<Component Type="Opacity" Enable="False"/>
    	</Layer>
    </RenderAlgorithm>

    The algorithm maps Sentinel-2 bands 4, 3 and 2 to Red, Green and Blue components to create a "Natural Color" rendering of the scene. The field index (zero-based) and the band index (zero-based) of the data I want to pull from the source raster are specified in each component.

    RGB Natural Color, enhanced
    For illustration, the algorithm includes three different data transforms even though it only uses one of them. The first is of type "NBitColor" and defines "Bits" to be 12. This is a linear transform from 0 – 4095 (12 bits of dynamic range) and does not require raster statistics to display. The second is a "Linear" transform type where the range has been defined from 0 – 1500. The range values are specified as data values (RangeType "Value") and so no statistics are required. They could also have been specified as "Percentage" or "Percentile" numbers (which range from 0 – 1) which would trigger a requirement for statistics. The third transform is an equal area transform which we used for LUTColor previously. However, it now includes a property called "EqualAreaPercent" (which ranges from 0 – 1). If this value is 0 then it returns a linear transform across the data range. If it is 1 then it returns an equal area transform. A value anywhere in-between returns a transitional transform between linear and equal area. In this example, I have used 25% and this has the effect of increasing the color contrast and making the image more appealing.

    Here is a second example that adds an intensity component to drape the RGB color over hill shaded terrain. In this example I show the "Shadow" and "Highlight" elements which allow you to exercise control over the position of the sun and the specular highlight.

    <?xml version="1.0" encoding="UTF-8"?>
    <RenderAlgorithm Version="1.0" Enable="True">
    	<Name>RGBColor Layer Algorithm</Name>
    	<Description>RGBColor layer from a Landsat-8 scene drapedon terrain</Description>
    	<ValidCellByComponentRule>All</ValidCellByComponentRule>
    	<CoordinateSystem>CoordSys Earth Projection 1, 104</CoordinateSystem>
    	
    	<Raster>
    		<Name>Raster01</Name>
    		<File>LC08_L1TP_091082_20190426_20190508_01_T1.xml</File>
    	</Raster>
    	
    	<Raster>
    		<Name>Raster02</Name>
    		<File>C:\Temp\GA_SRTM_1as_25cm_DEM-H.mrr</File>
    	</Raster>
    	
    	<DataTransform Name = "Transform03">
    		<Type>EqualAreaNonLinear</Type>
    	</DataTransform>
    	
    	<DataConditioning Name="RemoveZero">
    		<Value>0</Value>
    	</DataConditioning>
    	
    	<Layer Type = "RGBColor" Name = "Natural colors 4 3 2">
    		<ColorIntensity>90</ColorIntensity>
    		<Component Type = "Red" Enable = "TRUE">
    			<Raster Name = "Raster01" Field = "0" Band = "3"/>
    			<DataTransform Name = "Transform03"/>
    			<DataConditioning Name="RemoveZero"/>
    		</Component>
    		<Component Type = "Green" Enable = "TRUE">
    			<Raster Name = "Raster01" Field = "0" Band = "2"/>
    			<DataTransform Name = "Transform03"/>
    			<DataConditioning Name="RemoveZero"/>
    		</Component>
    		<Component Type = "Blue" Enable = "TRUE">
    			<Raster Name = "Raster01" Field = "0" Band = "1"/>
    			<DataTransform Name = "Transform03"/>
    			<DataConditioning Name="RemoveZero"/>
    		</Component>
    		<Component Type="Intensity" Enable="True">
    			<Raster Name="Raster02"/>
    			<Shadow>
    				<Enable>True</Enable>
    				<Azimuth>45</Azimuth>
    				<Altitude>60</Altitude>
    				<Scale>50</Scale>
    			</Shadow>
    			<Highlight>
    				<Enable>True</Enable>
    				<Azimuth>315</Azimuth>
    				<Altitude>60</Altitude>
    				<Scale>50</Scale>
    			</Highlight>
    		</Component>
    	</Layer>
    </RenderAlgorithm>
    

    In this example, I have used Landsat-8 data. I have downloaded a scene which is supplied as a collection of TIFF files. These have been brought together as a virtual raster. The RGBColor layer uses bands 4, 3 and 2 to generate a "Natural Color" image, but I have exaggerated the colors using an equal area transform. The Intensity component connects to a DTM raster to provide hill shade. I have used the ColorIntensity property to fade the hill-shading (in 17.03 this property does not work as intended). Also, I have added a DataConditioning element which declares that zero is an invalid value. This is used in all three color components to remove zero values from the data stream (which represent the border about the Landsat scene).


    RGB Natural Color, enhanced Landsat - 8
    We have now taken a look at the LUTColor and RGBColor layers. In the next article in this series, we will explore the "Image" layer type.

    Next article - Raster Rendering Deep Dive – Part 4 – Image Layers


    ------------------------------
    Sam Roberts
    Engineer, MapInfo Pro Advanced (Raster)
    Australia
    ------------------------------

    Attachment(s)



  • 2.  RE: Raster Rendering Deep Dive – Part 3 – RGBColor Layers

    Pitney Bowes
    Posted 07-01-2019 06:18
    This last image looks incredible, great to we what can be achieved!

    ------------------------------
    Chris Jenkins
    Pitney Bowes Software Ltd
    HENLEY-ON-THAMES
    ------------------------------