今天在看Michael Elad 大牛的论文《On the Role of Sparse and Redundant Representations in Image Processing》中,看到了soft thresholding 和hard thresholding 这两个概念,很是不明白,所以上网查了一些资料,先把网上查的东西贴出来讨论下。

网上资料大体是说这是指两类的函数,分别是软阈值函数和硬阈值函数,在matlab中soft thresholding function 的形式是 ,其中x代表的的输入向量或矩阵,T表示阈值, if x<0,  if x>=0; hard thresholding function 的形式是 两者的shrinkage curves 为下图:


这两个thresholding 有什么用处完全不知道,欢迎知道的朋友告知下,在网上到,好像小波变换的时候有用到它们哥俩,还有什么去噪什么的,而我看的Michael的论文提到它们哥俩的时候是在解决优化问题的时候,论文中是这样的,在解决优化问题

的时候,由于上式加号两边的两项是可分离的(separable)(为什么??),the optimization decouples into a set ofindependent scalar problems of the form ,which have particularly simple closed-form solutions in the two notable cases p=0 and p=1, called hard- and soft-thresholding, respectively. 上面是论文上的原话,就是说当p=1的时候,上述优化问题称为软阈值问题,论文中还有个结论就是对于soft thresholding, 阈值应该为λ,而对于hard thresholding,阈值应该是2倍λ的开根号(不是λ开根号的2倍),到目前为止完全不懂。在网上又看到了一个叫Simon Lucey的主页,他里面讲了一些soft thresholding的东西,也弄过来看看,我就不翻译了,直接上英文:Soft thresholding is becoming a very popular tool in computer vision and machine learning. Essentially it allows one to add to take the following objective:, (和上面的p=1相比,那个0.5可有可无吗???)and solve in a very fast fashion using an approach referred to as soft thresholding. Since L1 penalties are being used nearly everywhere at the moment, the property of soft thresholding to efficiently find the solution to the above form becomes very useful。
这个叫Simon的家伙分别使用matlab的凸优化包CVX中的interior point methods 与刚才讲的soft thresholding去解决上面提到的优化问题进行了对比,代码如下,先使用CVX工具箱,

% Function to solve soft thresholding problem using CVX
%
% arg min_{x} ||x - b||_{2}^{2} + lambda*||x||_{1}
%
% Usage:- x = soft_thresh_cvx
%
% where:- <in>
%         b = bias vector
%         lambda = weighting on the l1 penalty
%         <out>
%         x = solution         
%
% Written by Simon Lucey 2012

% 不得不佩服老外做事的认真严谨,随便写个函数看上面的注释就看出来了
function x = soft_thresh_cvx(b,lambda)

M = length(b);
cvx_begin
    cvx_quiet(true);
    variable x(M,1);
    minimize( sum_square(x - b) + lambda*norm(x,1));
cvx_end

根据作者说上述方法很费时,下面贴上使用了soft thresholding方法的code。

先定义soft thresholding operator。

其实就是本文最开始的时候的soft thresholding function中x=b,T=0.5λ的分段形式,但是这里的阈值取的却是0.5λ,这和上文Michael论文中结论说soft thresholding 阈值应该取λ不符,难道是因为这里的2范数之前没有那个1/2的原因吗??函数代码如下:

% Function to solve soft thresholding problem
%
% arg min_{x} ||x - b||_{2}^{2} + lambda*||x||_{1}
%
% Usage:- x = soft_thresh
%
% where:- <in>
%         b = bias vector
%         lambda = weighting on the l1 penalty
%         <out>
%         x = solution         
%
% Written by Simon Lucey 2012
function x = soft_thresh(b,lambda)

% Set the threshold
th = lambda/2;

% First find elements that are larger than the threshold
k = find(b > th);
x(k) = b(k) - th;

% Next find elements that are less than abs
k = find(abs(b) <= th);
x(k) = 0;

% Finally find elements that are less than -th
k = find(b < -th);
x(k) = b(k) + th;
x = x(:);

或者上述函数也可以更简洁的用一句matlab代码表示:

soft_thresh = @(b,lambda) sign(b).*max(abs(b) - lambda/2,0); %对matlab比较精通的同学可以解释下。
下面进行对比:

b = [-0.8487   -0.3349    0.5528    1.0391   -1.1176]';
lambda=2;

soft_thresh(b, lambda)

ans =

0
         0
         0
    0.0391
   -0.1176

soft_thresh_cvx(b, lambda)

ans =

-0.0000
   -0.0000
    0.0000
    0.0391
   -0.1176

可以看到,两者产生的结果完全一样,我自己也在自己的电脑上试验了一下,前提是需要安装斯坦福大学的凸优化解决包CVX,试验结果和simon的完全一样,CVX的解决时间为0.263894秒,而soft thresholding的时间仅仅为0.002016秒,快了130倍!!!

作者Simon在最后提醒说soft thresholding不能简单的用来解决下面形式的问题,
我看Michael 的那篇论文中也说了不能上面形式的问题,Michael只是简单的说由于A的存在,加号两边不具有可分离性了,所以不能使用soft thresholding了,而Simon说由于A将x进行了一个空间旋转,我们不得不使用更慢的CVX来解决上面的问题,但是好消息是最近被证明Augmented Lagragian Methods(不知道什么东东)可用于避免这一问题,并允许继续使用高效的soft thresholding。具体的我就不清楚了。。。哎,数学不好害死人啊,什么时候才能达到大牛们的高度啊。

暂时先写到这吧,

soft thresholding and hard thresholding相关推荐

  1. (转)IST:Iterative Shrinkage/Thresholding和Iterative Soft Thresholding

    原 IST:Iterative Shrinkage/Thresholding和Iterative Soft Thresholding 2016年08月10日 15:26:02 jbb0523 阅读数: ...

  2. IST:Iterative Shrinkage/Thresholding和Iterative Soft Thresholding

    题目:IST:Iterative Shrinkage/Thresholding和Iterative Soft Thresholding 本篇是对压缩感知重构算法之迭代软阈值(IST)的延续,可能需要以 ...

  3. Iterative Soft Thresholding和Iterative Shrinkage/Thresholding的区别

    版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明. 题目:IST:Iterative Shrinkage/Thresholding和Iterati ...

  4. Image Thresholding图像阙值化和Adaptive Thresholding

    要用到的函数是cv2.threshold() 这个参数的形式是cv.Threshold(src, dst, threshold, maxValue, thresholdType) Parameters ...

  5. 二值化Thresholding

    在图像处理中,Thresholding中文翻译过来叫二值化或者阈值化.二值化就是把图片传换成只有white和black这两种颜色.通过Thresholding,可以让图片中感兴趣的颜色变成主角–whi ...

  6. Image Thresholding

    摘自https://docs.opencv.org/4.2.0/d7/d4d/tutorial_py_thresholding.html Simple Thresholding The functio ...

  7. OpenCV-Python -- Image Thresholding

    学习目标 本教程,将学习自适应阈值(Adaptive Thresholding),Otsu's阈值等 学习函数:cv2.threshold,cv2.addaptiveThreshold 简单阈值(Si ...

  8. 「机器视觉」学习笔记 - Thresholding Techniques- 图像阈值

    shiIntroducing thresholding techniques Simple thresholding technique Adaptive thresholding technique ...

  9. 【Opencv学习】Image Thresholding

    文章目录 一.灰度图像二值化 阈值类型: 二.自适应阈值 三.大津法阈值选择 一.灰度图像二值化 阈值类型: cv.THRESH_BINARY cv.THRESH_BINARY_INV cv.THRE ...

最新文章

  1. Java提高篇——Java实现多重继承
  2. Spring-AOP @AspectJ切点函数之@annotation()
  3. python列表浅复制_Python列表深浅复制详解
  4. hadoop 自定义OutputFormat
  5. MapReduce之InputFormat理解
  6. axure 元件_在Axure中实现波纹点击特效按钮的方法
  7. arch模型的思路_时间序列--ARCH模型
  8. java 自定义登录态_java – 自定义HTTP状态代码
  9. [javaSE] 集合工具类(Collections-sort)
  10. 【Spring】对象后期处理,BeanPostProcessor
  11. 机器人到底会不会有情感?
  12. ActiveMQ下载与安装,无法远程访问控制台
  13. .net快速开发平台,learun敏捷开发框架
  14. px和毫米的换算_px和mm换算(px相当于多少毫米)
  15. 100%概率与任意好友获取QQ幸运字符的方法
  16. GIS真正的魅力在哪?
  17. 积分商城消费系统定制
  18. linux系统u盘格式化命令,如何用LINUX命令格式化U盘
  19. 学习笔记-基于全局和局部对比自监督学习的高分辨率遥感图像语义分割-day1
  20. python3 规则引擎_Ilog、Drools、Jess规则引擎的Rule Language 对比

热门文章

  1. 一文带你手撕metasploit中meterprter木马源码_雁不过衡阳
  2. C/C++之标准输入输出
  3. 搜狗拼音输入法不能连着打一整句,只能两个字两个字的词语来选
  4. python scatter
  5. Prodipe Pro 5v3超值模拟音色监听音箱评测
  6. Quested V2108录音室监听音箱评测
  7. Hudi学习02 -- Hudi核心概念
  8. 使用Calendar类得到一年中的二月有多少天
  9. 有功功率、无功功率和视在功率
  10. 在精读英文文献时有哪些好习惯?