I reshaped the image elements 256*256 into 16*1 linear array using the following code. There is 16 linear arrays in a variable (ex:tv). Now i need to retrieve the first array of variable (tv). ie, i need tv(1), tv(2)... tv(16). Please say the code.
Afficher commentaires plus anciens
I=imread('cameraman.tif'); I=double(I); Im=size(I); %find the size of the image [nr nc nd]=size(I); % Divide into blocks disp(nr); disp(nc);
% Divide into blocks m=64; n=64; row=1; column=1; i=1; j=1; sum=0; count=0; nnn=1; er1=0; for i=1:4:16
for j=1:4:16
block=I(i:i+3,j:j+3);
disp(block)
T = rand(16,16); % Size of all your vectors, concatenated
Tr = reshape(T,[4,4,16])
%convert 4X4 into 16X1 column vector
tv=reshape(block,16,1);
disp(tv)
count=count+1
column=column+4;
end
row=row+4;
end
Réponses (1)
Image Analyst
le 20 Fév 2016
I didn't delve into your code but I see you creating a 16x1 vector in it:
tv=reshape(block,16,1);
so what's the problem?
4 commentaires
divya taru
le 20 Fév 2016
Image Analyst
le 20 Fév 2016
Just make it a 2D array with indexing
tv = zeros(16, length(1:4:16)); % One column for each possible value of j
column = 1;
for j=1:4:16
% Code......
tv(:, column) = reshape(T,[4,4,16]);
column = column + 1;
% more code....
end
Now each one of those tv you have will be saved into one column instead of being overwritten during the next iteration.
divya taru
le 21 Fév 2016
divya taru
le 21 Fév 2016
Catégories
En savoir plus sur Vehicle Dynamics Blockset 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!