science research paper-the modernization of the qr code through color and brightness levels

33
1 The Modernization of the QR Code through Color and Brightness Level Report Written by Joonu Ryu

Upload: joonu-ryu

Post on 13-Jan-2017

253 views

Category:

Documents


0 download

TRANSCRIPT

1

The Modernization of the QR Code through Color and Brightness Level

Report Written by

Joonu Ryu

2

Abstract

The QR code is now ubiquitous around us. However, QR is actually an old technology that was

never meant for the application we see today. Looking back at its origin, QR was developed when

color printing was expensive and camera resolutions were poor. Everything about it, monochrome

and large blocky print, reflects the limitations around the time of its invention, and it is not the

optimal way of conveying information. This research attempted to modernize QR code by

employing color and brightness levels while preserving the basic technology intact. The first phase

of this research involved combining three QR codes into one RGB Color QR code, which could hold

three times more information than a normal QR, and this was successfully accomplished. The

second phase involved combining QR codes using their bit depths resulting in a QR code that could

hold two times more data than a regular QR. Finally, the last phase combined the first and second

phases together to create a Color QR that could hold six times more data than a regular QR code.

However, the last two phases were only about 60% reliable. Just by updating the color QR reader

apps, we can pack three times to six times more information in QR of a given size. The attractive

coloring is a welcome side effect.

3

The Table of Contents

Contents

Abstract ........................................................................................................................................... 2

The Table of Contents ..................................................................................................................... 3

Hypothesis....................................................................................................................................... 5

Background Research ..................................................................................................................... 6

Origins of the QR Code ................................................................................................................ 6

The Barcode ............................................................................................................................. 6

What is a QR Code? ..................................................................................................................... 9

History of the QR Code ............................................................................................................ 9

Anatomy of a QR code ............................................................................................................. 9

Difference between Color and Grey level ................................................................................. 10

Materials List ................................................................................................................................. 11

Variables........................................................................................................................................ 12

Independent .............................................................................................................................. 12

Dependent ................................................................................................................................. 12

Constant .................................................................................................................................... 12

Programming Procedure ............................................................................................................... 13

4

Data Analysis and Discussion ........................................................................................................ 17

Data ........................................................................................................................................... 17

Brightness Calibration ........................................................................................................... 19

Discussion .................................................................................................................................. 21

Conclusion ..................................................................................................................................... 22

Ideas for Future Research ............................................................................................................. 23

Acknowledgements ....................................................................................................................... 24

Works Cited ................................................................................................................................... 25

Appendix ....................................................................................................................................... 27

5

Hypothesis

The QR code is capable of carrying many times more information by leveraging the advancement

and affordability of modern printing technology without having to change its basic algorithm.

6

Background Research

Origins of the QR Code

The Barcode

There are many ways to store data and information other than using the QR code. Its

predecessor, the barcode, was the first type of technology that could effectively hold data.

The barcode is a popular automatic identification technology that is used in many fields, such as

industry, marketing, and manufacturing. It has facilitated data storage management and not to

mention, the length of the shopping lines at a supermarket. Barcodes comprises a series of bars

and white spaces that are printed in ratios (BhaskerRaj, 2001), and these are what conveys the

information. They can hold any type of information. However, a limiting factor is its data

capacity. Barcodes, which could only hold a few characters, are now more efficient and can

hold much more information due to more inventions of barcode symbologies, which are a set

of rules that relate the coded message with the barcode pattern. (BhaskerRaj, 2001)

History of the Barcode

The idea of the barcode was brought up when the president of a local fast food chain requested

an automatic checkout system to be researched. Bernard Silver and Norman Joseph Woodland,

both Drexel Institute of Technology (DIT) graduates, agreed to start researching on a system.

(Bokor, 2001) After studying variegated concepts, Silver and Woodland developed and

patented the first barcode off of the idea of Morse code. Woodland later became employed at

IBM and hoped to further develop the technology there, but economically it wasn’t in demand.

7

Thus, they sold it to another company to Philco, who sold it to RCA later on. (Yan, Zhang, Yang,

& Huansheng, 2008)

Finally, the technology became needed, especially by fast food restaurants and markets, who

wanted a facilitated way to automatically keep inventory and checkout food/market items. In

1966, the National Association of Food Chains began discussing the aforementioned concept.

RCA, which recently bought the rights to develop Woodland’s barcode patent, edited his

barcode concept. (Bokor, 2001) In 1981, the United States Department of Defense officially

established the use of the barcode in marketing and in industrial processes by using the

technology to mark all products that were sold to the military.

Barcode/QR code use Binary Code

Figure 1

All data or information from pictures, videos, to documents, are stored using binary code.

Binary code, which is the use of two numbers, most commonly 0 and 1, is the easiest way

computers can recognize and read data and thus, the barcode was built to accommodate to this

characteristic. In a barcode, the black lines represent 1 and the white spaces represent 0. When

the barcode is scanned by a scanner, the computer reads the binary code in one string such as

01001010, which could represent a letter or a decimal number.

8

Anatomy of the Barcode

Figure 2

Most barcodes usually comprise a start character, data characters, a stop character, and quiet

zones. (Kato, Chai, & Tan, 2010)Quiet zones are the most outer white parts of a barcode, and is

needed to read the data in the barcode. The start character and stop character are several bars

located at the beginning and end of a barcode, and tell the scanner when to start and stop

scanning. The data characters are the bars that represent the binary code. This code is then

read by the scanner and translated into characters or numbers.

Applications of the Barcode

The most well-known barcode users have been retailers in the supply chain. (Kato, Chai, & Tan,

2010). It was actually the retailers who took the initiative to develop an invention such as the

barcode. Today, the barcode type called Universal Product Code (UPC) is widely used in item

identification. In manufacturing and industry, barcodes have been used to mark items and

manage storage and production of those items. More recently, due to barcode’s limited data

9

capacity, industries such as Toyota are using 2D barcodes or more commonly known as QR

codes (Kato, Chai, & Tan, 2010).

What is a QR Code?

QR codes are 2D matrix barcodes that use the same 0 1 (Binary) symbology. They are very

famous for their use in industry as well as marketing, as seen being used by smart phone

applications. The QR code has also replaced the 1D barcode, due to its lack of data capacity and

efficiency. 2D barcode technology has many advantages from large data storage capacity, high

information density, strong error-correcting, to high readability and reliability (Jiang, Ma, &

Chen, 2010).

History of the QR Code

Developed by Denso Wave in Japan 1994, the QR code became a sensation, and today it is

ubiquitous around us. Due to the 1D barcode’s lack of data capacity, Denso Wave was asked to

develop a code that could do just the same function as the 1D barcode but hold more data.

Initially designed to track vehicle manufacturing processes, the QR code is now being used in a

wide variety of fields from marketing, industry, to education. (Winter, 2011)

Anatomy of a QR code

The QR code is very similar to the barcode when comparing their anatomies. Both consist of

quiet zones and detection bars/boxes that signal the scanning device to start reading the

barcode/QR. However, the QR diverges away from a 1D barcode when it comes to its data

storage method. Its ability to store data along two dimensions allows it to have increased data

capacity and reliability, and its ability to store data and error correction code into the QR allows

10

the scanner to read the QR even under extreme light conditions. A diagram of this is shown in

figure 3.

Figure 3

In addition, the QR code has a total 40 versions, with version 1 being the smallest and version

40 being the largest. Size is determined by the number of modules or boxes the QR code has.

For example, the largest QR, version 40 has 177x177 modules. The more modules, the more

data it can hold. However, it becomes much harder to read. (Standardization & Commission,

2000)

Difference between Color and Grey level

Grey level is a series of values in a 2-dimensional list. The computers read these values as

different shades of black. However, color pictures have a 3-dimensional list with 3 values

representing each pixel rather than 1 like grey level pictures. These 3 values are called R, G, and

B values or Red, Green and Blue. Each value commands the device to portray a certain contrast

of Red, Green, or Blue, and as a result, the 3 colors blend to form other colors such as cyan,

purple, and black.

11

Materials List

Wolfram Mathematica 10 Student Edition

iPhone 4S 1080p Back Camera

QR Code Documentation

Color Printer

Computer (Processor: Intel(R) Core(TM) i7-4700MQ CPU @ 2.40 GHz) and 16 GB of RAM

used for this research)

12

Variables

Independent

Number of colors in QR

Number of grey levels (bit depth) in QR

The number of pixels per QR block

Dependent

Readability of the QR code

Data capacity per area of print

Constant

Amount of Information

13

Programming Procedure

Phase 1: Color QR code with 1 grey level

1. Break any input text into three sub strings evenly. Pad the string at the end if necessary.

2. Generate traditional QR code of each sub string. Each of three resulting QR code images

has boxes that should be 2 times bigger than it would have been if the original string

was generated as a single QR code image. This larger box size leads to easier

readability.

Figure 1: Concept behind the Color QR Code

3. Convert the white of each of three QR code generated above to Red, Green and Blue

respectively.

14

4. Add corresponding pixels of above three RGB QR codes. This produces a single color QR

code image that has twice as large boxes and yet contains the original text.

Phase 2: QR code with 2 grey levels

5. Take any example text. Break the text into two sub strings evenly. Pad the string if

necessary.

6. Generate a QR code for each sub string.

7. Store one of the QR codes using the upper 4 bits.

8. Store the other QR code using the lower 4 bits

9. Merge the bits per each pixel.

10. The result should be byte data that has the first four bits of the first QR code’s data set

and the last four bits of the second QR code’s data set combined for each byte.

11. Convert the new data set into an image.

12. This produces a single QR code of four gray level that holds all of the original text. The

box size should remain equal to the original two QR codes.

Phase 3: Color QR code with 2 grey levels

13. Divide any input text into 6 sub strings, each with equal lengths.

14. Using the same technique as phase 2, generate a QR code images with 2 grey levels;

that is, two regular QR codes images combined into one using their bit depths.

Generate three sets of two level QR code images as described in phase 2.

15. Generate 2 more QR codes images with 2 grey levels each. Make sure all three QR codes

consist of an equal amount of data. Pad the data if needed. Combine three QR codes by

using RGB as described in phase 1.

15

16. This produces a single QR code made of three colors and four intensities that contains

six times more data with boxes that are 9 times larger than a regular QR code’s box size.

Figure 2: Grey Level Combination

Phase 4: How to read multi-level color QR code image

17. Take a picture of multi-level color QR code image

18. Separate the three color components of each pixel two form 3 separate images.

19. Use the traditional QR reading algorithm to retrieve the text data from the 3 QR codes

Phase 5: Separation of color QR with 2 grey levels

20. Separate the colors as described in phase 4.

21. This time the resulting 3 QR codes should comprise 4 different grey levels. However,

since the picture of the multi-level color QR code was taken under a specific

environment, the grey levels will be distorted. Thus, reduce the number of grey levels to

exactly four (Color Quantization).

22. Once reduced, separate the QR code into two QR codes by using the four higher bits and

the four lower bits of the image. Apply this to the other 2 QR codes.

23. The final result is 6 traditional QR codes that can be read using the traditional algorithm.

Concatenate the extract text. *(The final algorithm is pasted in the Appendix)

16

Figure 3: Multi-Gray Level Color QR Separation

17

Data Analysis and Discussion

Data

Color QR Combination & Decomposition

18

19

Brightness Calibration

1:7 Combined QR

2:6 Combined QR

3:5 Combined QR

4:4 Combined QR

20

5:3 Combined QR

Color QR vs. Black/White QR - 1:4 Size difference

Black/White QR vs. Multi-grey level color QR - 1:9 Size difference

21

Discussion

Although a color QR that comprised 6 regular QR codes was successfully generated, through

many trials and experiments, the extraction phase of the QR code was unreliable because the

QR codes that were extracted were too distorted to be read. Lighting most likely created this

problem, and it could possibly be the primary reason behind the error produced by the

algorithm. Color Quantization was applied, which made the extraction possible, but it could not

fix the issue. To further explore the problem, brightness calibration charts were set up around a

QR code, and depending how much the brightness changed on the calibration charts would also

show how much the brightness changed in the Color QR code. In the end, it was evident that

the four different brightness levels were too close to each other in value, thus making it difficult

for the algorithm to differentiate and separate the different shades of gray. Color QR separation

was successful but Multi-Gray level Color QR separation was not. However, it was discovered

that each box size for the Color QR was four times bigger and each box size for the Multi-gray

level Color QR was nine times bigger than those of a regular QR code.

22

Conclusion

This research demonstrated that it is possible to hold and transmit much more information using

the same paper area and at the same resolution by employing color and gray scale in QR

code. More specifically, by using color, 3 different QR codes were able to be combined into 1

color QR while holding the resolution constant, resulting in a 30.2% increase of the box size, which

increased the readability of the QR. This research also attempted to use gray scale to store 2

times more information resulting in 6x information density when combined with color. But it was

deduced to be unreliable after many trials showed data distortion when scanned. This method can

be easily adopted because this expanded capacity can be achieved by a simple pre-processing and

post-processing in the app, without requiring any investment or modifications in technology,

hardware, algorithm or any change of standards.

23

Ideas for Future Research

This research successfully combined 6 QR codes into one multi-grey level color QR. However,

the algorithm that attempted to read the multi-grey level color QR turned out to be unreliable

because it could not often read the color QR accurately due to QR data distortion within the QR

code itself. Through data and observations, it was evident that the algorithm could not

differentiate the four brightness levels accurately, thus producing six QR codes that were too

distorted to be read. Although a brightness calibration chart was used, the algorithm failed to

differentiate the four brightness values. However, if a black piece of paper is placed under the

Color QR, the algorithm might be able to differentiate the dark shades gray from the light ones

more accurately since the black paper contrasts best against lighter colors. Different lighting

will also be used to find the optimum environment to read a color QR.

24

Acknowledgements

This research could not have been possible without the help of my parents, mentors, and

especially God. I specially thank Dr. Choi for aiding and guiding me through this research as well

as Mrs. Lee who also directed me. I would also like to thank my parents who encouraged me

when I hit brick walls during my research and limitations. Finally, I would like to thank God above

all else who gave me this wonderful opportunity to study and research the application of color

and brightness levels on the QR code.

25

Works Cited

Bhasker, R. (2001). Bar Codes. New Delhi, India: Tata McGraw-Hill Education, 2001. Retrieved

February 21, 2015

Bokor, L. (2001). Bar Codes. Retrieved from cs.iusb:

http://www.cs.iusb.edu/internship/papers/laslo/Bar_Code.html

contributors, W. (n.d.). Barcode. Retrieved from Wikipedia:

http://en.wikipedia.org/wiki/Barcode

Jiang, X., Ma, M. Y., & Chen, C. W. (2010). Mobile Multimedia Processing: Fundamentals,

Methods, and Applications (illustrated ed.). (X. Jiang, M. Y. Ma, & C. W. Chen, Eds.)

Heidelberg, Germany: Springer Science & Business Media. Retrieved February 17, 2015

Kato, H., Chai, D., & Tan, K. T. (2010). Barcodes for Mobile Devices. Cambridge , New York,

United States of America: Cambridge University Press.

Standardization, I. O., & Commission, I. E. (2000). Information technology - Automatic

identification and data capture techniques - Bar code symbology - QR code.

International Standard, 11-120. Retrieved February 14, 2015

Winter, M. (2011). Scan Me-Everybody's Guide to the Magical World of Qr Codes. Napa,

California, United States of America: Westsong Publishing. Retrieved February 23, 2015

Xu, M. (2007). Managing Strategic Intelligence: Techniques and Technologies. (M. Xu, Ed.) Idea

Group Inc. Retrieved February 20, 2015

26

Yan, L., Zhang, Y., Yang, L. T., & Huansheng, N. (2008). The Internet of Things: From RFID to the

Next-Generation Pervasive Networked Systems. Boca Raton, Florida, United States of

America: Auerbach Publications. Retrieved February 20, 2015

27

Appendix

These are a list of algorithms that were written/discovered during this research.

This function converts any data into Color QR

by using both Color and GreyLevel specified by n.

sfProduceMultiGreyLevelColor6QRWithData data , n :

Module list, length, separated, hp, qrData1,

join1, toCode1, fromCode1, qr1, qrData2, join2,

toCode2, fromCode2, qr2, qrData3, join3, toCode3,

fromCode3, qr3, qrData4, join4, toCode4, fromCode4,

qr4, qrData5, join5, toCode5, fromCode5,

qr5, qrData6, join6, toCode6, fromCode6,

qr6, imData1, imData2, wiped1, wiped2,

combined1, combined2, combined3, imData3,

imData4, wiped3, wiped4, imData5, imData6,

wiped5, wiped6, cImage1, cImage2, cImage3 ,

hp sfBreakStringsIntoN data, 6 ;

qrData1 Flatten Take hp, 1 ;

join1 StringJoin qrData1 ;

toCode1 ToCharacterCode join1 ;

fromCode1 FromCharacterCode toCode1 ;

qr1 BarcodeImage fromCode1, "QR" ;

qrData2 Flatten Take hp, 2 ;

join2 StringJoin qrData2 ;

toCode2 ToCharacterCode join2 ;

fromCode2 FromCharacterCode toCode2 ;

qr2 BarcodeImage fromCode2, "QR" ;

qrData3 Flatten Take hp, 3 ;

join3 StringJoin qrData3 ;

toCode3 ToCharacterCode join3 ;

fromCode3 FromCharacterCode toCode3 ;

qr3 BarcodeImage fromCode3, "QR" ;

qrData4 Flatten Take hp, 4 ;

join4 StringJoin qrData4 ;

toCode4 ToCharacterCode join4 ;

fromCode4 FromCharacterCode toCode4 ;

qr4 BarcodeImage fromCode4, "QR" ;

qrData5 Flatten Take hp, 5 ;

join5 StringJoin qrData5 ;

toCode5 ToCharacterCode join5 ;

fromCode5 FromCharacterCode toCode5 ;

qr5 BarcodeImage fromCode5, "QR" ;

qrData6 Flatten Take hp, 6 ;

join6 StringJoin qrData6 ;

toCode6 ToCharacterCode join6 ;

fromCode6 FromCharacterCode toCode6 ;

qr6 BarcodeImage fromCode6, "QR" ;

imData1 ImageData qr1, "Byte" ;

imData2 ImageData qr2, "Byte" ;

wiped1 If n 1, Map BitAnd , 128 &, imData1 ,

If n 2, Map BitAnd , 192 &, imData1 ,

If n 3, Map BitAnd , 224 &, imData1 ,

If n 4, Map BitAnd , 240 &, imData1 ,

If n 5, Map BitAnd , 248 &, imData1 ;

wiped2 If n 1, Map BitAnd , 127 &, imData2 ,

If n 2, Map BitAnd , 63 &, imData2 ,

If n 3, Map BitAnd , 31 &, imData2 ,

If n 4, Map BitAnd , 15 &, imData2 ,

If n 5, Map BitAnd , 7 &, imData2 ;

combined1 wiped1 wiped2;

imData3 ImageData qr3, "Byte" ;

imData4 ImageData qr4, "Byte" ;

wiped3 If n 1, Map BitAnd , 128 &, imData3 ,

If n 2, Map BitAnd , 192 &, imData3 ,

If n 3, Map BitAnd , 224 &, imData3 ,

If n 4, Map BitAnd , 240 &, imData3 ,

If n 5, Map BitAnd , 248 &, imData3 ;

wiped4 If n 1, Map BitAnd , 127 &, imData4 ,

If n 2, Map BitAnd , 63 &, imData4 ,

If n 3, Map BitAnd , 31 &, imData4 ,

If n 4, Map BitAnd , 15 &, imData4 ,

If n 5, Map BitAnd , 7 &, imData4 ;

combined2 wiped3 wiped4;

imData5 ImageData qr5, "Byte" ;

imData6 ImageData qr6, "Byte" ;

wiped5 If n 1, Map BitAnd , 128 &, imData5 ,

If n 2, Map BitAnd , 192 &, imData5 ,

If n 3, Map BitAnd , 224 &, imData5 ,

If n 4, Map BitAnd , 240 &, imData5 ,

If n 5, Map BitAnd , 248 &, imData5 ;

wiped6 If n 1, Map BitAnd , 127 &, imData6 ,

If n 2, Map BitAnd , 63 &, imData6 ,

If n 3, Map BitAnd , 31 &, imData6 ,

If n 4, Map BitAnd , 15 &, imData6 ,

If n 5, Map BitAnd , 7 &, imData6 ;

combined3 wiped5 wiped6;

cImage1 Image combined1 ImageAdjust;

cImage2 Image combined2 ImageAdjust;

cImage3 Image combined3 ImageAdjust;

ColorCombine cImage1, cImage2, cImage3

This function converts any data into Color QR

by using both Color and GreyLevel specified by n.

sfProduceMultiGreyLevelColor6QRWithData data , n :

Module list, length, separated, hp, qrData1,

join1, toCode1, fromCode1, qr1, qrData2, join2,

toCode2, fromCode2, qr2, qrData3, join3, toCode3,

fromCode3, qr3, qrData4, join4, toCode4, fromCode4,

qr4, qrData5, join5, toCode5, fromCode5,

qr5, qrData6, join6, toCode6, fromCode6,

qr6, imData1, imData2, wiped1, wiped2,

combined1, combined2, combined3, imData3,

imData4, wiped3, wiped4, imData5, imData6,

wiped5, wiped6, cImage1, cImage2, cImage3 ,

hp sfBreakStringsIntoN data, 6 ;

qrData1 Flatten Take hp, 1 ;

join1 StringJoin qrData1 ;

toCode1 ToCharacterCode join1 ;

fromCode1 FromCharacterCode toCode1 ;

qr1 BarcodeImage fromCode1, "QR" ;

qrData2 Flatten Take hp, 2 ;

join2 StringJoin qrData2 ;

toCode2 ToCharacterCode join2 ;

fromCode2 FromCharacterCode toCode2 ;

qr2 BarcodeImage fromCode2, "QR" ;

qrData3 Flatten Take hp, 3 ;

join3 StringJoin qrData3 ;

toCode3 ToCharacterCode join3 ;

fromCode3 FromCharacterCode toCode3 ;

qr3 BarcodeImage fromCode3, "QR" ;

qrData4 Flatten Take hp, 4 ;

join4 StringJoin qrData4 ;

toCode4 ToCharacterCode join4 ;

fromCode4 FromCharacterCode toCode4 ;

qr4 BarcodeImage fromCode4, "QR" ;

qrData5 Flatten Take hp, 5 ;

join5 StringJoin qrData5 ;

toCode5 ToCharacterCode join5 ;

fromCode5 FromCharacterCode toCode5 ;

qr5 BarcodeImage fromCode5, "QR" ;

qrData6 Flatten Take hp, 6 ;

join6 StringJoin qrData6 ;

toCode6 ToCharacterCode join6 ;

fromCode6 FromCharacterCode toCode6 ;

qr6 BarcodeImage fromCode6, "QR" ;

imData1 ImageData qr1, "Byte" ;

imData2 ImageData qr2, "Byte" ;

wiped1 If n 1, Map BitAnd , 128 &, imData1 ,

If n 2, Map BitAnd , 192 &, imData1 ,

If n 3, Map BitAnd , 224 &, imData1 ,

If n 4, Map BitAnd , 240 &, imData1 ,

If n 5, Map BitAnd , 248 &, imData1 ;

wiped2 If n 1, Map BitAnd , 127 &, imData2 ,

If n 2, Map BitAnd , 63 &, imData2 ,

If n 3, Map BitAnd , 31 &, imData2 ,

If n 4, Map BitAnd , 15 &, imData2 ,

If n 5, Map BitAnd , 7 &, imData2 ;

combined1 wiped1 wiped2;

imData3 ImageData qr3, "Byte" ;

imData4 ImageData qr4, "Byte" ;

wiped3 If n 1, Map BitAnd , 128 &, imData3 ,

If n 2, Map BitAnd , 192 &, imData3 ,

If n 3, Map BitAnd , 224 &, imData3 ,

If n 4, Map BitAnd , 240 &, imData3 ,

If n 5, Map BitAnd , 248 &, imData3 ;

wiped4 If n 1, Map BitAnd , 127 &, imData4 ,

If n 2, Map BitAnd , 63 &, imData4 ,

If n 3, Map BitAnd , 31 &, imData4 ,

If n 4, Map BitAnd , 15 &, imData4 ,

If n 5, Map BitAnd , 7 &, imData4 ;

combined2 wiped3 wiped4;

imData5 ImageData qr5, "Byte" ;

imData6 ImageData qr6, "Byte" ;

wiped5 If n 1, Map BitAnd , 128 &, imData5 ,

If n 2, Map BitAnd , 192 &, imData5 ,

If n 3, Map BitAnd , 224 &, imData5 ,

If n 4, Map BitAnd , 240 &, imData5 ,

If n 5, Map BitAnd , 248 &, imData5 ;

wiped6 If n 1, Map BitAnd , 127 &, imData6 ,

If n 2, Map BitAnd , 63 &, imData6 ,

If n 3, Map BitAnd , 31 &, imData6 ,

If n 4, Map BitAnd , 15 &, imData6 ,

If n 5, Map BitAnd , 7 &, imData6 ;

combined3 wiped5 wiped6;

cImage1 Image combined1 ImageAdjust;

cImage2 Image combined2 ImageAdjust;

cImage3 Image combined3 ImageAdjust;

ColorCombine cImage1, cImage2, cImage3

28

This function converts any data into Color QR

by using both Color and GreyLevel specified by n.

sfProduceMultiGreyLevelColor6QRWithData data , n :

Module list, length, separated, hp, qrData1,

join1, toCode1, fromCode1, qr1, qrData2, join2,

toCode2, fromCode2, qr2, qrData3, join3, toCode3,

fromCode3, qr3, qrData4, join4, toCode4, fromCode4,

qr4, qrData5, join5, toCode5, fromCode5,

qr5, qrData6, join6, toCode6, fromCode6,

qr6, imData1, imData2, wiped1, wiped2,

combined1, combined2, combined3, imData3,

imData4, wiped3, wiped4, imData5, imData6,

wiped5, wiped6, cImage1, cImage2, cImage3 ,

hp sfBreakStringsIntoN data, 6 ;

qrData1 Flatten Take hp, 1 ;

join1 StringJoin qrData1 ;

toCode1 ToCharacterCode join1 ;

fromCode1 FromCharacterCode toCode1 ;

qr1 BarcodeImage fromCode1, "QR" ;

qrData2 Flatten Take hp, 2 ;

join2 StringJoin qrData2 ;

toCode2 ToCharacterCode join2 ;

fromCode2 FromCharacterCode toCode2 ;

qr2 BarcodeImage fromCode2, "QR" ;

qrData3 Flatten Take hp, 3 ;

join3 StringJoin qrData3 ;

toCode3 ToCharacterCode join3 ;

fromCode3 FromCharacterCode toCode3 ;

qr3 BarcodeImage fromCode3, "QR" ;

qrData4 Flatten Take hp, 4 ;

join4 StringJoin qrData4 ;

toCode4 ToCharacterCode join4 ;

fromCode4 FromCharacterCode toCode4 ;

qr4 BarcodeImage fromCode4, "QR" ;

qrData5 Flatten Take hp, 5 ;

join5 StringJoin qrData5 ;

toCode5 ToCharacterCode join5 ;

fromCode5 FromCharacterCode toCode5 ;

qr5 BarcodeImage fromCode5, "QR" ;

qrData6 Flatten Take hp, 6 ;

join6 StringJoin qrData6 ;

toCode6 ToCharacterCode join6 ;

fromCode6 FromCharacterCode toCode6 ;

qr6 BarcodeImage fromCode6, "QR" ;

imData1 ImageData qr1, "Byte" ;

imData2 ImageData qr2, "Byte" ;

wiped1 If n 1, Map BitAnd , 128 &, imData1 ,

If n 2, Map BitAnd , 192 &, imData1 ,

If n 3, Map BitAnd , 224 &, imData1 ,

If n 4, Map BitAnd , 240 &, imData1 ,

If n 5, Map BitAnd , 248 &, imData1 ;

wiped2 If n 1, Map BitAnd , 127 &, imData2 ,

If n 2, Map BitAnd , 63 &, imData2 ,

If n 3, Map BitAnd , 31 &, imData2 ,

If n 4, Map BitAnd , 15 &, imData2 ,

If n 5, Map BitAnd , 7 &, imData2 ;

combined1 wiped1 wiped2;

imData3 ImageData qr3, "Byte" ;

imData4 ImageData qr4, "Byte" ;

wiped3 If n 1, Map BitAnd , 128 &, imData3 ,

If n 2, Map BitAnd , 192 &, imData3 ,

If n 3, Map BitAnd , 224 &, imData3 ,

If n 4, Map BitAnd , 240 &, imData3 ,

If n 5, Map BitAnd , 248 &, imData3 ;

wiped4 If n 1, Map BitAnd , 127 &, imData4 ,

If n 2, Map BitAnd , 63 &, imData4 ,

If n 3, Map BitAnd , 31 &, imData4 ,

If n 4, Map BitAnd , 15 &, imData4 ,

If n 5, Map BitAnd , 7 &, imData4 ;

combined2 wiped3 wiped4;

imData5 ImageData qr5, "Byte" ;

imData6 ImageData qr6, "Byte" ;

wiped5 If n 1, Map BitAnd , 128 &, imData5 ,

If n 2, Map BitAnd , 192 &, imData5 ,

If n 3, Map BitAnd , 224 &, imData5 ,

If n 4, Map BitAnd , 240 &, imData5 ,

If n 5, Map BitAnd , 248 &, imData5 ;

wiped6 If n 1, Map BitAnd , 127 &, imData6 ,

If n 2, Map BitAnd , 63 &, imData6 ,

If n 3, Map BitAnd , 31 &, imData6 ,

If n 4, Map BitAnd , 15 &, imData6 ,

If n 5, Map BitAnd , 7 &, imData6 ;

combined3 wiped5 wiped6;

cImage1 Image combined1 ImageAdjust;

cImage2 Image combined2 ImageAdjust;

cImage3 Image combined3 ImageAdjust;

ColorCombine cImage1, cImage2, cImage3

29

The Algorithm below reads a Color QR.

sfReadColorQR qr , level :

Module alphaExtracted, qrImage, colorSeparated,

binarized, qrscanned, totalData, qrImageSized ,

qrImageSized Image ImageData qr , ImageSize level ;

alphaExtracted ImageData Blur qrImageSized All, All, 1 ;; 3 ;

qrImage Image alphaExtracted ;

colorSeparated ColorSeparate qrImage ;

binarized Map Binarize &, colorSeparated

This function converts any data into Color QR

by using both Color and GreyLevel specified by n.

sfProduceMultiGreyLevelColor6QRWithData data , n :

Module list, length, separated, hp, qrData1,

join1, toCode1, fromCode1, qr1, qrData2, join2,

toCode2, fromCode2, qr2, qrData3, join3, toCode3,

fromCode3, qr3, qrData4, join4, toCode4, fromCode4,

qr4, qrData5, join5, toCode5, fromCode5,

qr5, qrData6, join6, toCode6, fromCode6,

qr6, imData1, imData2, wiped1, wiped2,

combined1, combined2, combined3, imData3,

imData4, wiped3, wiped4, imData5, imData6,

wiped5, wiped6, cImage1, cImage2, cImage3 ,

hp sfBreakStringsIntoN data, 6 ;

qrData1 Flatten Take hp, 1 ;

join1 StringJoin qrData1 ;

toCode1 ToCharacterCode join1 ;

fromCode1 FromCharacterCode toCode1 ;

qr1 BarcodeImage fromCode1, "QR" ;

qrData2 Flatten Take hp, 2 ;

join2 StringJoin qrData2 ;

toCode2 ToCharacterCode join2 ;

fromCode2 FromCharacterCode toCode2 ;

qr2 BarcodeImage fromCode2, "QR" ;

qrData3 Flatten Take hp, 3 ;

join3 StringJoin qrData3 ;

toCode3 ToCharacterCode join3 ;

fromCode3 FromCharacterCode toCode3 ;

qr3 BarcodeImage fromCode3, "QR" ;

qrData4 Flatten Take hp, 4 ;

join4 StringJoin qrData4 ;

toCode4 ToCharacterCode join4 ;

fromCode4 FromCharacterCode toCode4 ;

qr4 BarcodeImage fromCode4, "QR" ;

qrData5 Flatten Take hp, 5 ;

join5 StringJoin qrData5 ;

toCode5 ToCharacterCode join5 ;

fromCode5 FromCharacterCode toCode5 ;

qr5 BarcodeImage fromCode5, "QR" ;

qrData6 Flatten Take hp, 6 ;

join6 StringJoin qrData6 ;

toCode6 ToCharacterCode join6 ;

fromCode6 FromCharacterCode toCode6 ;

qr6 BarcodeImage fromCode6, "QR" ;

imData1 ImageData qr1, "Byte" ;

imData2 ImageData qr2, "Byte" ;

wiped1 If n 1, Map BitAnd , 128 &, imData1 ,

If n 2, Map BitAnd , 192 &, imData1 ,

If n 3, Map BitAnd , 224 &, imData1 ,

If n 4, Map BitAnd , 240 &, imData1 ,

If n 5, Map BitAnd , 248 &, imData1 ;

wiped2 If n 1, Map BitAnd , 127 &, imData2 ,

If n 2, Map BitAnd , 63 &, imData2 ,

If n 3, Map BitAnd , 31 &, imData2 ,

If n 4, Map BitAnd , 15 &, imData2 ,

If n 5, Map BitAnd , 7 &, imData2 ;

combined1 wiped1 wiped2;

imData3 ImageData qr3, "Byte" ;

imData4 ImageData qr4, "Byte" ;

wiped3 If n 1, Map BitAnd , 128 &, imData3 ,

If n 2, Map BitAnd , 192 &, imData3 ,

If n 3, Map BitAnd , 224 &, imData3 ,

If n 4, Map BitAnd , 240 &, imData3 ,

If n 5, Map BitAnd , 248 &, imData3 ;

wiped4 If n 1, Map BitAnd , 127 &, imData4 ,

If n 2, Map BitAnd , 63 &, imData4 ,

If n 3, Map BitAnd , 31 &, imData4 ,

If n 4, Map BitAnd , 15 &, imData4 ,

If n 5, Map BitAnd , 7 &, imData4 ;

combined2 wiped3 wiped4;

imData5 ImageData qr5, "Byte" ;

imData6 ImageData qr6, "Byte" ;

wiped5 If n 1, Map BitAnd , 128 &, imData5 ,

If n 2, Map BitAnd , 192 &, imData5 ,

If n 3, Map BitAnd , 224 &, imData5 ,

If n 4, Map BitAnd , 240 &, imData5 ,

If n 5, Map BitAnd , 248 &, imData5 ;

wiped6 If n 1, Map BitAnd , 127 &, imData6 ,

If n 2, Map BitAnd , 63 &, imData6 ,

If n 3, Map BitAnd , 31 &, imData6 ,

If n 4, Map BitAnd , 15 &, imData6 ,

If n 5, Map BitAnd , 7 &, imData6 ;

combined3 wiped5 wiped6;

cImage1 Image combined1 ImageAdjust;

cImage2 Image combined2 ImageAdjust;

cImage3 Image combined3 ImageAdjust;

ColorCombine cImage1, cImage2, cImage3

30

31

32

33