MapInfo Pro

Expand all | Collapse all

Unwanted transparency with 8 bit images

Jump to Best Answer
  • 1.  Unwanted transparency with 8 bit images

    Posted 02-12-2020 21:15
      |   view attached
    I'm trying to open 8 bit GeoTIFF images in MapInfo Pro v2019. It seems to automatically be making white pixels transparent?

    I've tried setting no transparent colour (or setting a different colour) under Adjust Image Styles, but the white pixels are always transparent in the map.

    I've tried searching for a solution but didn't find any. Closest I got was some discussion about alpha channels and being able to disable this under the Raster options, however it appears that Raster options are now not available in the standard licence anyway?

    Thanks,


    ------------------------------
    Timothy Mashford
    Melbourne, Australia
    ------------------------------


  • 2.  RE: Unwanted transparency with 8 bit images

    Employee
    Posted 02-12-2020 21:40
    Hi Timothy,

    Can you share a GeoTiff raster that you are using?

    Thanks,
    Andrei

    ------------------------------
    Andrei Veselov
    Pitney Bowes Software Inc.
    Troy NY
    ------------------------------



  • 3.  RE: Unwanted transparency with 8 bit images

    Posted 02-12-2020 22:24
      |   view attached
    Hi Andrei,

    Good to hear from you :)

    I've attached a sample file.

    Thanks,

    Tim

    ------------------------------
    Timothy Mashford
    Melbourne, Australia
    ------------------------------

    Attachment(s)

    tif
    geotiff_example.tif   4K 1 version


  • 4.  RE: Unwanted transparency with 8 bit images

    Employee
    Posted 02-12-2020 23:00
    Hi Tim,

    Great to hear from you as well!

    Can you try to disable MiRaster handlers in Raster Preferences dialog? You will need to do it for both Native and GDAL drivers (see attached images).


    That would force Pro to use older raster handlers.

    Regards,
    Andrei

    ------------------------------
    Andrei Veselov
    Pitney Bowes Software Inc.
    Troy NY
    ------------------------------



  • 5.  RE: Unwanted transparency with 8 bit images

    Posted 02-12-2020 23:46
      |   view attached
    Hi Andrei,

    Am I supposed to see Raster Preferences under the Pro tab? Because I can't....

    I also can't see a Raster tab in the ribbon. Does this mean maybe I missed something with the installation?

    Tim

    ------------------------------
    Timothy Mashford
    Melbourne, Australia
    ------------------------------



  • 6.  RE: Unwanted transparency with 8 bit images

    Employee
    Posted 02-13-2020 00:40
      |   view attached
    Hi Timothy,

    You don't have Mapinfo Pro Raster Add-in running that's the reason why Raster preferences are not getting displayed.

    You can go to Home->Tool Extension->Registered and in the tools manager window, check if Mapinfo Pro Raster Add-in is available. If it's available, click on the "Load Tool" button.

    Once the Add-in is loaded, you will see the option that Andrei mentioned.

    Thanks
    Anshul

    ------------------------------
    Anshul Goel
    Knowledge Community Shared Account
    Shelton CT
    ------------------------------



  • 7.  RE: Unwanted transparency with 8 bit images

    Posted 02-13-2020 00:43
    Yep, it looks like my installation corrupted somehow, so the raster options aren't there.

    I'm reinstalling now, and will try that trick thanks Andrei.

    One more question, would there be a way of setting this option for many users? Is this stored in a preference file or something?

    ------------------------------
    Timothy Mashford
    Melbourne, Australia
    ------------------------------



  • 8.  RE: Unwanted transparency with 8 bit images
    Best Answer

    Employee
    Posted 02-13-2020 01:17
    I believe that pure white is treated specially in the raster handler for valid reasons. Unfortunate, but true.

    I found a solution by creating a rendering algorithm and displaying that - instead of displaying the TIFF file. You might need Pro 2019 for this to work. The algorithm only contains the name of the TIFF file - so all properties get set to default. It is an XML file and looks like this -

    <!-- This is XML boiler plate and ought to be included in each file -->
    <?xml version="1.0" encoding="UTF-8"?>
    <!-- This is the root element and identifies a rendering algorithm -->
    <RenderAlgorithm>
    	<!-- I have listed a single raster specifying the full file name and path -->
    	<Raster File="geotiff_example.tif"/>
    </RenderAlgorithm>

    If you put the XML file in the same directory as the TIFF you won't need a full path for the TIFF, assuming you have the latest version. We usually give these files an ".MRD" extension, but you don't have to. Use the Open Table > Raster mechanism and browse to it. It will render and the white will be opaque.

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



  • 9.  RE: Unwanted transparency with 8 bit images

    Posted 02-13-2020 15:49
    Thanks Sam, yes that appears to work. I'll create an XML/MRD for each TIFF image.

    Thanks also to Anshul and Andrei for your assistance.

    Regards,

    Tim

    ------------------------------
    Timothy Mashford
    Melbourne, Australia
    ------------------------------



  • 10.  RE: Unwanted transparency with 8 bit images

    Employee
    Posted 02-13-2020 16:09
    If all your TIFF files are in the same directory then you can just create a single XML file and change the "File" tag in the XML to "*.tif".
    Then the algorithm will render them all at once.

    Another alternative is to list all the rasters you want to render like this -

    <?xml version="1.0" encoding="UTF-8"?>
    <RenderAlgorithm>
    	<Raster>
    		<File>e_05821632_12_15000_4bd_2018.jp2</File>
    		<File>e_05821636_12_15000_4bd_2018.jp2</File>
    		<File>e_05821638_12_15000_4bd_2018.jp2</File>
    	</Raster>
    </RenderAlgorithm>


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



  • 11.  RE: Unwanted transparency with 8 bit images

    Posted 02-13-2020 18:20
    Thanks Sam, one MRD file per image is fine, I see that the .TAB file points to this.

    One more question though, whilst I don't want pure white pixels to be transparent, I do sometimes want magenta pixels to be transparent.

    The option to do this under Adjust Image Styles does not seem to be applied when the TAB file is subsequently re-opened, I'm guessing because the rendering algorithm overrides this?

    So, can you let me know how I can set magenta pixels to be transparent in the rendering algorithm?

    Thanks,

    Tim

    ------------------------------
    Timothy Mashford
    Melbourne, Australia
    ------------------------------



  • 12.  RE: Unwanted transparency with 8 bit images

    Employee
    Posted 02-13-2020 19:03
    You will need to put more into the XML file.

    <?xml version="1.0" encoding="UTF-8"?>
    <RenderAlgorithm>
    	<Raster Name="Raster1" File="geotiff_example.tif"/>
    	<DataConditioning Name = "RemoveColors">
    		<Value>4294967295</Value>
    	</DataConditioning>
    	<Layer Type = "Image">
    		<Component Type = "Image" Enable = "TRUE">
    			<Raster Name = "Raster1" Field = "0" Band = "1"/>
    			<DataConditioning Name = "RemoveColors"/>
    		</Component>
    	</Layer>
    </RenderAlgorithm>

    Now you have to actually define the algorithm - so I have added an "Image" type layer and named the raster.

    To remove color pixels I have added a "DataConditioning" object. I have defined one "Value" which is white, but you can add multiple values if you want. The color is specified as a number so you have to convert RGBA to decimal. Note there is an alpha byte which is 255.

    RED + Green*256 + Blue*256*256 + 255*256*256*256

    Magenta is Blue and Red so it is 0xFFFF00FF which is 4294902015 decimal. Windows Calculator in programmer mode is your friend.
    White is 0xFFFFFFFF which is 4294967295.


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



  • 13.  RE: Unwanted transparency with 8 bit images

    Posted 02-16-2020 15:43
    Thanks Sam that worked. Hopefully all sorted now.


    ------------------------------
    Timothy Mashford
    Melbourne, Australia
    ------------------------------