i had converted image into blocks. I converted blocks to linear array. Next i calculated mean values for first 8 arrays as given below. now i want to calculate values by using the formula: sum(linear array(:,1)-mean(:,1)).^2. please send code.
Show older comments
for i=1:4:nr-3
for j=1:4:nc-3
block=I(i:i+3,j:j+3);
%convert 4X4 into 16X1 column vector
tv(:,col)=reshape(block,16,1);
col=col+1;
count=count+1;
column=column+4;
end
row=row+4;
end
%find mean of 8 arrays
me=1;
nn=8;
nnn=1;
for count=1:nr+nc
cv(:,r) = mean(tv(:,me:nn*nnn), 2);
r=r+1;
nnn=nnn+1;
me=me+8;
end
2 Comments
Walter Roberson
on 5 Apr 2016
Which variable corresponds to the "linear array" of your formula?
sri raj
on 5 Apr 2016
Accepted Answer
More Answers (1)
Kuifeng
on 5 Apr 2016
%After you have the array, you can try the function rms
error = (rms(array))^2; %as descripted, sometimes rms is directly used as error
4 Comments
Walter Roberson
on 5 Apr 2016
It is recommended that you do not use "error" as the name of a variable, as error() is a critical MATLAB function.
sri raj
on 6 Apr 2016
Walter Roberson
on 6 Apr 2016
After the code you show there in your Question, add
values = sum( (tv(:,1) - cv(:,1)).^2 );
sri raj
on 6 Apr 2016
Categories
Find more on Neighborhood and Block Processing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!