Borrar filtros
Borrar filtros

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.

1 visualización (últimos 30 días)
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

Respuestas (1)

Image Analyst
Image Analyst el 20 de Feb. de 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 comentarios
divya taru
divya taru el 21 de Feb. de 2016
thank you sir for your reply again. i used your code. but i am having the following error sir. please guide me. because i am very new to matlab. sorry for the disturbance. please answer me sir. the error is: ??? Error using ==> reshape To RESHAPE the number of elements must not change.
Error in ==> array4 at 11 tv(:, column) = reshape(I,[4,4,16]);
divya taru
divya taru el 21 de Feb. de 2016
thank you sir. your answer is correct. i am so happy.. thank you so much sir.

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by