• 仿射变换矩阵


    图像的几何变换分为三类:刚性变换、仿射变换和透视变换。

    尺度变换,比例缩放变换

    [ x ′ y ′ 1 ] = [ f x 0 0 0 f y 0 0 0 1 ] [ x y 1 ]

    [xy1]" role="presentation">[xy1]
    =
    [fx000fy0001]" role="presentation" style="position: relative;">[fx000fy0001]
    [xy1]" role="presentation" style="position: relative;">[xy1]
    xy1 = fx000fy0001 xy1

    [ x ′ y ′ 1 ] = [ x y 1 ] [ f x 0 0 0 f y 0 0 0 1 ]

    [xy1]" role="presentation" style="position: relative;">[xy1]
    =
    [xy1]" role="presentation" style="position: relative;">[xy1]
    [fx000fy0001]" role="presentation" style="position: relative;">[fx000fy0001]
    [xy1]=[xy1] fx000fy0001

    x ′ = f x x x' = f_x x x=fxx
    y ′ = f y y y' = f_y y y=fyy

    平移变换

    [ x ′ y ′ 1 ] = [ 1 0 Δ x 0 1 Δ y 0 0 1 ] [ x y 1 ]

    [xy1]" role="presentation" style="position: relative;">[xy1]
    =
    [10Δx01Δy001]" role="presentation" style="position: relative;">[10Δx01Δy001]
    [xy1]" role="presentation" style="position: relative;">[xy1]
    xy1 = 100010ΔxΔy1 xy1

    [ x ′ y ′ 1 ] = [ x y 1 ] [ 1 0 0 0 1 0 Δ x Δ y 1 ]

    [xy1]" role="presentation" style="position: relative;">[xy1]
    =
    [xy1]" role="presentation" style="position: relative;">[xy1]
    [100010ΔxΔy1]" role="presentation" style="position: relative;">[100010ΔxΔy1]
    [xy1]=[xy1] 10Δx01Δy001

    x ′ = x + Δ x x' = x + \Delta x x=x+Δx
    y ′ = y + Δ y y' = y + \Delta y y=y+Δy

    镜像变换

    图像宽 w w w,高 h h h
    左上角为原点,向下为 x x x轴,向右为 y y y

    水平镜像变换

    [ x ′ y ′ 1 ] = [ − 1 0 w 0 1 0 0 0 1 ] [ x y 1 ]

    [xy1]" role="presentation" style="position: relative;">[xy1]
    =
    [10w010001]" role="presentation" style="position: relative;">[10w010001]
    [xy1]" role="presentation" style="position: relative;">[xy1]
    xy1 = 100010w01 xy1

    [ x ′ y ′ 1 ] = [ x y 1 ] [ − 1 0 0 0 1 0 w 0 1 ]

    [xy1]" role="presentation" style="position: relative;">[xy1]
    =
    [xy1]" role="presentation" style="position: relative;">[xy1]
    [100010w01]" role="presentation" style="position: relative;">[100010w01]
    [xy1]=[xy1] 10w010001

    水平镜像变换:先绕 y y y轴翻转,再沿 x x x轴移动
    [ − 1 0 w 0 1 0 0 0 1 ] = [ 1 0 w 0 1 0 0 0 1 ] [ − 1 0 0 0 1 0 0 0 1 ]

    [10w010001]" role="presentation" style="position: relative;">[10w010001]
    =
    [10w010001]" role="presentation" style="position: relative;">[10w010001]
    [100010001]" role="presentation" style="position: relative;">[100010001]
    100010w01 = 100010w01 100010001

    [ − 1 0 0 0 1 0 w 0 1 ] = [ − 1 0 0 0 1 0 0 0 1 ] [ 1 0 0 0 1 0 w 0 1 ]

    [100010w01]" role="presentation" style="position: relative;">[100010w01]
    =
    [100010001]" role="presentation" style="position: relative;">[100010001]
    [100010w01]" role="presentation" style="position: relative;">[100010w01]
    10w010001 = 100010001 10w010001

    x ′ = w − x x' = w - x x=wx
    y ′ = y y' = y y=y

    垂直镜像变换

    [ x ′ y ′ 1 ] = [ 1 0 0 0 − 1 h 0 0 1 ] [ x y 1 ]

    [xy1]" role="presentation" style="position: relative;">[xy1]
    =
    [10001h001]" role="presentation" style="position: relative;">[10001h001]
    [xy1]" role="presentation" style="position: relative;">[xy1]
    xy1 = 1000100h1 xy1

    [ x ′ y ′ 1 ] = [ x y 1 ] [ 1 0 0 0 − 1 0 0 h 1 ]

    [xy1]" role="presentation" style="position: relative;">[xy1]
    =
    [xy1]" role="presentation" style="position: relative;">[xy1]
    [1000100h1]" role="presentation" style="position: relative;">[1000100h1]
    [xy1]=[xy1] 10001h001

    垂直镜像变换:先绕 x x x轴翻转,再沿 y y y轴移动
    [ 1 0 0 0 − 1 h 0 0 1 ] = [ 1 0 0 0 1 h 0 0 1 ] [ 1 0 0 0 − 1 0 0 0 1 ]

    [10001h001]" role="presentation" style="position: relative;">[10001h001]
    =
    [10001h001]" role="presentation" style="position: relative;">[10001h001]
    [100010001]" role="presentation" style="position: relative;">[100010001]
    1000100h1 = 1000100h1 100010001

    [ 1 0 0 0 − 1 0 0 h 1 ] = [ 1 0 0 0 − 1 0 0 0 1 ] [ 1 0 0 0 1 0 0 h 1 ]

    [1000100h1]" role="presentation" style="position: relative;">[1000100h1]
    =
    [100010001]" role="presentation" style="position: relative;">[100010001]
    [1000100h1]" role="presentation" style="position: relative;">[1000100h1]
    10001h001 = 100010001 10001h001

    x ′ = x x' = x x=x
    y ′ = h − y y' = h - y y=hy

    注:线性代数 x A B = x ( A B ) xAB = x(AB) xAB=x(AB)

    恒等变换

    [ x ′ y ′ 1 ] = [ 1 0 0 0 1 0 0 0 1 ] [ x y 1 ]

    [xy1]" role="presentation" style="position: relative;">[xy1]
    =
    [100010001]" role="presentation" style="position: relative;">[100010001]
    [xy1]" role="presentation" style="position: relative;">[xy1]
    xy1 = 100010001 xy1

    [ x ′ y ′ 1 ] = [ x y 1 ] [ 1 0 0 0 1 0 0 0 1 ]

    [xy1]" role="presentation" style="position: relative;">[xy1]
    =
    [xy1]" role="presentation" style="position: relative;">[xy1]
    [100010001]" role="presentation" style="position: relative;">[100010001]
    [xy1]=[xy1] 100010001

    x ′ = x x' = x x=x
    y ′ = y y' = y y=y

    旋转变换

    绕原点逆时针旋转

    [ x ′ y ′ 1 ] = [ x y 1 ] [ c o s θ s i n θ 0 − s i n θ c o s θ 0 0 0 1 ]

    [xy1]" role="presentation" style="position: relative;">[xy1]
    =
    [xy1]" role="presentation" style="position: relative;">[xy1]
    [cosθsinθ0sinθcosθ0001]" role="presentation" style="position: relative;">[cosθsinθ0sinθcosθ0001]
    [xy1]=[xy1] cosθsinθ0sinθcosθ0001

    [ x ′ y ′ 1 ] = [ c o s θ − s i n θ 0 s i n θ c o s θ 0 0 0 1 ] [ x y 1 ]

    [xy1]" role="presentation" style="position: relative;">[xy1]
    =
    [cosθsinθ0sinθcosθ0001]" role="presentation" style="position: relative;">[cosθsinθ0sinθcosθ0001]
    [xy1]" role="presentation" style="position: relative;">[xy1]
    xy1 = cosθsinθ0sinθcosθ0001 xy1

    x ′ = c o s θ x − s i n θ y x' = cos \theta x - sin \theta y x=cosθxsinθy
    y ′ = s i n θ x + c o s θ y y' = sin \theta x + cos \theta y y=sinθx+cosθy

    绕原点顺时针旋转

    [ x ′ y ′ 1 ] = [ x y 1 ] [ c o s θ − s i n θ 0 s i n θ c o s θ 0 0 0 1 ]

    [xy1]" role="presentation" style="position: relative;">[xy1]
    =
    [xy1]" role="presentation" style="position: relative;">[xy1]
    [cosθsinθ0sinθcosθ0001]" role="presentation" style="position: relative;">[cosθsinθ0sinθcosθ0001]
    [xy1]=[xy1] cosθsinθ0sinθcosθ0001

    [ x ′ y ′ 1 ] = [ c o s θ s i n θ 0 − s i n θ c o s θ 0 0 0 1 ] [ x y 1 ]

    [xy1]" role="presentation" style="position: relative;">[xy1]
    =
    [cosθsinθ0sinθcosθ0001]" role="presentation" style="position: relative;">[cosθsinθ0sinθcosθ0001]
    [xy1]" role="presentation" style="position: relative;">[xy1]
    xy1 = cosθsinθ0sinθcosθ0001 xy1

    x ′ = c o s θ x + s i n θ y x' = cos \theta x + sin \theta y x=cosθx+sinθy
    y ′ = − s i n θ x + c o s θ y y' = -sin \theta x + cos \theta y y=sinθx+cosθy

    绕任意点旋转

    先将该点平移到原点,再绕原点进行旋转,最后将该点平移回去。

    错切变换,偏移变换

    水平错切变换

    [ x ′ y ′ 1 ] = [ 1 0 0 s h 1 0 0 0 1 ] [ x y 1 ]

    [xy1]" role="presentation" style="position: relative;">[xy1]
    =
    [100sh10001]" role="presentation" style="position: relative;">[100sh10001]
    [xy1]" role="presentation" style="position: relative;">[xy1]
    xy1 = 1sh0010001 xy1

    [ x ′ y ′ 1 ] = [ x y 1 ] [ 1 s h 0 0 1 0 0 0 1 ]

    [xy1]" role="presentation" style="position: relative;">[xy1]
    =
    [xy1]" role="presentation" style="position: relative;">[xy1]
    [1sh0010001]" role="presentation" style="position: relative;">[1sh0010001]
    [xy1]=[xy1] 100sh10001

    x ′ = x x' = x x=x
    y ′ = s h x + y y' = s_h x + y y=shx+y

    垂直错切变换

    [ x ′ y ′ 1 ] = [ 1 s v 0 0 1 0 0 0 1 ] [ x y 1 ]

    [xy1]" role="presentation" style="position: relative;">[xy1]
    =
    [1sv0010001]" role="presentation" style="position: relative;">[1sv0010001]
    [xy1]" role="presentation" style="position: relative;">[xy1]
    xy1 = 100sv10001 xy1

    [ x ′ y ′ 1 ] = [ x y 1 ] [ 1 0 0 s v 1 0 0 0 1 ]

    [xy1]" role="presentation" style="position: relative;">[xy1]
    =
    [xy1]" role="presentation" style="position: relative;">[xy1]
    [100sv10001]" role="presentation" style="position: relative;">[100sv10001]
    [xy1]=[xy1] 1sv0010001

    x ′ = x + s v y x' = x + s_v y x=x+svy
    y ′ = y y' = y y=y

  • 相关阅读:
    【一文秒懂——SLF4j日志】
    vue中使用base64编码上传文件或者图片,以及base64编码的图片在img标签中使用
    AI产品经理还不会数据挖掘❓看完这篇就够了
    2022速卖通官方披露;婚纱服饰品类策略及机会品类推荐
    JeecgBoot 3.4.3-GA 版本发布,开源免费的企业级低代码平台
    [ubuntu]ubuntu设置虚拟内存
    pandas处理两表合并
    【计算机网络】详解TCP协议(下) 滑动窗口 | 流量控制 | 拥塞控制
    Three.js加载360全景图片/视频
    【校招VIP】前端算法考察之字符串
  • 原文地址:https://blog.csdn.net/qq_37083038/article/details/126899308