How to do this without blkproc function..?
Afficher commentaires plus anciens
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 commentaires
Geoff Hayes
le 26 Sep 2014
Modifié(e) : Geoff Hayes
le 26 Sep 2014
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
le 26 Sep 2014
Geoff Hayes
le 26 Sep 2014
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.
Réponse acceptée
Plus de réponses (1)
Sean de Wolski
le 26 Sep 2014
0 votes
Why don't you want to use blkproc (or blockproc)?
You could always use two for-loops to do this.
Catégories
En savoir plus sur Scripts dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!