weird pixels on the border of transparent areas

massimomassimo Global Mapper UserPosts: 31Trusted User
edited March 2010 in Raster Data
Hello.
I have some jp2000 files with some areas set to transparent within them (created with Global Mapper). When load one such jp2000 and try to export a subset of the image (png or jp2000 still with transparency) I have some weird pixel set to the background color just on the border of transparent areas.
These pixel are not visible on the original file. The problem get worse every other iteration of the process.
I'm attaching an example of the result.
Any idea of the reason for that?
Thanks and regards,
Massimo

Comments

  • massimomassimo Global Mapper User Posts: 31Trusted User
    edited March 2010
    I'm using version 11 (build March 2, 2010)....
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited March 2010
    How are you setting up the transparency? It looks like you are getting artifacts caused by the lossy nature of JPEG2000 files around the borders of your data. You would see those if you were setting transparency using a particular color or something.

    Also, can you try getting the latest build in case that helps? I have placed a new build at http://www.globalmapper.com/global_mapper11.zip with the latest changes for you to try. Simply download that file and extract the contents into your existing v11.xx installation folder to give it a try. If you are using the 64-bit version, there is a new build available at http://www.globalmapper.com/global_mapper11_64bit.zip .

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • massimomassimo Global Mapper User Posts: 31Trusted User
    edited March 2010
    I'm setting transparency using BG_TRANSPARENT="YES" and so getting transparent areas from the source files (jpeg2000). I will try the new build, what I do not understand is why these effects are not evident in the source file if they are related on the lossy nature of jpeg2000...
    Thanks and Regards,
    Massimo
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited March 2010
    Massimo,

    If you still have trouble with the new build, can you provide the original JPEG2000 file that you are exporting from so that I can take a look?

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • massimomassimo Global Mapper User Posts: 31Trusted User
    edited March 2010
    I still have problems, i'm attaching two files: one jp2000 used as source and the derived png that shows the strange pixel pattern. Thanks in advance,
    Massimo
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited March 2010
    Massimo,

    I just tried loading your JP2 file and exporting to both 8-bit and 24-bit PNG files and in both cases they came out fine with no artifacts (I've attached my results). Can you provide the script that you are using to export?

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • massimomassimo Global Mapper User Posts: 31Trusted User
    edited March 2010
    I think they only "appear" to be good, but if you change the background color you will see the artifacts.. at least it is what happen on my pc..
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited March 2010
    Ah sorry, you are right, I do see the problems when I change the background color.

    I delved into this and found the issue in the JP2 file. The fuzzy areas in the PNG file are all places where the original JP2 file had a very small, but non-zero, alpha value. The alpha value in the source JP2 file is very small (like 1, the minimum non-transparent value), but that is enough to make it a valid pixel vs. a completely transparent one. The PNG export from Global Mapper only stores either completely transparent (alpha = 0) or completely opaque (alpha = 255), so those very faint pixels are turned to full color pixels on export to PNG with a color nearly identical to the background color.

    Where did you get the JP2 file that you are loading?

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • massimomassimo Global Mapper User Posts: 31Trusted User
    edited March 2010
    Hello, thanks for your time.
    The jp2 I have uploaded yesterday was created with Global Mapper (made with the latest build just before uploading it). I loaded a geotiff without transparency and a shapefile to be used as a crop mask for the visible area when exporting the jp2 with transparency. Since the small values on the alpha channel are probably unavoidable on the jp2 file (given the lossy compression of the format) is there a way to save this small values of alpha channel also on the png format? As far as I know about png it should be able to store any percentage of partial transparency..

    Massimo
  • MattMatt Global Mapper User Posts: 176Trusted User
    edited March 2010
    Make sure you also have resampling set to nearest neighbor at every stage in the process. That might help a little. PNG format should avoid this issue since it's not lossy. But you might first have to load the PNG file with Photoshop, select the color range that you want to be transparent, then expand selection by one pixel and delete out the new selection.

    I don't think you'll find an easy answer to problem. It's inherent with using lossy image formats and transparency. If you find better solution, let me know.
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited March 2010
    Massimo,

    I had thought that the lossiness for JP2 files didn't apply to the alpha channel, but I guess I was wrong! I have updated the JP2/ECW reader in Global Mapper to treat any very small alpha values (i.e. smaller than 8) as completely transparent, which should then carry over to the PNG export. I have placed a new build at http://www.globalmapper.com/global_mapper11.zip with the change for you to try. Simply download that file and extract the contents into your existing v11.xx installation folder to give it a try. If you are using the 64-bit version, there is a new build available at http://www.globalmapper.com/global_mapper11_64bit.zip .

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • massimomassimo Global Mapper User Posts: 31Trusted User
    edited March 2010
    ok! it works.. I still have some incorrect pixels but now they are negligible..

    Thanks a lot!

    Massimo
Sign In or Register to comment.