Help with an error when calling a function

1 visualizzazione (ultimi 30 giorni)
Hi All,
I have the following function, but every time I call it I get this error message.
function [C] = SquareCentroids( TempT, a, files, RawImages)
load('C:\Users\ezxtg4\OneDrive - The University of Nottingham\AFT and carbolite interpretation\Ash fusion analysis\Created Functions\Classifier.mat')
b1 = a;
b2 = find(TempT==500);
chk = isempty(b2);
if chk == 1
b2 = find(TempT==501);
chk = isempty(b2);
if chk == 1
b2 = find(TempT==502);
chk = isempty(b2);
if chk == 1
b2 = find(TempT==503);
end
end
end
L = int16(linspace(b1,b2,3));
Number_of_Squares_found = 1;
for i = L
progressbar(0,0) % Init 2 bars
Classifying_Image_TIFF = imread([RawImages '/' files(i).name]); % Original (files(i).name) added RawImages co it couldnt find it.
Classifying_Image_JPG = rgb2gray(Classifying_Image_TIFF(:,:,1:3));
Classifying_Image_Binarized = imbinarize(Classifying_Image_JPG);
Width_of_Classifying_Box = 90;
Height_of_Classifying_Box = 85;
[Ymax,Xmax] = size(Classifying_Image_JPG);
cellSize = [4 4];
[hog_4x4, vis4x4] = extractHOGFeatures(Classifying_Image_Binarized(1:Height_of_Classifying_Box,1:Width_of_Classifying_Box),'CellSize',cellSize);
for X = 1:15:(Xmax-Width_of_Classifying_Box)
progressbar([],0) % Reset 2nd bar
for Y = 1:15:(Ymax-Height_of_Classifying_Box)
Square_Prediction = predict(classifier,extractHOGFeatures(Classifying_Image_Binarized(Y:Y+Height_of_Classifying_Box, X:X+Width_of_Classifying_Box),'CellSize',cellSize));
if Square_Prediction == 1
SquarePredictorTable(Number_of_Squares_found,1)= Y + Height_of_Classifying_Box/2;
SquarePredictorTable(Number_of_Squares_found,2)= X + Width_of_Classifying_Box/2;
Number_of_Squares_found = Number_of_Squares_found + 1;
end
progressbar([],Y/(Ymax-Height_of_Classifying_Box)) % Update 2nd bar
end
progressbar(X/(Xmax-Width_of_Classifying_Box)) % Update 1st bar
end
end
% imshow(Classifying_Image_JPG);
% hold('on');
% plot(SquarePredictorTable(:,2), SquarePredictorTable(:,1), 'r*');
% Averaging data points from the Square predictor table
A = SquarePredictorTable;
[C,ia] = uniquetol(A(1:(Number_of_Squares_found-1),:), .10, 'ByRows', true);
%hold('on');
%plot(C(:,2), C(:,1), 'c*');
end
and the error:
Unrecognized function or variable 'SquarePredictorTable'.
Error in SquareCentroids (line 56)
A = SquarePredictorTable;
Is there any way I can fix this please? Thank you in advance!
  1 Commento
Adam Danz
Adam Danz il 20 Gen 2021
SquarePredictorTable is never being defined.
It could have been interrupted by an error or perhaps the Square_Prediction==1 condition never being met.
Use debug-mode to explore what's happening in your code. Here's a GIF showing how to set a breakpoint.

Accedi per commentare.

Risposta accettata

Cris LaPierre
Cris LaPierre il 20 Gen 2021
It would appear either one of your for loops is not executing, or your if statement Square_Prediction == 1 is never true. When that happens, SquarePredictorTable is not created, resulting in the error that you see.

Più risposte (0)

Categorie

Scopri di più su Programming Utilities in Help Center e File Exchange

Prodotti


Release

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by