Global Mapper v25.0

Bicubic resampling

tjhb
tjhb Global Mapper UserTrusted User
edited March 2010 in Bug Report
From Twitter announcement we learned that bicubic interpolation has now been enabled as an option (build dated 24 February). This is very welcome news.

The setting is in a good place, on the Display tab of the Options sheet for a raster layer. The former option "Anti-alias pixels (interpolate)" is replaced by a drop-down box with three options: nearest neighbour, bilinear, bicubic. As I read it, nearest neighbour is equivalent to the previous "off" setting, bilinear is equivalent to the previous "on" setting, and bicubic is new. So far so good.

However, I'm getting corruption of both display and resampled exports on every image raster I've tried so far. Horizontal interpolation seems to be out of sync from row to row. (I've attached an example.) I don't know whether the problem is also occurring with DEM rasters (I haven't tested well enough yet).

Comments

  • tjhb
    tjhb Global Mapper User Trusted User
    edited February 2010
    For DEMs (with shading enabled) a different sort of corruption: with the bicubic method, no shading or visible contrast on zooming in, but a featureless black or grey. Corrected by selecting biliear instead.
  • tjhb
    tjhb Global Mapper User Trusted User
    edited February 2010
    Resampling a DEM up with bicubic enabled seems to produce a flat DEM with 0 elevation (on the basis of one trial only).

    Is anyone getting good results with bicubic yet?
  • global_mapper
    global_mapper Administrator
    edited February 2010
    The Twitter post was premature as the bicubic support is not complete in an official build. It doesn't work at all for elevation files and still has some issues for imagery. Hopefully it will be completed in a couple of days in a new build.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • tjhb
    tjhb Global Mapper User Trusted User
    edited February 2010
    OK thanks Mike. Now I'm excited again.
  • tjhb
    tjhb Global Mapper User Trusted User
    edited February 2010
    And to repeat myself, I like what you've done for the user interface.
  • global_mapper
    global_mapper Administrator
    edited February 2010
    I've got the bicubic resampling working for non-elevation files. 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 v11 version there is a new build at http://www.globalmapper.com/global_mapper11_64bit.zip .

    Hopefully I can get it working for elevation layers in a day or two.
    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • global_mapper
    global_mapper Administrator
    edited February 2010
    The bicubic resampling should now work for elevation layers as well. 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
  • tjhb
    tjhb Global Mapper User Trusted User
    edited February 2010
    You've been very generous with your weekend Mike. I'm very excited to test this. I'll post back some examples of the difference it makes.

    (Bicubic sampling up for images was already fabulous with the previous build.)
  • tjhb
    tjhb Global Mapper User Trusted User
    edited March 2010
    Not much difference to notice yet, I think, for sampling down (subsampling). Maybe this is more difficult than just introducing bicubic interpolation. Or perhaps it's just that the radius or decay factor for the interpolation function (if that makes any sense) can be tweaked to a degree.

    I've zipped up a Global Mapper project ready to send. (I didn't use a package file as it would introduce lossy compression. It's important to show the original in this case.)

    Can I send the zip file to you Mike? It's about 155 MB, close to the stated limit for zip attachments. My first attemtp to attach it failed after a few minutes.

    These project contains 4 layers:
    • "10mpx original" is one of our cartographic textures at it original resolution of 10 metres per pixel.
    • "40mpx GM bilinear" is the original texture, resampled in Global Mapper to 40 metres per pixel with bilinear resampling set.
    • "40mpx GM bicubic" is the same, resampled in Global Mapper to 40 metres per pixel, this time with bicubic resampling set.
    • "40mpx PhS bicubic" is the original texture, resampled in Photoshop CS4 to 40 metres per pixel using the bicubic resampling method.

    The GM methods do not do well at preserving the continuity of local detail, which ends up excessively pixellated. This is most noticeable for small linear features such as streams or hedgerows. (Bilinear and bicubic produce very similar results; bicubic introduces slightly greater contrast between adjacent pixels.)

    The Photoshop method does much better. The continuity of local detail is visibly preserved despite subsampling.

    I wonder how close Global Mapper can get, in principle, to the quality the Photoshop engineers have achieved.
  • global_mapper
    global_mapper Administrator
    edited March 2010
    For a sample that large you would need to FTP the data to ftp.globalmapper.com using a username of 'upload' and a password of 'upload'.

    The bicubic resampling method is very well defined in terms of how to compute the color at a given location given the surrounding 16 samples/pixels, so I don't think that Photoshop is using bicubic if they are getting significantly better results. For significant sub-sampling vs. just resampling at a similar resolution there are much better algorithms than bicubic, namely boxing algorithms that consider larger numbers of pixels or just average out the values within a box rather than doing a weighted average heavily skewed towards the value at the actual sample location. Those are things we may be able to easily add now that an interface is in place for using multiple sampling methods.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • tjhb
    tjhb Global Mapper User Trusted User
    edited March 2010
    For all I know Photoshop's implementation of "bicubic" does have something extra added to it. They're such a centre of gravity that they might feel they can use whatever names they like.

    For what it's worth, the available resampling methods in Photoshop CS4 are listed as follows (with their usage hints):
    • Nearest Neighbour (preserve hard edges)
    • Bilinear
    • Bicubic (best for smooth gradients)
    • Bicubic Smoother (best for enlargement)
    • Bicubic Sharper (best for reduction)

    (In this case I used the method listed as plain bicubic.)

    I've uploaded the file Resampling.zip to your ftp site and I hope you can take a look.

    You'll immediately see what we mean about the difference in quality, and why we have hesitated to use Global Mapper for resampling down.

    Your point about the new architecture opening further possibilities seems really encouraging. Thanks.
  • global_mapper
    global_mapper Administrator
    edited March 2010
    I went ahead and added 3 new resampling methods, all box average resampling with sample sizes of 3x3, 4x4, and 5x5. These are better when downsampling than the base bicubic resampling method. I tried the 4x4 (i.e. average of 16 closest pixels) on your data and got results very close to what Photoshop was producing for you. The more you are downsampling the larger average you should use. For going 10m to 40m, the 4x4 size would be the best fit.

    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
  • global_mapper
    global_mapper Administrator
    edited March 2010
    I went ahead and added 3 new resampling methods, all box average resampling with sample sizes of 3x3, 4x4, and 5x5. These are better when downsampling than the base bicubic resampling method. I tried the 4x4 (i.e. average of 16 closest pixels) on your data and got results very close to what Photoshop was producing for you. The more you are downsampling the larger average you should use. For going 10m to 40m, the 4x4 size would be the best fit.

    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
  • tjhb
    tjhb Global Mapper User Trusted User
    edited March 2010
    Mike what can we do to thank you? You were dead right in your earlier comments, and now you've made a superior resampling tool. This is fantastic. Thank you.

    I agree that, on this data and for this subsampling ratio, a 4×4 box average is about ideal. The result is marginally better than by using Photoshop's "bicubic". For what it's worth, I agree that subsampling in Photoshop must being do something quite different from the "bicubic" resampliing it claims.

    Nailed. Thank you again Mike.

    A new level of usefulness.
  • global_mapper
    global_mapper Administrator
    edited March 2010
    Regarding bicubic and Photoshop, I think Photoshop is using the base bicubic resampling, then applying an additional filter. There seem to be a lot of different enhancements to bicubic with different filters that are used for different purposes. In my opinion, the bicubic resampling is better when upsampling or just slightly downsampling, and the box averagers are better when downsampling significantly.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com