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 次查看(过去 30 天)
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

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by