Having issue with imwrite. I'm attaching my code and error below.
1 view (last 30 days)
Show older comments
Shah Isha Redohy
on 24 Jul 2021
Commented: Walter Roberson
on 28 Jul 2021
% Apply normalization to images
nim=minMaxNormalize(oim);
% Save the image according to five fold set in respective tumor folder. After processing the whole dataset, take set1 as testing (testDS1)
%and remainig four sets as traing (trainingDS1). apply similar method for set2, set3, set4, and set5
% Set1
if cvind(i)==1
if imlab==1
outputFileName = fullfile('/Users/ragib/Desktop/Thesis/MatlabCodes/set1/meningioma/', [num2str(i) '.jpg']);
imwrite(nim, outputFileName);
elseif imlab==2
outputFileName = fullfile('/Users/ragib/Desktop/Thesis/MatlabCodes/set1/glioma/', [num2str(i) '.jpg']);
imwrite(nim, outputFileName);
elseif imlab==3
outputFileName = fullfile('/Users/ragib/Desktop/Thesis/MatlabCodes/set1/pituitary/', [num2str(i) '.jpg']);
imwrite(nim, outputFileName);
else
fprintf('No label found');
end
end
0 Comments
Accepted Answer
Image Analyst
on 24 Jul 2021
My guesses are either that the file is probably open and locked in some other program when you try to blast over it, and so it won't let you.
By the way, what is the value of i? You should not use i as a variable since it's the imaginary variable. Use k or index or something else.
Also, do not use JPG format if you're doing image analysis. Use PNG instead. PNG is lossless compression and is pretty much the de facto standard these days while (the hated) JPG often gives bad compression artifacts. There will be no change to image values in a round trip save/recall using PNG like there will be with JPG.
7 Comments
Walter Roberson
on 28 Jul 2021
You marked that you are using R2021a, but line 51 of fullfile() for R2021a cannot generate any error. Line 51 of fullfile for R2021a is
containsCellOrStringInput = false;
Either you are using a third-party fullfile(), or else you are using R2016b, which is a release in which string() datatype was first released but was not yet available in all functions (or you copied fullfile.m from an old release.)
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!