A code reading apparatus comprising an image acquisition apparatus for capturing a barcode and a control and evaluation unit in which a method for reading a barcode is implemented, said method comprising that:
- a barcode is captured by means of an image acquisition apparatus, said barcode comprising barcode elements in the form of bars and spaces, wherein the bars and the spaces arranged between the bars are arranged in an alternating manner, wherein a respective bar and/or a respective space can be assigned to a width level of a predefined number of width levels, wherein each width level has a respective reference width;
- an edge field is generated based on the captured barcode, wherein an edge in the edge field indicates a bar-space transition;
- using the edge field, a similarity value is determined that indicates a similarity between a distribution of bar width values and a distribution of space width values;
- wherein an adjustment of the edge field takes place when the similarity value satisfies a predetermined condition;
- and
- the barcode is decoded based on the edge field and/or the adjusted edge field, or a barcode is captured by means of an image acquisition apparatus, on which barcode bars and spaces arranged between the bars are arranged in an alternating manner, wherein the width of a respective space and/or the width of a respective bar corresponds to a reference width of a respective width level of a predefined number of width levels;
- an edge field is generated based on the captured barcode, wherein an edge in the edge field indicates a bar-space transition;
- using the edge field, at least a first estimate of a reference width of a first width level takes place on the basis of the bar width values and a second estimate of the reference width of the first width level takes place on the basis of the space width values;
- a shift value is determined based on a difference of the first estimate value and the second estimate;
- and
- the edge field is adjusted based on the shift value,
- wherein the barcode is decoded based on the adjusted edge field, or a barcode is captured by means of an image acquisition apparatus, said barcode comprising barcode elements in the form of bars and spaces, wherein the bars and the spaces arranged between the bars are arranged in an alternating manner, wherein the width of a respective space and/or the width of a respective bar corresponds to a reference width of a respective width level of a predefined number of width levels;
- an edge field is generated based on the captured barcode, wherein an edge in the edge field indicates a bar-space transition;
- wherein an adjustment of the edge field takes place and comprises that:
- (1) a first estimate of the reference width of the respective width level takes place on the basis of the bar width values and a second estimate of the reference width of the respective width level takes place on the basis of the space width values for each width level of the predefined number of width levels,
- (2) an averaged estimated reference width for each width level is determined based on an averaging of the respective first estimate and the respective second estimate,
- (3) an iteration takes place over the edge field,
- (4) wherein, for each edge, based on the averaged estimated reference widths of the width levels, it is determined which width level the two adjacent barcode elements belong to,
- (5) wherein, for each edge, it is further determined whether a shift of the edge by a predefined fine adjustment value Δx in one of the two directions leads to a reduction in the distance of both adjacent elements from the averaged estimated reference width of their associated width level and, in the event of a positive determination, a shift of the respective edge by Δx takes place in the corresponding direction and step is repeated for the shifted edge,
- (6) wherein, in the event of a negative determination, no shift of the respective edge takes place and the preceding steps to are carried out for the next edge;
- wherein the barcode is decoded based on the adjusted edge field.