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

2 Ansichten (letzte 30 Tage)
ankita
ankita am 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!!!

Antworten (1)

Image Analyst
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
ankita
ankita am 3 Mai 2013
thank you sir ...... will try and report back to you
Image Analyst
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);

Melden Sie sich an, um zu kommentieren.

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!

Translated by