Hi Jacob,
I understand that you want to detect the decimal points when reading a line with numbers and decimals, while avoiding detecting any dot as decimal.
You can follow below steps:
- Segment the digits in the line. Segmenting the individual digits in the line will help you do contextual analysis.
- Identify the position of digits and their relationship to the nearby dots. For instance, if a dot is located between two digits, it is more likely to represent a decimal point.
- Find patterns that suggest the presence of a decimal number. For instance, search for digit sequences that are followed by a dot and then additional digits, as this is a typical way to identify a decimal number.
Refer the following pseudo code for better understanding:
inputLine = 'Your input line containing numbers and decimals';
characters = convertInputLineToCharacters(inputLine);
for i = 1:length(characters)
currentChar = characters{i};
if istrcmp(previousChar, '.')
if i > 2 && i < length(characters)-1
previousChar = characters{i-1};
nextChar = characters{i+1};
if isdigit(previousChar) && isdigit(nextChar)
For more information on various segmentation techniques for images and “OCR” function refer the links below:
Regards,
Ayush