Borrar filtros
Borrar filtros

i need to save images with different file names in seperate folders

3 visualizaciones (últimos 30 días)
lear all; close all;
inputfilename ='back_5.jpg';
img = imread(inputfilename);
dim = size(img);
width = dim(2);height = dim(1);
gfrgb = imfilter(img, fspecial('gaussian', 3, 3), 'symmetric', 'conv');
cform = makecform('srgb2lab', 'AdaptedWhitePoint', whitepoint('d65'));
lab = applycform(gfrgb,cform);
l = double(lab(:,:,1));
a = double(lab(:,:,2));
b = double(lab(:,:,3));
li = cumsum(cumsum(l,2));
ai = cumsum(cumsum(a,2));
bi = cumsum(cumsum(b,2));
sm = zeros(height, width);
sm2 = zeros(height, width);
for j = 1:height
yo = min(j, height-j);
y1 = max(1,j-yo); y2 = min(j+yo,height);
for k = 1:width
xo = min(k,width-k);
x1 = max(1,k-xo); x2 = min(k+xo,width);
invarea = 1.0/((y2-y1+1)*(x2-x1+1));
lm = iisum(li,x1,y1,x2,y2)*invarea;
am = iisum(ai,x1,y1,x2,y2)*invarea;
bm = iisum(bi,x1,y1,x2,y2)*invarea;
%---------------------------------------------------------
% Compute the saliency map
%---------------------------------------------------------
sm(j,k) = (l(j,k)-lm).^2 + (a(j,k)-am).^2 + (b(j,k)-bm).^2;
end
end
%figure()
%imshow(sm,[]);
img = (sm-min(sm(:)))/(max(sm(:))-min(sm(:)));
imwrite(img,'back_msss.jpg')
now i have six faces like top, front ,bottom, back,left, and right
i need to save images in different folders with image names as top.png, right,png
  1 comentario
Jan
Jan el 16 de Feb. de 2021
As far as I understand, the posted code has no relation to the actual problem.
What is the problem with saving the images to different folders?
imwrite(img, 'D:\Your\Folder\top.jpg')

Iniciar sesión para comentar.

Respuestas (1)

Bjorn Gustavsson
Bjorn Gustavsson el 16 de Feb. de 2021
You can do this, as Jan hinted at, something like this:
faces = 1:6
face_names = {'top','bottom','front','back','left','right'}; % your image-names
folders2savein = {'run-01','run-02'}
for iRuns = 1:2 % or however many sets you might need
for iFaces = 1:numel(faces)
% Here's where you plug in your processing, for each face and whatever you need
img_type = 'msss'; % In case you have multiple result-files to save
savename = fullfile(folders2savein{iRuns},...
sprintf('%s_%s.jpg',face_names{iFaces},img_type));
imwrite(img,savename)
end
end
By using fullfile your code will become robust enough to run in different operating systems, and that's one worry less, by generating the file-name this way where you put toghether different parts of the name you're preparing to use this for cases where you save a number of different outputs from the same run and face. Doing it this way will make batch-processing much cleaner.
HTH

Categorías

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

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by