当前位置:网站首页>NMF-matlab
NMF-matlab
2022-07-02 18:38:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
matlab练习程序(非负矩阵分解)
这个算法是Lee和Seung在1999年发表在nature杂志上的。具体论文看这里:http://www.seas.upenn.edu/~ddlee/Papers/nmf.pdf。
看不懂英文没关系,可以看这个中文的介绍:http://wenku.baidu.com/view/94c8af0bf78a6529647d5331.html。
原理上面两篇文章已经很清楚了,我在按自己的理解介绍一下吧。
通常矩阵分解如svd或其他什么的分解都会把矩阵分解为有正有负的矩阵,而他的这种分解方法就把矩阵完全分解成只有正数的矩阵,因为现实世界中如图像,负数是没什么意义的,所以这种只分解为正数矩阵的分解方法就很有意义了,要不也不会发在nature这样牛B的杂志上。
这里是分解的公式:
这里r是分解矩阵的秩,V是原矩阵的一个近似,W与H就是分解而成的两个矩阵。
下面是W和H的求法,是一个迭代算法,初始的W与H是随机的就行了:
关于代码,我借鉴了这个博客的:http://fxy1211.blog.163.com/blog/static/68255322007826111015905/,真是太感谢这位博主了。
下面是代码:
clear all; close all; clc; V=double(imread('lena.jpg')); imshow(mat2gray(V)); [i u]=size(V); %计算V的规格 r=100; %设置分解矩阵的秩 W=rand(i,r); %初始化WH,为非负数 H=rand(r,u); maviter=100; %最大迭代次数 for iter=1:maviter W=W.*((V./(W*H))*H'); %注意这里的三个公式和文中的是对应的
W=W./(ones(i,1)*sum(W)); H=H.*(W'*(V./(W*H)));
end img_V=W*H; figure; imshow(mat2gray(img_V));
下面是原图和重构后的效果,如果秩和迭代次数越大,那么重构后的图越接近原图:
原图
重构图
因为这个是看自己相关方向论文偶然在一篇论文的引用中看到了这个算法,所以就稍微了解了一下,肯定有不妥的地方,就这样吧。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/148571.html原文链接:https://javaforall.cn
边栏推荐
- Py之interpret:interpret的简介、安装、案例应用之详细攻略
- 搭建主从模式集群redis
- 字典
- AcWing 1127. 香甜的黄油 题解(最短路—spfa)
- Golang:[]byte to string
- Memory management of C
- LeetCode 0871. Minimum refueling times - similar to poj2431 jungle adventure
- Idea editor removes SQL statement background color SQL statement warning no data sources are configured to run this SQL And SQL dialect is not config
- 《架构整洁之道》读书笔记(下)
- Codeworks 5 questions per day (1700 average) - day 4
猜你喜欢
Data dimensionality reduction factor analysis
潇洒郎:彻底解决Markdown图片问题——无需上传图片——无需网络——转发给他人图片无缺失
Develop fixed asset management system, what voice is used to develop fixed asset management system
搭建主从模式集群redis
Markdown基础语法
线程应用实例
Yunna | why use the fixed asset management system and how to enable it
高级性能测试系列《24. 通过jdbc执行sql脚本》
[error record] problems related to the installation of the shuttle environment (follow-up error handling after executing the shuttle doctor command)
Reading notes of "the way to clean structure" (Part 2)
随机推荐
Why should we build an enterprise fixed asset management system and how can enterprises strengthen fixed asset management
Yunna | why use the fixed asset management system and how to enable it
AcWing 341. 最优贸易 题解 (最短路、dp)
Refactoring: improving the design of existing code (Part 1)
451-memcpy、memmove、memset的实现
PHP asymmetric encryption method private key and public key encryption and decryption method
Mobile robot path planning: artificial potential field method [easy to understand]
Emmet basic syntax
Reading notes of code neatness
GMapping代码解析[通俗易懂]
Bubble sort array
《代码整洁之道》读书笔记
Microservice technology - distributed global ID in high concurrency
Binary operation
Golang并发编程——goroutine、channel、sync
Data dimensionality reduction factor analysis
注解开发方式下AutowiredAnnotationBeanPostProcessor的注册时机
Notes de lecture sur le code propre
Implementation of 452 strcpy, strcat, StrCmp, strstr, strchr
Develop fixed asset management system, what voice is used to develop fixed asset management system