Filter löschen
Filter löschen

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 convert mean values to linear array again. please send suitable code. please don't ignore it. help .

4 Ansichten (letzte 30 Tage)
for i=1:4:16
for j=1:4:16
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
nn=8;
for count=1:16
sum1=sum1+tv(:,count);
if count==nn*nnn
cv(:,r)=sum1/8;
sum1=0;
nnn=nnn+1;
r=r+1;
end
end
  2 Kommentare
Star Strider
Star Strider am 27 Mär. 2016
You cannot un-fry that egg.
Calculating a mean — even with the standard deviation — requires that you throw away information that you can never again retrieve. The best you can hope for is a vector the same size as the original, every element being the mean.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 27 Mär. 2016
Your code does not calculate mean values -- not unless nnn happens to equal 1, and for some odd reason you only want the first 8 values to be included even though your loop goes to 16.
  9 Kommentare
Image Analyst
Image Analyst am 3 Apr. 2016
If you're in a loop, just have the upper limit be 8 and it will only do 8
for blockNumber = 1 : 8
% code
stdDev(blockNumber) = std(............
end

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Image Analyst
Image Analyst am 27 Mär. 2016
Exactly what values are you hoping to have in this second linear array? If you want the first ones, simply use the original values
secondLinearArray = firstLinearArray;
If you want the means, then use repmat, imresize, or other approaches to create it from your means, for example
secondLinearArray = theMean * ones(size(firstLinearArray));

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by