0
votes

I'm trying yo implement vlsh with the California ND Datastet, wich is composed by 701 photos. 10 subject wrote down in a txt file which photos are near duplicate for them, and we have also correlation matrix. The images are RGB and i reduced them in 20x20. I created a 4-d array 20x20x3x701. So i tried to reshape and obtained a 1200x701 matrix, but the problem is that reshape can't maintain the order of the original matrix. I tried to search online and most of suggestion is to use "Permute", but it seems to me that doesn't fit my situation.

I can post the matlab code:

`
path='C:\Users\franc\Desktop\stage\californiaND\prova*.jpg';
path2='C:\Users\franc\Desktop\stage\californiaND\prova';
d=dir(path);
a=[];
for m=1:length(d)
  a=cat(4,a,imread(strcat(path2,d(m).name)));
end
r=reshape(a,[],701);
r=double(r);
L = lshConstruct( r, 10,4);`
1
What is the order you'd want your data to be with respect to the input?BillBokeey
I want that every matrix of the same image is concatenated. So one matrix of 1200 pixel, for 701 images.FireFox1616
Yes, but in what order should the 2nd and 3rd dimensions be collapsed into the 1st dimension? Reshape doesn't randomise the order...Wolfie
It looks like the problem is that you crate a 4D matrix.... just create what you want from the start, not from the 4D matrixAnder Biguri
@AnderBiguri How can i do it? i have 2-d matrix in 3 channel. I have to reshape anyway, or at least i think. Can you help me? thank you anywayFireFox1616

1 Answers

0
votes

I am assuming you need the 1D vector in RGBRGB format, as otherwise the solution would be trivial ( just (:)).

Assuming imread is reading 20x20x3 images one by one, this is how you directly make your 2D matrix:

for m=1:length(d) % this is 701, right?
  im=imread(strcat(path2,d(m).name));
  im=permute(im,[3 1 2]);
  a=cat(2,im(:));
end