How to save image , in the image type it is being fetched.
2 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Image Analyst
2013 年 5 月 3 日
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 件のコメント
Image Analyst
2013 年 5 月 3 日
編集済み: Image Analyst
2013 年 5 月 3 日
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);
参考
カテゴリ
Help Center および File Exchange で Image Processing Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!