I want a matrix to be represented in the form of an array

3 vues (au cours des 30 derniers jours)
akash bais
akash bais le 22 Déc 2016
Modifié(e) : Roger Stafford le 22 Déc 2016
I want a image matrix 512x512 to be represented in the array form or simply in a straight line while scanning the matrix in inverse S way. I have attached an image to make it clear
  2 commentaires
David Barry
David Barry le 22 Déc 2016
There is no image attached.
akash bais
akash bais le 22 Déc 2016

Connectez-vous pour commenter.

Réponse acceptée

Roger Stafford
Roger Stafford le 22 Déc 2016
Modifié(e) : Roger Stafford le 22 Déc 2016
Here are the “Pixel Scan” and “Rearrange” operations:
% Let M be the m by n image matrix
% Pixel Scan:
M = M.';
M(:,2:2:end) = flipud(M(:,2:2:end)); % Flip even columns
M = M(:); % The result is a column vector
Then perform the “Difference computation”, the “Histogram shifting” and the “Embedding” on M.
% Now M is still a column vector
% Rearrange:
M = reshape(M,n,m); % <-- Note the reversal of sizes here
M(:,2:2:end) = flipud(M(:,2:2:end)); % Flip even columns
M = M.';
% M is again an m by n image matrix.
The "Difference computation" is an obvious use of the ‘diff’ function. I have no idea how to do the “Histogram shifting” or the “Embedding”.

Plus de réponses (1)

David Barry
David Barry le 22 Déc 2016
a = rand(512, 512);
a = a(:);

Community Treasure Hunt

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

Start Hunting!

Translated by