def QRUtil.demerit_points_1_same_color(modules)
demerit_points = 0
module_count = modules.size
(0...module_count).each do |row|
(0...module_count).each do |col|
same_count = 0
dark = modules[row][col]
( -1..1 ).each do |r|
next if row + r < 0 || module_count <= row + r
( -1..1 ).each do |c|
next if col + c < 0 || module_count <= col + c
next if r == 0 && c == 0
if dark == modules[row + r][col + c]
same_count += 1
end
end
end
if same_count > 5
demerit_points += (DEMERIT_POINTS_1 + same_count - 5)
end
end
end
return demerit_points
end