Clear Filters
Clear Filters

How to measure the performance (precision and recall ) for following model and does it need to have groundTruth?

8 views (last 30 days)
I have 3 questions for classical computer vision detection model for crack detection.
I attached the original image (input ) and the output thus,
1- How many image I need to calculate the peformance of this model(Precision, recall,....) if I want o reach accuracy above 90%?
2-Does this type of model need to have the groundTruth or the original image is the groundTruth?
3-Does this type of model needs to train (80% for traing and 20% for testing) and how to do it, or traingnig only for machine learning and deep learning model ?
% Program to compute the mean width of a blob in an image.
clearvars;
close all;
clc;
fontSize = 15;
% Read in original image, with white lightning on black background.
baseFileName = 'Original image.jpg';
fullFileName = fullfile(pwd, baseFileName);
grayImage = imread(fullFileName);
% Get the dimensions of the image.
% numberOfColorChannels should be = 1 for a gray scale image, and 3 for an RGB color image.
[rows, columns, numberOfColorChannels] = size(grayImage)
if numberOfColorChannels > 1
% It's not really gray scale like we expected - it's color.
% Use weighted sum of ALL channels to create a gray scale image.
% grayImage = rgb2gray(rgbImage);
% ALTERNATE METHOD: Convert it to gray scale by taking only the green channel,
% which in a typical snapshot will be the least noisy channel.
grayImage = grayImage(:, :, 2); % Take green channel.
else
grayImage = grayImage; % It's already gray scale.
end
% Now it's gray scale with range of 0 to 255.
subplot(2, 3, 1);
imshow(grayImage, [])
impixelinfo; % Let user mouse around and see values in the status line at the lower right.
title('Original Image', 'FontSize', fontSize);
% Binarize the image.
% mask = imbinarize(grayImage);
lowThreshold = 0;
highThreshold = 160;
% Interactively and visually set a threshold on a gray scale image.
% https://www.mathworks.com/matlabcentral/fileexchange/29372-thresholding-an-image?s_tid=srchtitle
[lowThreshold, highThreshold] = threshold(lowThreshold, highThreshold, grayImage);
mask = grayImage >= lowThreshold & grayImage <= highThreshold;
% Fill holes.
mask = imfill(mask, 'holes');
% Take largest blob only.
mask = bwareafilt(mask, 1);
subplot(2, 3, 2);
imshow(mask)
impixelinfo; % Let user mouse around and see values in the status line at the lower right.
title('Mask', 'FontSize', fontSize)
% Compute the skeleton
skelImage = bwskel(mask);
subplot(2, 3, 3);
imshow(skelImage)
impixelinfo; % Let user mouse around and see values in the status line at the lower right.
title('Thinned', 'FontSize', fontSize)

Answers (1)

Pratham Shah
Pratham Shah on 28 Sep 2023
Yes, You need to have a ground truth in order to obtain accuracy, precision and recall. If you have ground truth you can calculate all those parameters.
  5 Comments
Pratham Shah
Pratham Shah on 1 Oct 2023
You can use Image Segmenter application of MATLAB or LableImg to mark background and foreground(Cracks). With that image you can compute accuracy of your algorithm.
yasmin ismail
yasmin ismail on 2 Oct 2023
@Pratham Shah thanks I used Imgae segmeneter and I got the result as shown in attached file (crack) which is groundTruth, now how can I apply IoU to compare between the GrndTruth and model out put ? I attached the outPut Too

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!