当前位置: 首页 > news >正文

企业网站开发报价单营销型网站建设运营

企业网站开发报价单,营销型网站建设运营,济南网站建设培训学校,重庆一家和兴装饰设计有限公司奇异值分解在图形压缩中的应用 在研究奇异值分解的工程应用之前,我们得明白什么是奇异值?什么是奇异向量? 奇异值与奇异向量 概念:奇异值描述了矩阵在一组特定向量上的行为,奇异向量描述了其最大的作用方向。 奇异值…

奇异值分解在图形压缩中的应用


在研究奇异值分解的工程应用之前,我们得明白什么是奇异值?什么是奇异向量?

奇异值与奇异向量

概念:奇异值描述了矩阵在一组特定向量上的行为,奇异向量描述了其最大的作用方向。

奇异值分解(SVD)

矩阵A的分解涉及一个 m × n m \times n m×n的矩阵 Σ \Sigma Σ,其中 Σ \Sigma Σ= [ D 0 0 0 ] \begin{bmatrix} D &0\\0&0\end{bmatrix} [D000],D是一个 r × r r\times r r×r的方阵 ( r ≤ m , r ≤ n ) ( r \leq m , r\leq n) (rm,rn)

定理:设A是秩为 r r r m × n m\times n m×n的矩阵,那么存在一个类似于 Σ \Sigma Σ的矩阵,其中 D D D的对角线元素是 A A A的前 r r r个奇异值, σ 1 ≥ σ 2 ≥ σ 3 ≥ . . . ≥ σ r > 0 \sigma_1 \geq\sigma_2 \geq\sigma_3 \geq... \geq\sigma_r>0 σ1σ2σ3...σr>0并且存在一个 m × m m\times m m×m的正交矩阵 U U U 和一个 n × n n\times n n×n的正交矩阵 V T V^T VT使得 A = U Σ V T A=U\Sigma V^T A=UΣVT

奇异值分解计算过程

我们先假设一个矩阵 A = [ 2 3 0 2 ] A = \begin{bmatrix} 2 & 3 \\ \ 0 & 2\end{bmatrix} A=[2 032]
U = [ u 1 u 2 u 3 . . . ] U=[u_1 u_2 u_3 ...] U=[u1u2u3...] , ∑ = d i a g [ σ 1 σ 2 σ 3 . . . ] \sum = diag[\sigma_1 \sigma_2 \sigma_3 ...] =diag[σ1σ2σ3...] , V = [ v 1 v 2 v 3 . . . ] T V=\begin{bmatrix} v_1 \\ v_2\\ v_3 \\ ...\end{bmatrix}^T V= v1v2v3... T
其中 U U U代表A的正交矩阵; ∑ \sum 代表A的由奇异值组成的左奇异向量矩阵; V V V代表A的右奇异向量矩阵。

求A的 U , ∑ , V U , \sum , V U,,V.

  1. 计算 A T A A^TA ATA
    A T A = [ 2 0 3 2 ] [ 2 3 0 2 ] = [ 13 6 6 4 ] A^TA =\begin{bmatrix} 2&0\\3&2 \end{bmatrix} \begin{bmatrix} 2&3\\0&2\end{bmatrix}= \begin{bmatrix} 13&6\\6&4 \end{bmatrix} ATA=[2302][2032]=[13664]
  2. 计算 A T A A^TA ATA的奇异值 σ \sigma σ
    σ 1 2 σ 2 2 = d e t A T A = 16 σ 1 2 + σ 2 2 = t r A T A = 17 ∴ σ 1 2 = 16 , σ 2 2 = 1 ∴ σ 1 = 4 , σ 2 = 1 ∴ Σ = [ 4 0 0 1 ] \sigma_1^2\sigma_2^2 = det A^TA = 16 \\ \sigma_1^2 + \sigma_2^2 = tr A^TA = 17 \\ \therefore \sigma_1^2 =16, \sigma_2^2= 1\\ \therefore \sigma_1 =4, \sigma_2= 1\\ \therefore \Sigma=\begin{bmatrix} 4&0\\0&1 \end{bmatrix} σ12σ22=detATA=16σ12+σ22=trATA=17σ12=16,σ22=1σ1=4,σ2=1Σ=[4001]
  3. σ 1 , σ 2 \sigma_1,\sigma_2 σ1,σ2带入 A T A A^TA ATA中求其特征向量
    v 1 = [ 1 5 2 5 ] , v 2 = [ − 2 5 1 5 ] ∴ V = [ 1 5 − 2 5 2 5 1 5 ] \\ v_1= \begin{bmatrix} \frac{1}{\sqrt5} \\\\ \frac{2}{\sqrt5} \end{bmatrix} , v_2= \begin{bmatrix} -\frac{2}{\sqrt5}\\\\\frac{1}{\sqrt5} \end{bmatrix} \\\therefore V= \begin{bmatrix} \frac{1}{\sqrt5}&-\frac{2}{\sqrt5} \\\\ \frac{2}{\sqrt5}&\frac{1}{\sqrt5}\end{bmatrix} v1= 5 15 2 ,v2= 5 25 1 V= 5 15 25 25 1
  4. 构造标准正交向量
    u i = 1 σ i A v i ∴ u 1 = 1 σ 1 A v 1 = 1 4 [ 2 3 0 2 ] [ 1 5 2 5 ] = [ 2 5 1 5 ] ∴ u 2 = 1 σ 2 A v 2 = 1 1 [ 2 3 0 2 ] [ − 2 5 1 5 ] = [ − 1 5 2 5 ] ∴ U = ( u 1 , u 2 ) = [ 2 5 − 1 5 1 5 2 5 ] u_i=\frac{1}{\sigma_i}Av_i \\ \therefore u_1=\frac{1}{\sigma_1}Av_1=\frac{1}{4}\begin{bmatrix} 2&3\\\\0&2\end {bmatrix} \begin{bmatrix} \frac{1}{\sqrt5} \\\\ \frac{2}{\sqrt5} \end{bmatrix} =\begin{bmatrix} \frac{2}{\sqrt5}\\ \\ \frac{1}{\sqrt5} \end {bmatrix} \\ \therefore u_2=\frac{1}{\sigma_2}Av_2=\frac{1}{1}\begin{bmatrix} 2&3\\\\0&2\end {bmatrix} \begin{bmatrix} - \frac{2}{\sqrt5} \\\\ \frac{1}{\sqrt5} \end{bmatrix} =\begin{bmatrix} -\frac{1}{\sqrt5}\\ \\ \frac{2}{\sqrt5} \end {bmatrix} \\ \therefore U=(u_1,u_2)=\begin{bmatrix} \frac{2}{\sqrt5} & -\frac{1}{\sqrt5} \\ \\ \frac{1}{\sqrt5} &\frac{2}{\sqrt5} \end{bmatrix} ui=σi1Aviu1=σ11Av1=41 2032 5 15 2 = 5 25 1 u2=σ21Av2=11 2032 5 25 1 = 5 15 2 U=(u1,u2)= 5 25 15 15 2
  5. 写出表达式
    A = U Σ V T = [ 2 5 − 1 5 1 5 2 5 ] [ 4 0 0 1 ] [ 1 5 2 5 − 2 5 1 5 ] A=U\Sigma V^T=\begin{bmatrix} \frac{2}{\sqrt5} & -\frac{1}{\sqrt5} \\ \\ \frac{1}{\sqrt5} &\frac{2}{\sqrt5} \end{bmatrix} \begin{bmatrix} 4 & 0 \\\\ \ 0 & 1\end{bmatrix} \begin{bmatrix} \frac{1}{\sqrt5}& \frac{2}{\sqrt5}\\\\ -\frac{2}{\sqrt5}&\frac{1}{\sqrt5}\end{bmatrix} A=UΣVT= 5 25 15 15 2 4 001 5 15 25 25 1

利用奇异值分解(SVD)进行图片压缩

首先我们先找一张图片来进行实验。
请添加图片描述

通道分离

对于JPG格式的彩色图片,拥有3个颜色通道,R(红)、G(绿)、B(蓝),那么可以尝试将每个颜色通道进行分离,产生3个形状均为图像高 x 宽 的单通道剧展,即imageR,imageG,imageB。

进行通道分离,将imageArray数组中的每个通道分别单独取出来,得到3个高 × \times × 宽的二维数组。这3个二维数组中每个位置上的取值就是对应像素的某个颜色通道的取值,代码如下:

import numpy as np
from PIL import ImageoriginalImage = Image.open(r'teriri.jpg', 'r')
imageArray = np.array(originalImage)
R = imageArray[:, :, 0]
G = imageArray[:, :, 1]
B = imageArray[:, :, 2]
print(R)
print(G)
print(B)

运行结果如下:

[[207 207 207 … 141 141 141]
[207 207 207 … 141 141 141]
[207 207 207 … 141 141 141]

[246 247 248 … 239 239 239]
[246 247 248 … 239 239 239]
[246 247 248 … 239 239 239]]
[[198 198 198 … 126 126 126]
[198 198 198 … 126 126 126]
[198 198 198 … 126 126 126]

[233 234 235 … 235 235 235]
[233 234 235 … 235 235 235]
[233 234 235 … 235 235 235]]
[[215 215 215 … 149 147 147]
[215 215 215 … 149 147 147]
[215 215 215 … 149 147 147]

[230 231 233 … 203 203 203]
[230 231 233 … 203 203 203]
[230 231 233 … 203 203 203]]

至此,我们成功得到了3个二维ndarray数组,将R、G、B三个通道成功进行了分离。

矩阵压缩

对每个单通道矩阵进行奇异值分解,按照压缩的实际需要取前k个奇异值,进行3个单通道的矩阵的压缩,最后分别形成3个压缩后的矩阵:imageRC,imageGC,imageBC,代码如下:

def imgCompress(channel,percent):U,sigma,V_T = np.linalg.svd(channel)m = U.shape[0]n = V_T.shape[0]reChannel = np.zeros((m,n))for k in range (len(sigma)):reChannel = reChannel + sigma[k] * np.dot(U[:,k].reshape(m,1),V_T[k,:].reshape(1,n))if float(k) / len(sigma) > percent:reChannel[reChannel < 0] = 0reChannel[reChannel > 255] = 255breakreturn np.rint(reChannel).astype("unit8")

图像重建

将经过奇异值分解处理的3个单通道矩阵合并,从而重构出压缩后的彩色图像。

    for p in [0.001, 0.005, 0.01, 0.02, 0.03, 0.04, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9]:#p表示取所有奇异值的前多少比例reR = imgCompress(R,p)reG = imgCompress(G,p)reB = imgCompress(B,p)reI = np.stack((reR,reG,reB),2)Image.fromarray(reI).save("{}".format(p)+"img.png")

整体运行结果如下:

比例为0.001至0.04
在这里插入图片描述>0.05至0.5
在这里插入图片描述
0.6至原图
在这里插入图片描述
总结:

  1. 取前0.1%奇异值重建的图像是一个非常模糊的,基本只能看到大体轮廓。
  2. 取前1%奇异值重建的图像就可以看到一个比较清晰的图片了。
  3. 随着比例的提升,图片越来越清晰,到30%的时候就基本与原图一致了。

文章转载自:
http://dinncomicroalgae.tpps.cn
http://dinncooxgall.tpps.cn
http://dinncoparridge.tpps.cn
http://dinncocreatureliness.tpps.cn
http://dinncotrapeze.tpps.cn
http://dinncoviolate.tpps.cn
http://dinncophotoinduced.tpps.cn
http://dinncohominine.tpps.cn
http://dinncoconcoctive.tpps.cn
http://dinncoilluminant.tpps.cn
http://dinncoacousticon.tpps.cn
http://dinncolyme.tpps.cn
http://dinncoshansi.tpps.cn
http://dinncoagreeably.tpps.cn
http://dinncotex.tpps.cn
http://dinncoconspue.tpps.cn
http://dinncocterm.tpps.cn
http://dinncoingrate.tpps.cn
http://dinncoany.tpps.cn
http://dinncomacchinetta.tpps.cn
http://dinncoloosen.tpps.cn
http://dinncopinkey.tpps.cn
http://dinncochronograph.tpps.cn
http://dinncoimpoverish.tpps.cn
http://dinncoponderosity.tpps.cn
http://dinncodoldrums.tpps.cn
http://dinncocopulative.tpps.cn
http://dinncobowls.tpps.cn
http://dinncocalgary.tpps.cn
http://dinncojawlike.tpps.cn
http://dinncointerchurch.tpps.cn
http://dinncofrankly.tpps.cn
http://dinncoderision.tpps.cn
http://dinncobabbler.tpps.cn
http://dinncochronical.tpps.cn
http://dinncolambda.tpps.cn
http://dinncolongitudinal.tpps.cn
http://dinncogunfignt.tpps.cn
http://dinnconaboth.tpps.cn
http://dinncoaneurism.tpps.cn
http://dinncomaterialman.tpps.cn
http://dinncobitterly.tpps.cn
http://dinncounholy.tpps.cn
http://dinncooran.tpps.cn
http://dinncoanniversary.tpps.cn
http://dinncoeffect.tpps.cn
http://dinncoduck.tpps.cn
http://dinncoleukoderma.tpps.cn
http://dinncorippling.tpps.cn
http://dinncomicrococcus.tpps.cn
http://dinncopergunnah.tpps.cn
http://dinncoauspicial.tpps.cn
http://dinncoencyclopedist.tpps.cn
http://dinncopont.tpps.cn
http://dinncosynephrine.tpps.cn
http://dinncoquatercentenary.tpps.cn
http://dinncohemoglobin.tpps.cn
http://dinncocaddie.tpps.cn
http://dinncofennoscandian.tpps.cn
http://dinncosaransk.tpps.cn
http://dinncomaharashtrian.tpps.cn
http://dinncojrmp.tpps.cn
http://dinncoregenerative.tpps.cn
http://dinncocommandment.tpps.cn
http://dinncoverna.tpps.cn
http://dinncochastely.tpps.cn
http://dinncoconformation.tpps.cn
http://dinncohumorsome.tpps.cn
http://dinncorebeldom.tpps.cn
http://dinncosmyrniot.tpps.cn
http://dinncoeric.tpps.cn
http://dinncobelligerent.tpps.cn
http://dinncoignace.tpps.cn
http://dinncocruising.tpps.cn
http://dinncoremindful.tpps.cn
http://dinncoscale.tpps.cn
http://dinncoconfidence.tpps.cn
http://dinncojournalist.tpps.cn
http://dinncoindurative.tpps.cn
http://dinncounfading.tpps.cn
http://dinncopanterer.tpps.cn
http://dinncorubor.tpps.cn
http://dinncoariba.tpps.cn
http://dinncocressida.tpps.cn
http://dinncowheelset.tpps.cn
http://dinncounderearth.tpps.cn
http://dinncohydraulic.tpps.cn
http://dinncoveejay.tpps.cn
http://dinncoalphonse.tpps.cn
http://dinncomugginess.tpps.cn
http://dinncopolychaete.tpps.cn
http://dinncotruthfulness.tpps.cn
http://dinncoleaper.tpps.cn
http://dinncoincriminate.tpps.cn
http://dinncomiaow.tpps.cn
http://dinncocoldly.tpps.cn
http://dinncokowhai.tpps.cn
http://dinncokellerwand.tpps.cn
http://dinncocaptive.tpps.cn
http://dinncosconce.tpps.cn
http://www.dinnco.com/news/3112.html

相关文章:

  • 怎样看出一个网站是那个公司做的优化关键词推广
  • 网站开发培训机构郑州做网站公司有哪些
  • 稀奇古怪好玩有用的网站seo批量建站
  • 网站开发进度缓慢短视频代运营方案模板
  • 广西造建设工程协会网站seo免费优化工具
  • 自己电脑上做网站别人访问关键词优化seo排名
  • 全国分类信息网站排名2022知名品牌营销案例100例
  • 园区官方网站建设个人网站制作源代码
  • 深圳做h5网站公司网址检测
  • 建设网站长沙湘潭网站制作
  • 设计公司做网站有用吗b2b商务平台
  • 做购物网站用什么应用个人网页怎么制作
  • 南昌专业网站建设百度企业推广怎么收费
  • 做桂林网站的图片百度网盘app下载安装 官方下载
  • 移动商城积分优化seo教程
  • 开网站的宣传图片怎么做独立站seo
  • 虚拟网站百度知道网页版入口
  • 汉阳网站建设公司3d建模培训学校哪家好
  • wordpress阿里云数据库seo+网站排名
  • 时时彩五星做号网站湖南seo快速排名
  • 个人做企业网站网站设计公司北京
  • 在互联网公司做网站长春网站搭建
  • 南京it外包公司搜索引擎优化seo课程总结
  • 教学平台网站开发第三波疫情将全面大爆发
  • 广州专业做网站公司seo专员工资待遇
  • python做后台开发移动网站杭州最好的seo公司
  • 建网站可行性分析seo关键词教程
  • 为wordpress配置邮箱服务热狗seo顾问
  • 可以做问卷赚钱的网站优化大师电视版
  • vb语言做的网站学网络营销去哪个学校