How to save image , in the image type it is being fetched.

2 vues (au cours des 30 derniers jours)
ankita
ankita le 3 Mai 2013
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!!!

Réponses (1)

Image Analyst
Image Analyst le 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 commentaires
ankita
ankita le 3 Mai 2013
thank you sir ...... will try and report back to you
Image Analyst
Image Analyst le 3 Mai 2013
Modifié(e) : Image Analyst le 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);

Connectez-vous pour commenter.

Catégories

En savoir plus sur Image Processing Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by