Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
I get only one image in my directory while while executing the below code. Please help to come out from this.
조회 수: 1 (최근 30일)
이전 댓글 표시
srcFile =dir('C:\Users\Dell\Desktop\python tutorials\matlab\myfiles\matlab\myfiles\Dataset 2\*.tif');
for s=1:length(srcFile)
filename=strcat('C:\Users\Dell\Desktop\python tutorials\matlab\myfiles\matlab\myfiles\Dataset 2\',srcFile(s).name);
a=imread(filename);
b=double(a(:));
lem=225;
minim=min(b(:));
maxim=max(b(:));
[m,n]=size(a);
x=zeros(1,225);
q=zeros(1,225);
w=zeros(1,225);
r=zeros(1,225);
E=zeros(1,225);
u=zeros(1,225);
for i=1:m
for j=1:n
g=a(i,j);
x(i,j)=((g-minim)./(maxim-minim));
q(i,j)=((1+lem)*x(i,j))./(1+lem*x(i,j));
w(i,j)=(1-x(i,j))./(1+(3*lem*x(i,j))+(lem^2*x(i,j))+x(i,j));
r(i,j)=1-q(i,j)-w(i,j);
E(i,j)=(1./x(i,j))*(sum(sum(r(i,j)*exp(1-r(i,j)))));
u(i,j)=maxim*(E(i,j)+lem);
t=q(i,j)^1.25;
for y=0:0.1:1
if t<=0.5
p(i,j)=2*(t^2);
else
p(i,j)=1-2*((1-t)^2);
end
end
end
mkdir('myimages')
figure, imshow(p);
imwrite(p,'myimages/testfile.tif','tif')
end
end
댓글 수: 0
답변 (1개)
Walter Roberson
2020년 6월 7일
imwrite(p,'myimages/testfile.tif','tif')
You are always writing to the same output location. I suggest:
[~, basename] = fileparts(srcFile(s).name);
outputname = fullfile('myimages', [basename '.tif'], 'tif');
This will output into the same file name as the input, except in the myimages directory.
srcFile =dir('C:\Users\Dell\Desktop\python tutorials\matlab\myfiles\matlab\myfiles\Dataset 2\*.tif');
I recommend that you learn to use fullfile() such as
projectdir = 'C:\Users\Dell\Desktop\python tutorials\matlab\myfiles\matlab\myfiles\Dataset 2';
srcFile = dir( fullfile(projectdir, '*.tif') );
...
filename = fullfile(projectdir, srcFile(s).name);
댓글 수: 0
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!