How to save multiple images using imwrite in matlab ?

조회 수: 9 (최근 30일)
Armylia Dewi
Armylia Dewi 2022년 5월 31일
댓글: Armylia Dewi 2022년 5월 31일
How to save multiple images gray format .jpeg using imwrite in matlab ?
image_folder ='E:\gambar_eror'
filenames = dir (fullfile(image_folder,'*.jpeg'))
total_images = numel(filenames);
%training=[];
for n= 1:total_images;
f= fullfile(image_folder, filenames(n).name);
disp(f);
our_images= imread (f);
size (our_images);
gray=rgb2gray(our_images);
end

채택된 답변

KSSV
KSSV 2022년 5월 31일
편집: KSSV 2022년 5월 31일
image_folder ='E:\gambar_eror'
filenames = dir (fullfile(image_folder,'*.jpeg'))
total_images = numel(filenames);
%training=[];
for n= 1:total_images;
f= fullfile(image_folder, filenames(n).name);
disp(f);
[FILEPATH,NAME,EXT] = fileparts(f) ;
our_image= imread (f);
gray=rgb2gray(our_image);
filename = [image_folder,'\',NAME,'_gray',EXT] ;
imwrite(gray,filename)
end
  댓글 수: 5
KSSV
KSSV 2022년 5월 31일
You can read the documentation. Read about those functions.
fileparts: This gives, the path of the file, name of the file and extension of the file.
[]: This will join the strings. This line, creates the image name.
Armylia Dewi
Armylia Dewi 2022년 5월 31일
Okay. Thankyou so much for the answer and discussion.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by