フィルターのクリア

Functions renaming answers from variable, also saving cropped image as file

1 回表示 (過去 30 日間)
victor law
victor law 2017 年 2 月 22 日
回答済み: Jan 2017 年 2 月 22 日
Hi there, I have a simple question that I couldn't find an answer to.
I wrote a simple function for cropping, where I am cropping multiple images at the same size and dimensions as such:
function [I4] = icrop (Image)
I4 = imcrop(Image,[2000 1185 776 760]);
imshow(I4)
end
I want to be able to automatically saved the cropped image with a suffix after the variable name. So, if I put in A.jpg, I want the cropped file to be A1.jpg
Any suggestions? Thanks

採用された回答

Jan
Jan 2017 年 2 月 22 日
filename = 'A.jpg';
number = 1;
[fPath, fName, fExt] = fileparts(filename);
newfilename = fullfile(fPath, sprintf('%s%d%s', fName, number, fExt));
Then use imwrite with the new file name.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by