MATLAB Answers

Having issue with imwrite. I'm attaching my code and error below.

조회 수: 1(최근 30일)
Shah Isha Redohy
Shah Isha Redohy 2021년 7월 24일
댓글: Walter Roberson 2021년 7월 28일
% 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

채택된 답변

Image Analyst
Image Analyst 2021년 7월 24일
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
Walter Roberson
Walter Roberson 2021년 7월 28일
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.)

댓글을 달려면 로그인하십시오.

추가 답변(0개)

범주

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by