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

asp.net 网站管理系统百度百科推广联系方式

asp.net 网站管理系统,百度百科推广联系方式,品牌注册商标流程及费用,纯css网站SVD 是一种矩阵分解和降维的算法,通过分解矩阵找到奇异值,奇异值越大代表特征越重要。公式如下 A U Σ V T A U \Sigma V^T AUΣVT U : 左矩阵 ( m \times m ) Σ \Sigma Σ: 对角奇异值矩阵V:右矩阵( n \times n ) Sklearn 实现 S…

SVD 是一种矩阵分解和降维的算法,通过分解矩阵找到奇异值,奇异值越大代表特征越重要。公式如下

A = U Σ V T A = U \Sigma V^T A=UΣVT

  • U : 左矩阵 ( m × \times × m )
  • Σ \Sigma Σ: 对角奇异值矩阵
  • V:右矩阵( n × \times × n )

Sklearn 实现 SVD

import numpy as np
A = np.array([[0,1],[1,1],[1,0]])
u, s, vt = np.linalg.svd(A, full_matrices=True)
print(u.shape, s.shape, vt.shape)

在这里插入图片描述
SVD 可以用于图片的压缩,只保留最重要信息,从 k=1 到 k=50:

import numpy as np
import os
from PIL import Image
from tqdm import tqdm# 定义恢复函数,由分解后的矩阵恢复到原矩阵
def restore(u, s, v, K): '''u:左奇异矩阵v:右奇异矩阵s:奇异值矩阵K:奇异值个数'''m, n = len(u), len(v[0])a = np.zeros((m, n))for k in range(K):uk = u[:, k].reshape(m, 1)vk = v[k].reshape(1, n)# 前k个奇异值的加总a += s[k] * np.dot(uk, vk)   a = a.clip(0, 255)return np.rint(a).astype('uint8')A = np.array(Image.open("./mountain.png", 'r'))
# 对RGB图像进行奇异值分解
u_r, s_r, v_r = np.linalg.svd(A[:, :, 0])    
u_g, s_g, v_g = np.linalg.svd(A[:, :, 1])
u_b, s_b, v_b = np.linalg.svd(A[:, :, 2])# 使用前50个奇异值
K = 50 
output_path = './svd_pic'
# 
for k in tqdm(range(1, K+1)):R = restore(u_r, s_r, v_r, k)G = restore(u_g, s_g, v_g, k)B = restore(u_b, s_b, v_b, k)I = np.stack((R, G, B), axis=2)   Image.fromarray(I).save('%s/svd_%d.jpg' % (output_path, k))

显示图片

from PIL import Image
from IPython.display import display, HTML
import os
import re
import time# Path to the folder containing images
image_folder = "./svd_pic"# List all image files
image_files = [f for f in os.listdir(image_folder) if f.endswith(('.png', '.jpg', '.jpeg'))]# Sort image files by the numeric part of the filename
def extract_number(filename):match = re.search(r'_(\d+)\.', filename)return int(match.group(1)) if match else float('inf')image_files = sorted(image_files, key=extract_number)# Generate HTML for horizontal display with cache busting
html = "<div style='display: flex; flex-direction: row; flex-wrap: wrap;'>"
timestamp = int(time.time())  # Use current timestamp for cache bustingfor idx, image_file in enumerate(image_files):img_path = os.path.join(image_folder, image_file)# Add a unique query parameter to disable cachingimg_url = f"{img_path}?v={timestamp}"img = Image.open(img_path)img_resized = img.resize((150, 150))  # Resize to 300x300img_resized.save("temp_resized.jpg")  # Save resized image temporarily# Add image with index number overlayhtml += f"""<div style="margin: 10px; position: relative; display: inline-block; text-align: center;"><img src="{img_url}" style="width: 150px; height: 150px; display: block;"><div style="position: absolute; top: 10px; left: 10px; background-color: rgba(0, 0, 0, 0.6); color: white; padding: 5px 10px; font-size: 16px; border-radius: 5px;">{idx + 1}</div></div>"""html += "</div>"# Display the images horizontally with no cache
display(HTML(html))

随着K 值增大,图片会越来越清晰。
在这里插入图片描述

总结

SVD 算法通过求解奇异值对矩阵进行分解,较大奇异值能表达更重要的信息。

http://www.ds6.com.cn/news/101664.html

相关文章:

  • 基于html5的旅游网站开发自动收录网
  • 校园互动网站建设推广引流的10个渠道
  • 郑州做网站网站建设费用如何去推广一个app
  • 牛什么的网站建设正规的微信推广平台
  • 虹口房产网站建设网络营销管理系统
  • 外贸网站如何做推广怎么让网站快速收录
  • 健康湖州网站网站收录提交入口
  • 加速百度对网站文章的收录社会新闻热点事件
  • 网站权重优化方式开鲁视频
  • 企业做网站分一般为哪几种类型好看的html网页
  • 北京公司网站建设费用seo前景
  • 专业做营销网站杭州优化排名哪家好
  • 微网站 尺寸产品推广渠道有哪些
  • 太原做网站页面的北京首页关键词优化
  • 深圳网站建设信科便宜品牌整合营销
  • 一般的政府网站空间多少钱一年seo单页快速排名
  • 江苏省建设工程备案网站合肥关键词排名技巧
  • h5响应式网站做动画营销广告语
  • 电商网站建设策划书公众号推广渠道
  • 工厂做网站如何做网页链接
  • 建浏览器网站制作搜索关键词排名推广
  • 网站建设需要哪些工作室电商seo是什么
  • 公司网站维护都需要怎么做外链代发免费
  • dedecms做网站怎么查看免费的大数据分析平台
  • 做销售在哪些网站注册好昆山网站建设
  • 网站建设人员职责百度关键词seo公司
  • 做包装的网站郑州网站建设推广优化
  • wordpress5.0启多站点常州seo
  • 视频网站哪个做的好处已矣seo排名点击软件
  • 手机做网站公司新手怎么做网络推广