how to read numbers of images and save the change

3 次查看(过去 30 天)
i need to read a number of images (signature) then conert them to grayscale after that apply mediam filter then binarization the images and berform the morphological operation the following code doesn't contain an error but not implemented as i need
Directory='C:\Users\XXX\Desktop\Imges';
Imgs = dir(Directory);
for j=1:length(Imgs)
thisname = Imgs(j).name;
thisfile = fullfile(Directory, thisname);
try
Img = imread(thisfile); % try to read image
Im = rgb2gray(Img);
If2 = medfilt2(Im,[3 3]);
Bim=im2bw(If2);
I = bwmorph(Bim,'thicken',Inf);
figure
imshow(I)
title(thisname);
baseFileName= thisname;
fullFileName = fullfile('C:\Users\XXX\Desktop\Imges',baseFileName);
imwrite( I,fullFileName);
catch
end
end

采纳的回答

KALYAN ACHARJYA
KALYAN ACHARJYA 2019-7-6
编辑:KALYAN ACHARJYA 2019-7-6
Images=dir('C:\Complete_path\hand_2101\*.png');
%.............................^^ Folder Name, where Images are there, note on png/jpg
outDirectory='C:\Complete_path\result_images\';
%.............................^^ Folder Name, where you wish to save the image
% Result images will save in the folder ^^result_images
%The result_images folder will cretes by following statement
mkdir(outDirectory);
for i=1:length(Images)
ImgName=strcat('C:\Complete_path\hand_2101\',Images(i).name);
grayImage=((imread(ImgName)));
% do operation, say result image is result1
result1=.....
imwrite(result1,strcat(outDirectory,Images(i).name));
end
  4 个评论
Image Analyst
Image Analyst 2019-7-7
[~, baseFileNameNoExt, ext] = fileparts(Images(i).name)
outputFileName = fullfile(outDirectory, [baseFileNameNoExt, '.PNG'])
imwrite(result1, outputFileName);

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Import, Export, and Conversion 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by