Problem of imwrite permission
Afficher commentaires plus anciens
Hi!, recently I have been troubled with getting cropped picture for given input. What I expected are from input PolyU_0034_F.bmp will become crop_0034_F.jpg for example the code are:
file = dir('C:\Program Files\MATLAB\R2017a\bin\FYP\PolyU\*.bmp');
input = {file.name}';
c = input;
for i = 1:length(file)
fname = strcat('C:\Program Files\MATLAB\R2017a\bin\FYP\PolyU\',file(i).name);
a = imread(fname);
b = imcrop(a,[140,65,150,150]);
c{i} = strrep(fname, 'PolyU', 'crop');
d = c{i};
imwrite(b,strrep(d, '.bmp', '.jpg'));
imshow(b);
end
However, The error given out are
Error using imwrite (line 454)
Unable to open file "C:\Program Files\MATLAB\R2017a\bin\FYP\crop\crop_037_F_10.jpg" for writing. You might not have write
permission.
Error in corp1 (line 24)
imwrite(b,strrep(d, '.bmp', '.jpg'));
This is weird for 2 reasons. First, the file direction on error is different folder (crop) even though I use folder of (PolyU). Second, This code was done on different folder(FYP) and execute very well. Are same code in different folder need to readjust so that it could work again?
Thanks for your time!
2 commentaires
Walter Roberson
le 19 Mar 2018
"First, the file direction on error is different folder (crop) even though I use folder of (PolyU)."
No you do not. You strrep(fname, 'PolyU, 'crop') to replace PolyU with crop, and then you use that as the destination for imwrite, so it is expected that you write to the crop directory.
Muhammad Bariq Azmi
le 19 Mar 2018
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Text Detection and Recognition dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!