How do I store a series of 5*5 arrays into a multidimensional array?
Mostra commenti meno recenti
Hi people, I am new to this forum as well as MATLAB. As of now I'm working on copy-move forgery and i intend to do a 5*5 pixel comparison within the image. I want to store the values of every 5*5 array within the image into a multidimensional array but i'm not too sure how. Below is what i've come up with so far:
clear;
clf;
A=imread('file1.png');
Agray=rgb2gray(A);
[ar,ac]=size(Agray);
v1=5;
v2=5;
r=ar-v1+1;
c=ac-v2+1;
noOfArrays=r*c;
for i=1:r
for j=1:c
k(:,:,noOfArrays)=(Agray(i:i+4,j:j+4));
end
end
k
In which k is my supposed multidimensional array. Any help would be appreciated thank you :)
Risposta accettata
Più risposte (2)
Image Analyst
il 11 Feb 2013
0 voti
How about using mat2cell()?
the cyclist
il 11 Feb 2013
Modificato: the cyclist
il 11 Feb 2013
In the line
k(:,:,noOfArrays)=(Agray(i:i+4,j:j+4));
you are alway writing to the same "plane" along the 3rd dimension of k, because noOfArrays is a constant. I expect you actually wanted to write to different planes, varying with i and j.
The simplest way to do that is probably to just have a counter for each pass through the loop.
Categorie
Scopri di più su Resizing and Reshaping Matrices in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!