[cv] filters as templates-normxcorr2(template,img)
来源:互联网 发布:sql中like用法 编辑:程序博客网 时间:2024/06/05 11:49
introduction
images are not just functions (intensity).
it also contains location properties.
1D correlation
the filter is normalized and then is used to compute cross -correlation.
why the peak value is at index 60?
because positve value in signal [50,70] multiply positive value in filter, and negative value in signal [50,70] multiply negative value in filter. At last, we sum them up.
cross-correlation in matlab
%% matlab cross-correlationfruit = rgb2gray(imread('../pics/fruit.png'));apple = rgb2gray(imread('../pics/apple.png'));% imshowpair(fruit,apple, 'montage');c = normxcorr2(apple, fruit);figure;surf(c);shading flat;
% Find template 1D% Function definition must be the very first piece of code here!function index = find_template_1D(t, s) c = normxcorr2(t,s); [~,index] = max(c); index = index -size(t,2) + 1;endpkg load image; % after define function% Test code:s = [-1 0 0 1 1 1 0 -1 -1 0 1 0 0 -1];t = [1 1 0];disp('Signal:'), disp([1:size(s, 2); s]);disp('Template:'), disp([1:size(t, 2); t]);index = find_template_1D(t, s);disp('Index:'), disp(index);
template matching
% Find template 2D% NOTE: Function definition must be the very first piece of code here!function [yIndex xIndex] = find_template_2D(template, img) % TODO: Find template in img and return [y x] location % NOTE: Turn off all output from inside the function before submitting! c = normxcorr2(template, img); [~,idx] = max(c(:)); [yIndex, xIndex] = ind2sub(size(c), idx); xIndex = xIndex - size(template,2) + 1; yIndex = yIndex - size(template,1) + 1;endfunctionpkg load image; % AFTER function definition% Test code:tablet = imread('tablet.png');imshow(tablet);glyph = tablet(75:165, 150:185);imshow(glyph);[y x] = find_template_2D(glyph, tablet);% y row number % x column numberdisp([y x]); % should be the top-left corner of template in tabletcolormap('gray'),imagesc(tablet);hold on;plot(x,y,'r+','markersize',16);hold on;
but we have more powerful tools to detection face.
0 0
- [cv] filters as templates-normxcorr2(template,img)
- 2A-L4 filters as templates quiz code
- AS template
- AS Live Templates
- Live templates in AS
- django notes 4 template tags and filters
- xsl:template和xsl:apply-templates
- confd template src格式和 templates 语法
- The Standard Containers as Class Templates
- 工具篇AS之 live templates
- AS创建简单的live templates
- 《C++ Template. The Complete Guide》笔记之二 Function Templates
- 《C++ Template. The Complete Guide》笔记之三 Class Templates
- xsl:template 和 xsl:apply-templates 的用法
- XSLT(6) Function named templates and <xsl:call-template>
- C++ template高阶技巧(4)---《C++ Templates》
- C++ Template基本术语(6)---《C++ Templates》
- C++ Template自变量推导(11)---《C++ Templates》
- 可逆素数
- (不ROOT/不安装软件/安全)--Android/安卓手机手动冻结/禁用系统应用方法
- PHP 中使用explode()函数切割字符串为数组
- MySQL Order By实现原理分析和Filesort优化
- 各种面试题-虐虐虐
- [cv] filters as templates-normxcorr2(template,img)
- 383. Ransom Note
- java的本地方法
- 开博客了
- 如何解决回调地狱问题(任何语言)
- InstantRun框架源码分析之一
- Java面试知识点(全面)
- CSU 1913: 送礼物 (二分答案 + 线段树)
- WAMPServer自定义端口号