problems to open images after I have saved it in a folder

5 Ansichten (letzte 30 Tage)
Maria
Maria am 22 Jan. 2015
Kommentiert: Maria am 23 Jan. 2015
Hello, I have a problem with my work. My program can read some images from a specific folder, process and study them (differents features of them). When I have processed these images, I would save them in a different folder than the original. I did it, but when I want to open these (with Paint or another), it's impossible. I have been searching, but I can't find a good solution and neither my fault. This is my code:
function mostrar2
%load my processed images (for the moment are matrix)
load archivoimagenesfinales
[stat,struc] = fileattrib;
PathCurrent = struc.Name;
FolderName = ['imagenes'];
PathFolder = [PathCurrent '/RESULTADOS DE ESTUDIOS DE IMAGENES/' FolderName];
mkdir([PathCurrent '/RESULTADOS DE ESTUDIOS DE IMAGENES/'], FolderName);
for k=1:length(grupoimage)
matriz=grupoimage(k).im;
imagennumero=sprintf('imagentratada%d.bmp',k);
%save as image in the usual folder
imwrite(matriz,imagennumero);
save([PathFolder imagennumero])
end
end
Thanks in advance

Akzeptierte Antwort

Image Analyst
Image Analyst am 22 Jan. 2015
Why is the save() function call in there??? Can you attach one of the files that it made?
  3 Kommentare
Image Analyst
Image Analyst am 23 Jan. 2015
Try this:
% Get the name of the file that the user wants to save.
% Note, if you're saving an image you can use imsave() instead of uiputfile().
startingFolder = userpath
defaultFileName = fullfile(startingFolder, '*.*');
[baseFileName, folder] = uiputfile(defaultFileName, 'Specify a file');
if baseFileName == 0
% User clicked the Cancel button.
return;
end
fullFileName = fullfile(folder, baseFileName)
imwrite(matriz, fullFileName);
Maria
Maria am 23 Jan. 2015
Thanks for the help! Finally, I made a...mix?, because I don't want "to have to choose the folder" but saved a number of images on this directly, or by default, I don't know how to say that exactly, but I don't want a window open for every image and have to select folder, name, ec... That what I do and it works!
function pcdi
load archivomatricesfinales
grupoimage; %im
n=length(grupoimage);
[stat,struc] = fileattrib;
PathCurrent = struc.Name;
%crear las rutas (Path) para carpetas y archivos
FolderName = ['imagenes'];
PathFolder = [PathCurrent '/RESULTADOS DE ESTUDIOS DE IMAGENES/' FolderName];
mkdir([PathCurrent '/RESULTADOS DE ESTUDIOS DE IMAGENES/'], FolderName);
for k=1:n
matriz=grupoimage(k).im;
imagennumero=sprintf('imagentratada%d.bmp',k);
fullFileName=fullfile(PathFolder,imagennumero);
imwrite(matriz,fullFileName);
end
Again, thanks a lot!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Convert Image Type finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by