How can i reshape a dataset maintaining the correct order?

2 views (last 30 days)
Hello, i need some help. I got a dataset composed by 701 images. They are RGB and i reduced them in 20x20. I created a 4-d array 20x20x3x701. Now the problem is that i need to insert this matrix in an lsh algorithm, but it requires a 2 dimensions matrix. So i tried to reshape and obtained a 1200x701, but the problem is that reshape can't maintain the order of the original matrix and the images are wrong, and the lsh algorithm execute in the wrong way. What can i do? The code is the following:
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);
  2 Comments
Francesco Morano
Francesco Morano on 20 Aug 2017
Yes i'm trying to implement the vhls algorithm. But if i run it that way i got problems with the content of the buckets, i supposed the problem is how i reshape the matrix

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 20 Aug 2017
If it is the above-linked vLSH code that you are using, then the reshape() you are doing is correct. The documentation for lshConstruct() says
% X: [D x N] matrix containing N columns of D-dimensional data
which in your case would be 1200 dimensional data, 701 different samples, which would be appropriate. The exact order of that each image got reshaped into would not matter, as long as it is a consistent order, as the routine is going to treat each of the 1200 points (per sample) as independent of the other points in the same sample.
  1 Comment
Francesco Morano
Francesco Morano on 20 Aug 2017
Yes it's the vlsh. The problem is that if i try to run the code exactly how is written in my question it won't work properly. It does run and all, but the buckets and the images are completely wrong comparing them to the dataset groundtruth. So i think that the problem is how i do the reshape, or i don't know what am i doing wrong. Thank you for the answer anyway

Sign in to comment.

Categories

Find more on Deep Learning Toolbox in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!