save image in a folder with original name

4 ビュー (過去 30 日間)
armeen
armeen 2013 年 3 月 31 日
コメント済み: Stephen23 2017 年 12 月 17 日
i use to resize the image and then save it back into with the original name. for example the first image name is signature3, then after resize the image i want to save it into the bmp image with the name signature3. i am going to process many image with different name..
J=imread('Signature3.jpg');
I=im2double(J);
figure(1),imshow(I);
title('original')
I2=imresize(I,[128 ,128]);
figure(2),imshow(I2);
data=I2;
pathname = 'D:\matlab\trying\data\';
imwrite(data,[pathname,('J'),'.bmp']);
the result of this code just name the file with j. can anyone help me. i am new in matlab.

回答 (2 件)

Image Analyst
Image Analyst 2013 年 3 月 31 日
I prefer to use sprintf() to build the base filename, and then use fullfile() to construct the full file name from the folder and base file name. You're putting your images in the current folder, same as your m-file scripts. The current folder is pwd.
Also, please use better variable names than I (which looks a lot like 1 and l) and J. Use longer, more descriptive names that will help explain what you are trying to do. Also make sure you put comments into your code.

Salma Hassan
Salma Hassan 2017 年 12 月 17 日
https://stackoverflow.com/questions/32430643/saving-with-original-names-in-matlab
  1 件のコメント
Stephen23
Stephen23 2017 年 12 月 17 日
Note that using fullfile is preferred over string concatenation.

サインインしてコメントする。

カテゴリ

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