I'm working on an image and I divided into non overlapping blocks, what I want to do next is to apply some changes on every two adjacent chunks of the same blocks. For example, I have a block B1 and I divided it into B11 and B12.
The objective here is to apply SVD on B11 and B12 and compare their singular values: S11(2,2)
and S12(2,2)
and so on for every other blocks. But I don't know how to work on every two sub-blocks adjacent I only can apply SVD for blocks Bi.
It seems like I need a loop for
to process every two sub-blocks right or can the function mat2tiles
do this?
This is an example explaining what I'm saying.
I finally found the way how to get my objective, and I'm sharing in case somebody needed too:
%First this a function that help me to divide my image into non overlapping block
function B=Block(IM,p,q)
p=p %% number of rows
q=q %% number of cols
[m,n] = size(IM);
IJ = zeros(p,q);
z = 1;
for m1 = 1:m/p
for n1 = 1:n/q
if m1*p <= m;
if n1*q <= n;
for i = (m1-1)*p+1:m1*p
for j = (n1-1)*q+1:n1*q
IJ(i-(m1-1)*p,j-(n1-1)*q) = IM(i,j);
if (i-(m1-1)*p)==p&&(j-(n1-1)*q)==q;
OUT = IJ;
B{1,z} = OUT;
z = z+1;
end
end
end
end
end
end
end
Now I will divide each blocks into sub-blocks and apply SVD
Block_Num = (m*n)/(p*q) % To get how many blocks we have
fun= @svd % the function we use is SVD
for i=1:Block_Num
sv=blkproc(B{i},[4 4],fun) % in my case I wanted to apply SVD
of every sub-block of 4*4
end
And this get the job done. hope it will be useful for you too
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.