Effacer les filtres
Effacer les filtres

Problem trying to scale image size from 18x5 to 24x14

1 vue (au cours des 30 derniers jours)
Recap
Recap le 27 Mar 2016
As the title says, I'm trying to scale images from their size to the size of 24x14. its used for numbers in a license plate. The code works fine with all numbers and letters except for the number 1. All other characters are 19x12 and they rescale to 24x14 without a problem. But the number 1 is 18x5. This is the code I have been using, which works fine until number 1 (18x5).
What can be done here if anything?
% inImg is the license plate and bbox are the coordinates for the bounding
% box of a number in the license plate
function [outImg,N]=Frame_RecognitionDigits(inImg,bbox)
% Auxiliary function that draws a specified bounding box in the image
outImg=inImg;
x1=bbox(:,1); % Coordinates frame
y1=bbox(:,2);
x2=x1+bbox(:,3);
y2=y1+bbox(:,4);
%----------------Recognition of numbers--------------------
%----------Scaling the image size------------
if y2-y1>=15
Nom=inImg(y1:y2-1,x1:x2,2); % The images in the frame
sizeNom=size(Nom);
sizeNom
figure,imshow(Nom) % single digits
im2=zeros(24,14); % The desired image size
sizeIm2=size(im2); % 24x14 pixel
% coefficients
k1=length(im2(:,1))/length(Nom(:,1));
k2=length(im2(1,:))/length(Nom(1,:));
for i=1:length(im2(:,1)) % 24
for j=1:length(im2(1,:)) % 14
y=round(i/k1);
x=round(j/k2);
imSt(i,j)=Nom(y,x); % Problem is here
end
end
end % the full function doesnt end here. I just closed it for this question
This is the error i get
Attempted to access Nom(1,0); index must be a positive integer or logical.
Error in
imSt(i,j)=Nom(y,x);

Réponses (1)

Star Strider
Star Strider le 27 Mar 2016
You may have to adjust your code a bit to accommodate this, but if ‘x’ and ‘y’ round down to zero, you can avoid that by replacing the round call with a ceil call:
y=ceil(i/k1);
x=ceil(j/k2);

Catégories

En savoir plus sur Feature Detection and Extraction dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by