MapInfo Pro

 View Only
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   4 KB 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

    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

    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

    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
    ------------------------------



  • 14.  RE: Unwanted transparency with 8 bit images

    Posted 02-21-2022 08:57
      |   view attached

    Hi Andrei.

    I got a request from one of our customers related to this.

    Based on the settings you mentioned, raster will be displayed is correctly when using MIPro.

    But they also have a plenty of MapInfo Runtime in use.

    So: how to apply the settings in MI RT?

    Did attach a PDF which illustrates the issue.

    Best regards

    Oliver (AGIS GmbH)



    ------------------------------
    Oliver Best
    AGIS Anwender-Geo-Informations-Systeme GmbH
    Bad Homburg
    ------------------------------

    Attachment(s)



  • 15.  RE: Unwanted transparency with 8 bit images

    Employee
    Posted 02-22-2022 12:21
    Edited by Anshul Goel 02-22-2022 12:24
    Hello Oliver,

    The same can be achieved in MapInfo Runtime by following below steps:

    1. Navigate to MIRasterPreferences.xml file. This can be found at %appdata%\MapInfo\RasterRT\500 location (If using Runtime 2019).
    MIRasterPreferences.xml file location

    2. Open the MIRasterPreferences.xml file in a text editor and make changes based on the screenshot provided.

    Once done save the changes and relaunch MapInfo Runtime. This should do the trick.

    Hope it helps.

    Thanks
    Anshul

    ------------------------------
    Anshul Goel
    Pitney Bowes Software Inc.
    Shelton CT
    ------------------------------



  • 16.  RE: Unwanted transparency with 8 bit images

    Posted 02-23-2022 02:12

    Good Morning Anshul.
    Thanks a lot for picking up this issue.

    Luckily you could provide me/our customer with a workaround.

    It's not the very best solution, because the IT-Team has to distribute this file to bunch of machines - but will be possible.

    Problem is that we expect a lot of requests from our customers related to this.
    Based on MIPro 32-Bit we rarley have had trouble with the display of raster files.
    This changed with MIPro 64-Bit. Since we have increasing feedback that raster data are not displayed correctly (especially using *tif). Often we have to change the settings in the corresponding dialog of MapInfo Pro Raster. But a fourth/third of our customers do use MIRT.

    Anyway .. ... thanks again for providing us with a quick solution.

    Oliver



    ------------------------------
    Oliver Best
    AGIS Anwender-Geo-Informations-Systeme GmbH
    Bad Homburg
    ------------------------------



  • 17.  RE: Unwanted transparency with 8 bit images

    Employee
    Posted 02-23-2022 20:22
    Hi Oliver,

    In the upcoming 2021.1 update we will be addressing transparency related issues in raster rendering. It will be improved for both MapInfo and Runtime. Our current plans is to release 2021.1 update (with all supported languages) around end of March.

    Regards,
    Andrei

    ------------------------------
    Andrei Veselov
    Precisely
    Troy NY
    ------------------------------