Error using reshape syntax
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Wildan
el 4 de Abr. de 2019
Respondida: Walter Roberson
el 4 de Abr. de 2019
I'm new in Matlab. I want to reduce the size of the vector magnitude to smaller so that later I can use it for the KNN classification. So I try use 'reshape' to reduce the vector column size to 100
Error using reshape
To RESHAPE the number of elements must not change.
Error in Gabor2 (line 25)
rs = reshape(mag,1,250*250);
Here is my code..
%Pelatihan (Training)
folder_citra = 'data latih';
nama_citra = dir(fullfile(folder_citra, '*.jpg'));
jumlah_citra = numel(nama_citra);
for n = 1:jumlah_citra
% Membaca citra
Img = imread(fullfile(folder_citra, nama_citra(n).name));
% Resize citra
Img_resize = imresize(Img, [250 250]);
% Konversi citra RGB menjadi Grayscale
Img_gray = rgb2gray(Img_resize);
% Ekstraksi Ciri Tekstur Filter Gabor
wavelength = 4;
orientation = 90;
[mag,phase] = imgaborfilt(gray, wavelength, orientation);
rs = reshape(mag,1,250*250);
mag_kecil = imresize(mag,1/25);
training = reshape(mag_kecil,1,100);
end
0 comentarios
Respuesta aceptada
Walter Roberson
el 4 de Abr. de 2019
reshape() can never be used to make an array smaller. It can only be used to change how a block of memory is indexed, with the number of elements having to stay the same.
You might be able to use resample() for your purposes.
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Resizing and Reshaping Matrices en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!