zoukankan      html  css  js  c++  java
  • 用GDAL对影像重采样的一些要点

    1、RasterIO只能使用最临近插值法

    做影像金字塔时,开始用的GDALDataSet的RasterIO通过控制行列宽度来抽层,代码写起来很简洁,奇怪一直没见设置重采样参数的地方,急于实现功能,没有怎么深究,基本功能全都做好后发现分层质量很差。文档里边没找到资料介绍这些,查了很久在Maillist上发现RasterIO() level resampling should all be "nearest neighbour", and so

    not introduce any new values.看来不换方法是不行了。

    参考资源:http://lists.maptools.org/pipermail/gdal-dev/2005-May/005646.html

    On 5/4/05, Sheykhet, Rostic <rsheykhet at sanz.com> wrote:

    > Hello,

    >

    > I am trying to perform RasterIO on a band that references a color

    table.

    > When the source and destination image dimensions are different, I get

    > back a band that has indexes into blank/invalid color table entries.

    > I assume this is because of the decimation procedure. Is there a way

    > to modify this behavior?

    Rostic,

    RasterIO() level resampling should all be "nearest neighbour", and so

    not introduce any new values. Is it possible you have built overviews

    on the file in question with averaging? Perhaps the format is a lossy

    compression format?

    Best regards,

    --

    ---------------------------------------+--------------------------------

    ---------------------------------------+------

    I set the clouds in motion - turn up | Frank Warmerdam,

    warmerdam at pobox.com

    light and sound - activate the windows | http://pobox.com/~warmerdam

    and watch the world go round - Rush | Geospatial Programmer for Rent

    2、 GDALWarp的四种采样方式

    Warp Resampling Algorithm

    Enumerator:

    GRA_NearestNeighbour 

    Nearest neighbour (select on one input pixel)

    GRA_Bilinear 

    Bilinear (2x2 kernel)

    GRA_Cubic 

    Cubic Convolution Approximation (4x4 kernel)

    GRA_CubicSpline 

    Cubic B-Spline Approximation (4x4 kernel)

    GDALWarpOpations::eResampleAlg

    One of GRA_NearestNeighbour (the default, and fastest), GRA_Bilinear (2x2 bilinear resampling) or GRA_Cubic. The GRA_NearestNeighbour type should generally be used for thematic or colormapped images. The other resampling types may give better results for thematic images, especially when substantially changing resolution.

    3、用GDAL Utility实现高质量重采样

    ===============================================================
    NiceResample.cmd
    ===============================================================
    @echo off
    echo.
    echo.   %~n0: resample an image nicely, slow but with good results
    echo.
    if [%2]==[] goto :Usage
    if not exist "%1" goto :NoFile
    rem if exist "%2" goto :OutExists
    set inFile=%1
    set outFile=%2

    :: enables variable expansion inside FOR loop (!x! syntax)
    :: requires Windows 2000 or newer
    setlocal enabledelayedexpansion

    :Main
            set tmpFile=%infile%
            :: resample from 900x900 pixels down to 128x128
            :: in 100px stages.
            for %%a in (900 800 700 600 500 400 300 200 128) do (
                    gdalwarp -q -ts %%a %%a !tmpFile! xx_%%a_%inFile%
                    set tmpFile=xx_%%a_%inFile%
                    )
            :: "&& del" only deletes if previous command successful
            gdal_translate !tmpFile! %outFile% && del xx_*_%inFile%
            echo.
            echo   Finished writing 128x128px %outFile%
            goto :EOF

    :NoFile
            echo *** Error: input %1 not found
            goto :EOF

    :Usage
            echo. Usage: %~n0 [input image] [output image]
            echo.
            echo   output overwritten if it exists
            goto :EOF
    ===============================================================

    参考:Resampling With GDAL库

    http://www.nabble.com/Resampling-With-GDAL-t3611789.html

    4、使用调色板的影像只能使用nearest neighbour采样方式。

    For indexed images change the resampling to nearest neighbour (-rn)
    rather than bilinear, cubic or cubic spline (-rb, -rc, -rcs):

    参考:http://www.nabble.com/Resampling-With-GDAL-t3611789.html

  • 相关阅读:
    (OK) VirtualBox 5.0.10 中 Fedora 23 在安装了增强工具后无法自动调节虚拟机分辨率的问题
    (OK) install-fedora23—gnome classic—dnf—gdm—multi-user—graphical
    (OK) fedora23——add “opening terminal” in the menu of right click
    (OK) Install Docker on Fedora 23
    (OK) 运行cBPM in Fedora23
    错误:‘bOS::SQL::SQLCommand::SQLOperation’既不是类也不是命名空间
    My enum is not a class or namespace
    【t049】&&【u001】足球
    【u002】数列排序(seqsort)
    【u003】计算概率
  • 原文地址:https://www.cnblogs.com/flyingfish/p/729868.html
Copyright © 2011-2022 走看看