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!