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

  • 相关阅读:
    XXX is not in the sudoers file
    git错误“无法推送一些引用到xxx"的解决方法
    mysql开启远程访问
    ubuntu 在启动器中启动webstorm和phpstorm
    ubuntu nginx卸载和安装
    基于grunt构建的前端集成开发环境
    fullPage.js
    常见的HTTP状态码
    JS随机数
    CSS3简单的动画
  • 原文地址:https://www.cnblogs.com/flyingfish/p/729868.html
Copyright © 2011-2022 走看看