renaming the image after matching the image with other folder in matlab

1 次查看(过去 30 天)
I have two folders, In the first folder connected components are present like alphabets and some other components, each are named with 1,2....In the second folder 26 alphabets are present and are named with 1,2,...26. Using pca each elements in the first folder is matched with the second folder. If it does not matched i want to remove it from the folder. If the first element matched with the first element in the second folder then i want to rename the element in the first folder with alphabet A. If it matched with second then rename it as B and so on Is it possible? can anyone give some example for that pls..thanks in advance the code for matching the images is given below
clear all
clc
close all
% You can customize and fix initial directory paths
TrainDatabasePath = uigetdir('D:\Program Files\MATLAB\R2006a\work', 'Select training database path' );
TestDatabasePath = uigetdir('D:\Program Files\MATLAB\R2006a\work', 'Select test database path');
prompt = {'Enter test image name (a number between 1 to 10):'};
dlg_title = 'Input of PCA-Based Face Recognition System';
num_lines= 1;
def = {'1'};
TestImage = inputdlg(prompt,dlg_title,num_lines,def);
TestImage = strcat(TestDatabasePath,'\',char(TestImage),'.bmp');
im = imread(TestImage);
T = CreateDatabase(TrainDatabasePath);
[m, A, Eigenfaces] = EigenfaceCore(T);
OutputName = Recognition(TestImage, m, A, Eigenfaces);
Z=OutputName;
SelectedImage = strcat(TrainDatabasePath,'\',OutputName);
SelectedImage = imread(SelectedImage);
imshow(im)
title('Test Image');
figure,imshow(SelectedImage);
title('Equivalent Image');
str = strcat('Matched image is : ',OutputName);
disp(str)
imshow(im) title('Test Image'); figure,imshow(SelectedImage); title('Equivalent Image');
str = strcat('Matched image is : ',OutputName); disp(str)

采纳的回答

Image Analyst
Image Analyst 2015-7-12
Which variable gives the number of the letter/image that it matched? Anyway, you can use movefile() to rename image files . You might also find sprintf() and fullfile() useful.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Import and Analysis 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by