confusion matrix for image retrieval

4 views (last 30 days)
new_user
new_user on 29 Dec 2021
Edited: new_user on 29 Dec 2021
im = fullfile(pn, fn);
images_query = imageDatastore(rootFolder, 'IncludeSubfolders',true, 'LabelSource','foldernames'); %%'ReadFcn', @readCBIR
R = imread(im); % Read image
Input_Layer_Size_q = net.Layers(1).InputSize(1:2); % (1:2 = 1st 2 elemnts of input size), input layer size stored in this variable (Input_layer_size)
Resized_Test_image_q = augmentedImageDatastore(Input_Layer_Size_q, R, 'ColorPreprocessing','gray2rgb'); %% For defining test image replace "Testing _image with test folder
%Extract feature
train_feature = activations(net, Resized_Training_image, 'Animal Feature Learner', 'OutputAs', 'Rows');
query_feature = activations(net, Resized_Test_image_q, 'Animal Feature Learner', 'OutputAs', 'Rows');
%Equation 2
a = query_feature; % transposing
b = transpose(1-a);
%Equation 3
c = zeros(Number_of_Classes,Number_of_Training_images);
d = sqrt(sum((query_feature' - train_feature') .^ 2)); % other method eucledian: giving all images from same category maybe something is wrong
for e = 1 : Number_of_Training_images
f = b.*d(:,e);
c(:, e) = f;
end
c = sqrt(sum(c))';
% Fetch top 25 similar images
g = sort(c);
[~, n] = sort(c);
n = n(1:25);
files = cell(1, 25);
for h =1:25
files{h} = Training_image.Files{n(h)};
end
%Display query image
figure;
imshow(R);
title('query')
% Display retrived images
figure;
montage(files);
title("retrived")
figure;
confusionchart(Testing_image.Labels, Predicted_Label,'Normalization','row-normalized', 'Title', 'Normalised ConfMat'); % normalised values for different rows, col, etc
confMat = confusionmat(Testing_image.Labels, Predicted_Label); %confusionmat generates cofusion matrix
How do I find confusion matrix, precison, RMS error for image retrival?

Answers (0)

Community Treasure Hunt

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

Start Hunting!