How to do this without blkproc function..?
显示 更早的评论
B = blkproc(I,[8 8],'P1*x*P2',T,T');
B2 = blkproc(B,[8 8],'P1.*x',mask);
% I have this code..
%I want to replace blkproc without using that fuction.. And the code is at follows.
%
%
m = 8;
n = 8;
p =0;
q = 0;
NColBlocks = 0;
for Colnum = 1: n : size(I,2)
NColBlocks = NColBlocks + 1;
NRowBlocks = 0;
for Rownum = 1: m : size(I,1)
NRowBlocks = NRowBlocks + 1;
fun = T*T';
B_temp{NRowBlocks, NColBlocks} = ...
fun(I(Rownum - p: Rownum + m - 1 + p, ...
Colnum - q: Colnum + n - 1 + q));
end
end
B = cell2mat(B_temp);
% But it created error, So, how to correct it..
4 个评论
Geoff Hayes
2014-9-26
编辑:Geoff Hayes
2014-9-26
Nimisha - what is the error? Please include the error message and line number that the error corresponds to. As well, please format all of you code and not just some of it. Highlight all of the code and press the {} Code button.
You have the line
B = cell2mat(B_temp);
but nowhere is B_temp defined. As well, what is T and why do you treat the multiplication of T with it's transpose as some sort of function that does not return anything at
fun(I(Rownum - p: Rownum + m - 1 + p, ...
Colnum - q: Colnum + n - 1 + q));
You may want to review your code line by line and add comments where appropriate. That may help you to figure out where you are going wrong.
Nimisha
2014-9-26
Geoff Hayes
2014-9-26
But what is the error? Is it occurring because the number of rows and columns in your input image I are not (evenly) divisible by eight (your m and n) or is it because of the evaluation of fun? What is T, and what are you attempting with
fun(I(Rownum - p: Rownum + m - 1 + p, ...
Colnum - q: Colnum + n - 1 + q));
My understanding, is that fun is a function handle that performs an operation on the block of data. See blokproc fun input arg for details. And yet you are using a matrix instead? Please add some context surrounding this code.
采纳的回答
更多回答(1 个)
Sean de Wolski
2014-9-26
0 个投票
Why don't you want to use blkproc (or blockproc)?
You could always use two for-loops to do this.
类别
在 帮助中心 和 File Exchange 中查找有关 Scripts 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!