MapInfo Pro

Welcome to the MapInfo Pro community!  Please feel free to start a discussion in the discussion tab or join in a conversation.

Here are some useful links where you can find more information:

Product Announcements  Product Documentation  Ideas Portal

Discussions

Members

Resources

Events

 View Only

How to merge two images together, where one image requires transparency for the merge?

  • 1.  How to merge two images together, where one image requires transparency for the merge?

    Posted 11-27-2017 20:48

    Hello,

     

    I've got a few aerial images I want to merge together using MapInfo's raster merge function, the issue I've come across is that some of my images contain large areas of black which when I overlap the images create large patches where there is no imagery.

     

    I can remove the black using the raster style function but as I mentioned before whenever I try to merge them like this the black areas are present in the final result. Is there anyway to get around this issue?

     

    Please let me know if anyone needs more information about what I'm trying to achieve!

     

    Thanks,

    Michael



  • 2.  RE: How to merge two images together, where one image requires transparency for the merge?

    Employee
    Posted 11-27-2017 23:40

    Hi Michael,

    It does not seem to be an issue with the Merge function. The user could be running an older version of MapInfo Pro where the MapInfo Pro handler, leadtool.rhx, opens the file as all black. The image when opened in MS Paint and Windows Photo Viewer would also appear black.

    Could you please confirm what raster handler is opening the image and see if you can use a different handler.

    Regards,

    Shweta

     



  • 3.  RE: How to merge two images together, where one image requires transparency for the merge?

    Employee
    Posted 11-27-2017 23:41

    Also, in MapInfo Pro 16.0.2 and 17.0 (under development) the new MIRaster handler has considerably enhanced the Raster handling capability. In MapInfo Pro version 17.0 , we also have the alpha channel support added .

    MIRaster has also been adding support for additional raster formats.

    My recommendation is to upgrade to the latest x64 bit version of MapInfo Pro and use the new MIRaster functionality and it should work fine.



  • 4.  RE: How to merge two images together, where one image requires transparency for the merge?

    Employee
    Posted 11-27-2017 23:54

    Michael,

    Could you please share the data with us to get back with an exact reason for the issue coming up.

    Thanks,

    Shweta



  • 5.  RE: How to merge two images together, where one image requires transparency for the merge?

    Posted 11-28-2017 15:13

    Hi Shweta,

    Thank you very much for the replies, currently I'm using MapInfo version 16 (as part of the 2016 Discover bundle) and I agree that this doesn't seem like an issue with the merge tool itself. I'm not to sure what you mean by raster handler as I don't have too much experience with raster data. The images I'm using are also not fully black they are only black on an image where there is no aerial photography, but the black also shows up in paint, windows photo viewer and Photoshop.

    I've been looking at alpha bands and ways to make it transparent but as I mentioned earlier I'm really new to all of this so I didn't get very far...

    You'll understand when you see the images, I can send some through so you can better understand what I'm trying to achieve.

    Can you please let me know how you'd like to receive them? They're about 100 or so MB's.

     

    Cheers,

    Michael



  • 6.  RE: How to merge two images together, where one image requires transparency for the merge?

    Employee
    Posted 11-29-2017 03:40

    Hi Michael,

    Shared the location with you, sent an email. Let me know if you are not able to share.

    Regards,

    Shweta



  • 7.  RE: How to merge two images together, where one image requires transparency for the merge?

    Posted 11-29-2017 18:58

    Hi Shweta,

     

    Thanks for sending that shared link through, unfortunately I won't have access to the images to upload as some things are being moved around. I will share those files with you on Monday.

     

    Kind Regards,

    Michael



  • 8.  RE: How to merge two images together, where one image requires transparency for the merge?

    Posted 12-07-2017 16:19

    I would be interested in seeing that data, if you can upload it (or some of it).



  • 9.  RE: How to merge two images together, where one image requires transparency for the merge?

    Posted 12-07-2017 16:23

    I'm really sorry I haven't got around to uploading the files yet, I was sidetracked by other work. I will let you know once I've uploaded the data!



  • 10.  RE: How to merge two images together, where one image requires transparency for the merge?

    Posted 01-10-2018 21:19

    Hi Michael,

    Thanks for supplying the source data. I downloaded it before Xmas but holidays intervened.

    You supplied 98 geolocated JPEG RGB images. Two are low resolution images and the other 96 are 4x higher resolution. Of these 98 images, 21 contain a black border region of varying size and position. You want to merge these images into a single raster that preserves the high resolution data (overwriting the low) and that does not include the black border regions.

    We do not currently support located JPEG images in Pro Advanced. They get loaded by MapInfo, not the raster engine. However, we do have a driver that supports PNG and JPG but it is currently not shipped. I hope it will ship in the v17 release. To process this data I activated this driver and upgraded it to support ESRI world registration files.

    With this driver I was then able to batch convert all the JPG images to MRR. I used the PNG compression codec in the MRR to prevent any further information loss.

    Before you can merge the images, you have to remove the black regions. I can do this with a flood-fill edit operation. I manually pick a seed pixel to initiate a flood fill which changes all the adjacent black pixels to invalid cells. This works, but only to a point. Lossy compression codecs like JPEG blur the boundary between the black cells and the valid imagery. JPEG is better than ECW in this regard because it only blurs the boundary out to the JPEG block size, whereas ECW injects noise into the entire image which makes it even harder to identify the invalid pixels.

    To resolve this issue I introduced some color space tolerance into the flood fill operation. This removes all the black. The tolerance has to be quite large, so it tends to eat out some real image pixels in some cases. But it is hard to imagine how you can get a perfect result for data like this.

    I executed this operation manually on the 21 affected images. This processing operation is not available to users at the current time.

    Then I executed a merge operation using the simple union and stamp options. I chose one of the high resolution rasters as the key raster (to define cell size etc). The two low resolution rasters need to be listed first, then all the high resolution rasters. If I use the PNG codec (preferred, as it does not introduce any more noise), the MRR is 3.2 GB. Using JPEG it is 809 MB. I can upload this smaller raster to the cloud so I will send you a link via email.

    One clear take away from this exercise is - get your imagery delivered in a lossless compression format like PNG or TIFF. If you want to process images that use a lossy codec, you end up introducing more and more noise.

    So in summary - I have managed to process this data and produce a high quality result, but I had to use (and upgrade) tools that are not currently available to Pro Advanced users. But thanks for sharing because it was a valuable exercise and I think it will be a common experience for users. I will post some pictures below.



  • 11.  RE: How to merge two images together, where one image requires transparency for the merge?

    Posted 01-10-2018 21:27

    Here is one of the files showing the black region.

    Critchlow_Example_WithBlack

    Here is the same file with the black removed.

    Critchlow_Example_WithBlackRemoved

    Here is a portion of the final merged image showing low resolution data to the north and high resolution data to the south.

    Critchlow_Example_HigOnLowResData



  • 12.  RE: How to merge two images together, where one image requires transparency for the merge?

    Posted 01-10-2018 21:44

    Hi Sam,

    Thank you very much for looking into this for me! Those results are exactly what I was trying to achieve. Although this method isn't currently available for me to replicate it's really great to see that it can be done with the images I have.

    Once again I really appreciate the help!



  • 13.  RE: How to merge two images together, where one image requires transparency for the merge?

    Employee
    Posted 01-10-2018 23:05

    Sam, you have explained it in such details and made it so clearly understandable. Thank you so much!