Creating artistic QR Codes and color threshold...

421 views
Skip to first unread message

Ricardo1980

unread,
Jan 8, 2011, 9:21:49 PM1/8/11
to zxing
Hello mates!

Just a question.
I see on the Internet many QR Codes with a lot of colors.
http://www.google.com/images?oe=UTF-8&gfns=1&q=qr+code+art&um=1&ie=UTF-8&source=og&sa=N&hl=es&tab=wi&biw=1920&bih=959

Most of them can be read by zxing and the iPhone without problems, for
instant, surprisingly this one can be read perfectly:
http://blogofpatrick.files.wordpress.com/2010/04/dots_qr_color.jpg

So, I wonder, how can I create QR Codes plenty of colors, I mean,
instead of a boring black and white matrix.
Using libqrencode, my iPhone app can create qr codes, just a black/
white matrix, but how could I add more color without affecting the
reading quality or vision algorithm?

What does the artificial vision algorithm in order to differentiate a
black square from a white square?
Perhaps (I have no idea), captured image is transformed to grayscale
and if a pixel is >0.5 then is white, otherwise is black, am I right?

Another more advance topic could be, what about circles instead of
squares, and what about 2 colors per square/circle? inner and outside,
similar to the example I told you. What do you think?

I would like to know what you think about this topic.
Thanks for replies.

Daniel Switkin

unread,
Jan 10, 2011, 4:15:16 PM1/10/11
to zx...@googlegroups.com
ZXing operates on all images as 1 bit, i.e. each pixel is black or white. So you can certainly use colors as long as the contrast between the foreground (the barcode) and the background is big enough.

Ricardo Ruiz

unread,
Jan 10, 2011, 6:25:09 PM1/10/11
to zx...@googlegroups.com
Thanks for reply!

How much is "big enough"? In numbers, of course.

Here you can see my first artistic qr code:

Does anyone know exactly how artificial vision algorithm works?
Does it convert images to grayscale using this formula?
float gray = color.r * 0.3 + color.g * 0.59 + color.b *0.11;  


De: Daniel Switkin <dswi...@google.com>
Para: zx...@googlegroups.com
Enviado: lun,10 enero, 2011 22:15
Asunto: Re: Creating artistic QR Codes and color threshold...

Steven Parkes

unread,
Jan 10, 2011, 6:46:37 PM1/10/11
to zx...@googlegroups.com
> How much is "big enough"? In numbers, of course.

There's no answer to this. There's no way to argue definitively: the algorithm has heuristics in it and they'll do whatever they do. Even that is subject to whatever the camera gets based on lighting conditions and brightness adjustment. As Daniel mentioned, in the end you get a bit matrix, but that happens by mapping a color image to a grayscale image to a binary image (and finally to a sampled matrix).

The algorithm is pretty highly tweaked ... in fact there are multiple. The default algorithm (did this change recently? I've been meaning to check; I think I remember hearing about a new binarizer) deals with blocks of pixels rather than each pixel individually in order to adapt to variations in dynamic range across an image, e.g., due to shadows. The qr decoder is also more sensitive to errors in different parts of the image, e.g., the finders.

> Does anyone know exactly how artificial vision algorithm works?
> Does it convert images to grayscale using this formula?
> float gray = color.r * 0.3 + color.g * 0.59 + color.b *0.11;

This depends on the platform since it's handled in platform-dependent code. I believe in general this is what they do, though.

Ricardo Ruiz

unread,
Jan 10, 2011, 8:00:39 PM1/10/11
to zx...@googlegroups.com
Thanks.
So, should I start an empirical process looking for the best color factors and different enviroment lights?


De: Steven Parkes <smpa...@smparkes.net>
Para: "zx...@googlegroups.com" <zx...@googlegroups.com>
Enviado: mar,11 enero, 2011 00:46

Asunto: Re: Creating artistic QR Codes and color threshold...

Daniel Switkin

unread,
Jan 11, 2011, 3:53:11 PM1/11/11
to zx...@googlegroups.com
I'd try some experiments with our online decoder (which I apologize is probably out of date):


and see what works reliably.

Daniel

Ricardo Ruiz

unread,
Jan 11, 2011, 8:00:09 PM1/11/11
to zx...@googlegroups.com
If you discover anything, you know were to talk about it :)


De: Daniel Switkin <dswi...@google.com>
Para: zx...@googlegroups.com
Enviado: mar,11 enero, 2011 21:53

Asunto: Re: Creating artistic QR Codes and color threshold...

Ilan Singer

unread,
Jan 13, 2011, 4:59:32 PM1/13/11
to zx...@googlegroups.com
Does anyone have the code that extract QR code from an image?

Lachezar Dobrev

unread,
Jan 13, 2011, 5:37:27 PM1/13/11
to zx...@googlegroups.com
You should be able to use com.google.zxing.qrcode.detector.Detector
to detect the code, or use the result points on successful read.

2011/1/13 Ilan Singer <ilan....@gmail.com>:

Ilan Singer

unread,
Jan 13, 2011, 5:57:05 PM1/13/11
to zx...@googlegroups.com
Is that a Web site URL?

Ricardo Ruiz

unread,
Jan 13, 2011, 6:58:35 PM1/13/11
to zx...@googlegroups.com
Hahahaha. I don't think so.


De: Ilan Singer <ilan....@gmail.com>
Para: zx...@googlegroups.com
Enviado: jue,13 enero, 2011 23:57

Asunto: Re: Creating artistic QR Codes and color threshold...

Ilan Singer

unread,
Jan 13, 2011, 7:37:26 PM1/13/11
to zx...@googlegroups.com
how'd you get the code?

Lachezar Dobrev

unread,
Jan 14, 2011, 8:11:18 AM1/14/11
to zx...@googlegroups.com
The com.google.zxing.qrcode.detector.Detector is a Java class part
of the ZXing core library.

The library is Open Source, and the code can be found in the code
repository. I am not going to go into further detail. Visit
http://code.google.com/p/zxing/source/checkout for a brief instruction
for code checking-out.

However the question you're asking shows, that you're probably not a
Java software developer. Libraries are not used by end users, but
rather applications, that the end users use.

2011/1/14 Ilan Singer <ilan....@gmail.com>:

streetview99

unread,
Jan 14, 2011, 6:54:38 PM1/14/11
to zxing
Ricardo That's a good question. How big is big enough. We need a
widget we can drop a qr code into & adjust contrasts w/ different
colors / shapes & get a qr image into a reasonable readabl;e range w/
out having to test endlessly. A custom qr code (image) builder w/ an
instant readability display. Tall order...

On Jan 14, 8:11 am, Lachezar Dobrev <l.dob...@gmail.com> wrote:
>   The com.google.zxing.qrcode.detector.Detector is a Java class part
> of the ZXing core library.
>
>   The library is Open Source, and the code can be found in the code
> repository. I am not going to go into further detail. Visithttp://code.google.com/p/zxing/source/checkoutfor a brief instruction
> for code checking-out.
>
>   However the question you're asking shows, that you're probably not a
> Java software developer. Libraries are not used by end users, but
> rather applications, that the end users use.
>
> 2011/1/14 Ilan Singer <ilan.sin...@gmail.com>:
>
> > how'd you get the code?
>
> > On Thu, Jan 13, 2011 at 6:58 PM, Ricardo Ruiz <ricardo_ruiz_lo...@yahoo.es>
> > wrote:
>
> >> Hahahaha. I don't think so.
> >> ________________________________
> >> De: Ilan Singer <ilan.sin...@gmail.com>
> >> Para: zx...@googlegroups.com
> >> Enviado: jue,13 enero, 2011 23:57
> >> Asunto: Re: Creating artistic QR Codes and color threshold...
>
> >> Is that a Web site URL?
>
> >> On Thu, Jan 13, 2011 at 5:37 PM, Lachezar Dobrev <l.dob...@gmail.com>
> >> wrote:
>
> >>>  You should be able to use com.google.zxing.qrcode.detector.Detector
> >>> to detect the code, or use the result points on successful read.
>
> >>> 2011/1/13 Ilan Singer <ilan.sin...@gmail.com>:
Reply all
Reply to author
Forward
0 new messages