How to save image , in the image type it is being fetched.
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
In my work, I have provided a GUI interface to select a image to be watermarked and after watermarking process i have to save the image,
Now the issue is if I save it using imwrite then the image type will be fixed like either .BMP or .JPG
how to provide, the choice that user can select image format and image is saved in that same type.
I am not getting, how the code will be done
Plz help!!!
0 Kommentare
Antworten (1)
Image Analyst
am 3 Mai 2013
Use menu(), then depending on which button was selected, use sprintf() to write the proper extension into the filename. Let me know if you can't figure it out and I can give a demo.
2 Kommentare
Image Analyst
am 3 Mai 2013
Bearbeitet: Image Analyst
am 3 Mai 2013
If you're having trouble, here is the code:
folder = 'C:/Users/ankita/Documents';
baseFileName = 'myOutputImage';
button = menu('Use which format for the image file?', 'PNG', 'BMP', 'TIF', 'JPG');
if button == 1
extension = 'PNG';
elseif button == 2
extension = 'BMP';
elseif button == 3
extension = 'TIF';
else
extension = 'JPG';
end
% Append extension to the base file name.
baseFileName = sprintf('%s.%s', baseFileName, extension)
% Prepend the folder to get the full file name.
fullFileName = fullfile(folder, baseFileName)
imwrite(imageArray, fullFileName);
Siehe auch
Kategorien
Mehr zu Image Processing Toolbox 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!