I want to resize the images of whole database and then replace it with the same images. The problem is how to create or access the database for images.
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ahmer Shahid
am 12 Nov. 2018
Kommentiert: Ahmer Shahid
am 13 Mär. 2019
Here is the code I tried for resizing and replacing ...
Kindly help me thanks.
Database = imageSet('Palm','recursive');
for i=1:size(training,2)
for j = 1:training(i).Count
image=read(Database(i),j);
image=imresize(image,0.568);
Database((i),j)=image; %for replacing the same image
end
end
2 Kommentare
KSSV
am 12 Nov. 2018
YOu have to save the image in a folder of your choice, using imwrite. And then in that folder use imageSet.
Akzeptierte Antwort
Walter Roberson
am 12 Nov. 2018
Database = imageSet('Palm','recursive');
for i=1:size(training,2)
Filenames = Database(i).Locations;
for j = 1:training(i).Count
image=read(Database(i),j);
image=imresize(image,0.568);
imwrite(image, Filenames{j}) ;
end
end
This code is not recommended. Every time you run it, it will shrink the files by the same factor. If there is a problem part way through such as a file permissions problem then you would need to move the files that had already been processed to a different directory or else they would get shrunken again.
It would be safer if you specified an output size instead of a scaling factor: then it would not matter how many times you ran the code on the same file.
3 Kommentare
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Convert Image Type finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!