⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 avgofmatblks.m

📁 quadtree implementation in matlab
💻 M
字号:
% % finds average of different blocks of input matrix
% % INPUT
% % i,j,w,h are vectors
% % mat : input matrix
% % i(k): beginning row index of kth block
% % j(k): beginning column index of kth block
% % w(k): width of kth block   (e.g. column 1 to colum 5 of mat)
% % h(k): height of kth block  (e.g. row 1 to row 3 of mat)
% % OUTPUT
% % avg(k): average of kth block (avg is a vector)
function avg=avgofmatblks(mat,i,j,w,h)

blkcount=length(i);
for k=1:blkcount        
    fromRow=i(k);
    toRow=i(k)+h(k)-1;
    fromCol=j(k);
    toCol=j(k)+w(k)-1;
    count=(toRow-fromRow+1).*(toCol-fromCol+1);
    avg(k)=sum(sum(mat(fromRow:toRow,fromCol:toCol)))/count; %avg/mean of block values
end

% % -------------------------------------------------------------------------
% % This program or any other program(s) supplied with it does not provide any
% % warranty direct or implied. This program is free to use/share for
% % non-commercial purpose only, for any other usage contact with author.
% % Kindly reference author.
% % Thanking you.
% % @ Copyright M Khan
% % Email: mak2000sw@yahoo.com
% %        mak2000@GameBox.net 
% % http://www.geocities.com/mak2000sw

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -