UNABLE TO PERFORM ASSIGMENT BECAUSE THE SIZE OF THE LEFT SIDE IS 1 BY 1260 AND THE SIZE OF THE RIGHT SIDE IS 1 BY 5040

1 view (last 30 days)
function matr_text=ocr(im, bb)
Dir="C:\Users\Usuario\Downloads\vcc2\vcc";
trainingSet = imageDatastore(Dir,'IncludeSubfolders',true,'LabelSource','foldernames');
countEachLabel(trainingSet)
numImages = numel(trainingSet.Files);
img = readimage(trainingSet, 1);
[hog_4x4, vis4x4] = extractHOGFeatures(img,'CellSize',[4 4]);
plot(vis4x4)
cellSize = [4 4];
hogFeatureSize = length(hog_4x4);
trainingFeatures = zeros(numImages,hogFeatureSize,'single');
for i = 1:numImages
img = readimage(trainingSet,i);
img = rgb2gray(img);
% Apply pre-processing steps
img = imbinarize(img);
trainingFeatures(i,:) = extractHOGFeatures(img, 'CellSize',cellSize);
end
% Get labels for each image.
trainingLabels = trainingSet.Labels;
classifier = fitcecoc(trainingFeatures, trainingLabels);
[m, n] = size(bb)
for j = 1:m
img = imcrop(im, bb(j,:));
figure, imshow(img)
img = rgb2gray(img);
% Apply pre-processing steps
img = imbinarize(img);
img=imresize(img, [45,60])
figure, imshow(img)
features(j,:) = extractHOGFeatures(img,'CellSize',cellSize);
end
% Make class predictions using the test features.
predictedLabels = predict(classifier, features);
end

Answers (0)

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!