Borrar filtros
Borrar filtros

i want to write 25 sample image after treatment and save in 10 folders

2 visualizaciones (últimos 30 días)
NSamples=25; NClasses=9;
for i =1:T
for s=1:NSamples
for c=0:NClasses
%traitement---------------------------------------------------------
img=imread([P I(i).name]);
R = imresize (img,[100 100]);
G = rgb2gray(R);
BW1 = edge(G,'sobel');
classfile =mkdir( sprintf('c%d',c));
imgfile = sprintf('%d.png',s);
fulfile = fullfile(classfile,imgfile);
dir_file = dir(fulfile)
imwrite(BW1,dir_file);
end
end
end
  2 comentarios
Rik
Rik el 30 de Mzo. de 2018
And what is your question/error?
zakaria siad
zakaria siad el 31 de Mzo. de 2018
An unknown error occurred in FULLFILE while constructing the file specification.
Error in Creat_Files_Class(line 21) fulfile = fullfile(classfile,imgfile);
Caused by: Error using horzcat The following error occurred converting from logical to char: Error using char Conversion to char from logical is not possible.

Iniciar sesión para comentar.

Respuesta aceptada

Rik
Rik el 31 de Mzo. de 2018
In the code below I fixed some issues with your code. Compare the lines I changed and read the documentation for those functions to better understand their input and output. Especially the output for mkdir and dir.
for c=0:NClasses
classfoldername=sprintf('c%d',c);
if ~exist(classfoldername,'dir')
mkdir(classfoldername);
end
end
for i =1:T
for s=1:NSamples
for c=0:NClasses
%traitement---------------------------------------------------------
img=imread([P I(i).name]);
R = imresize (img,[100 100]);
G = rgb2gray(R);
BW1 = edge(G,'sobel');
classfoldername=sprintf('c%d',c);
imgfile = sprintf('%d.png',s);
fulfile = fullfile(classfoldername,imgfile);
imwrite(BW1,fulfile);
end
end
end
  2 comentarios
zakaria siad
zakaria siad el 31 de Mzo. de 2018
I modified my code but i have problem his create same image into all of folder class
NSamples=25; NClasses=9;
for c=0:NClasses
classfoldername=sprintf('N%d',c);
if ~exist(classfoldername,'dir')
mkdir(classfoldername);
end
end
for i =1:250
for s=0:NSamples
imgfile = sprintf('%d.png',s);
for c=0:NClasses
classfoldername=sprintf('N%d',c);
%traitement---------------------------------------------------------
img=imread([P I(i).name]);
R = imresize (img,[100 100]);
G = rgb2gray(R);
G1 = YCrCb(R);
%BW1 = HOG(R);
BW1 = edge(G1,'sobel');
%-------------------------------------------------------------------
fulfile =fullfile(classfoldername,imgfile);
imwrite(BW1,fulfile);
end
end
end

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Convert Image Type en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by