rqrcode_core icon indicating copy to clipboard operation
rqrcode_core copied to clipboard

Mask pattern penalty rules wrong? Or old?

Open swifthand opened this issue 7 months ago • 3 comments

Hello!

Thank you for this library and for your effort maintaining it for so long!

In using this library, I have recently concluded that three of the four penalty rules for selecting a mask pattern are not correct. Specifically the methods:

  • QRUtil::demerit_points_1_same_color
  • QRUtil::demerit_points_3_dangerous_patterns
  • QRUtil::demerit_points_4_dark_ratio

I have used RQRCode for some time, and so I did not come to this conclusion lightly. I have already fixed these for my own purposes with an undesirable combination of subclassing and monkeypatching. In solving this puzzle, I have many test cases to validate the correctness on various arrangements of modules (manually verified with pen-and-paper), based on the ISO 18004:2015 specification.

Before I put effort into writing up a larger issue and pull request, I wanted to ask whether this is intentional?
For example, are these rules adapted from some earlier version of the ISO standard? I only have access to the 2015 document, and I am aware that this project is older than that.

I do not wish to waste anyone's time.

swifthand avatar Jul 01 '24 00:07 swifthand