Hello Mat

 找回密码
 立即注册
查看: 8769|回复: 0

局部对比度归一化层Local Contrast Normalization Layer-N

[复制链接]

1319

主题

1547

帖子

0

金钱

管理员

Rank: 9Rank: 9Rank: 9

积分
22631
发表于 2017-6-10 17:07:16 | 显示全部楼层 |阅读模式
局部对比度归一化层Local Contrast Normalization Layer-N:
可参考链接:http://blog.csdn.net/zouxy09/article/details/10007237
  1. function y = localContrastNormalize(I, windowSize)
  2. % Locally contrast normalizes an image. This is very often used as a
  3. % pre-processing technique in feature learning. It is described in more
  4. % detail in, for example,
  5. %
  6. % Jarett et al., "What is the Best Multi-Stage Architecture for Object
  7. % Recognition?" (ICCV 2009)
  8. %
  9. % EXAMPLE
  10. %  G = rgb2gray(imread('data/lenna.jpg'));
  11. %  y = localContrastNormalize(G);
  12. %  figure(1); imshow(G,[]); figure(2); imshow(y,[]);
  13. %

  14. if(isa(I, 'uint8')), I = double(I) / 255.0; end
  15. if nargin < 2 || isempty(windowSize), windowSize = 8; end

  16. nd = ndims(I);

  17. wSide = normpdf(linspace(-2, 2, windowSize), 0, 1);
  18. w = wSide'*wSide;
  19. w = w/sum(sum(w));

  20. conv2opt= 'same';
  21. % if removeBorder, conv2opt= 'full'; end

  22. if nd == 2
  23.     % grayscale input
  24.     v = I - conv2(I, w, conv2opt);
  25.     s = sqrt(conv2(v.^2, w, conv2opt));
  26.     c = mean(mean(s));
  27.     y = v./max(c, s);
  28. else
  29.     % RGB input
  30.     v1 = I(:,:,1) - conv2(I(:,:,1), w, conv2opt);
  31.     v2 = I(:,:,2) - conv2(I(:,:,2), w, conv2opt);
  32.     v3 = I(:,:,3) - conv2(I(:,:,3), w, conv2opt);
  33.      
  34.     s = sqrt(conv2(v1.^2, w, conv2opt) + conv2(v2.^2, w, conv2opt) + conv2(v3.^2, w, conv2opt));
  35.     c = mean(mean(s));
  36.     mm= max(c, s);
  37.     y = cat(3, v1./mm, v2./mm, v3./mm);
  38. end
  39. end
复制代码










本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
算法QQ  3283892722
群智能算法链接http://halcom.cn/forum.php?mod=forumdisplay&fid=73
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Python|Opencv|MATLAB|Halcom.cn ( 蜀ICP备16027072号 )

GMT+8, 2024-10-31 18:21 , Processed in 0.222382 second(s), 26 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表