# How to put a photo in a money bill?

Me and some friends want to make a present for another friend and we want to put pictures of each of us, e.g., me

into a, e.g., one hundert dollar bill (replacing Benjamin Franklin and adequate color correction)

and as a watermark on the white left part of the 20 Euro Bill

I know I could use online stuff, e.g., https://photofunia.com/effects/100_dollars, but I would like to learn how to do this the geeky and fun way with Mathematica. Besides, I would like to print the generating code also for the present. Any ideas?

• You could use image histogram matching to match the colours of the 100 dollar bill. – Rahul Apr 25 '17 at 22:01
• Hmmm... I dont know if I am using it correctly, it does not seem to match the colors very well, or the color space of the bill is just to poor, see drive.google.com/file/d/0B4HppN1nEJ6KOXlEVE8yQWEtYUE/… . – Mauricio Fernández Apr 25 '17 at 22:34
• Ah, my bad. It works better if you transform the face to monochrome, ImageApply[{1, 1, 1} ({0.3, 0.6, 0.1}.#) &, face], and use only the face part of the bill, ImageTrim[bill, First@FindFaces[bill]]. Then you get i.stack.imgur.com/3gBWp.png – Rahul Apr 26 '17 at 22:57

Here's a suggestion for getting the picture of your face to have the proper colors of the bill:

bill = Import["https://i.stack.imgur.com/niI83.jpg"];
face = Import["https://i.stack.imgur.com/1Ub07.jpg"];

billColors = Sort[DominantColors[bill]]

quantize = ColorQuantize[face, 3];

faceColors =
Sort[RGBColor @@ # & /@
DeleteDuplicates[Flatten[ImageData[quantize], 1]]]



While this doesn't address the whole problem, it's one step of it. You might also find the FindFaces function useful as well:

boxes = FindFaces[bill];
HighlightImage[bill, Rectangle @@@ boxes]


but it would take a little more effort to get this to work well.

Hope it helps!

• Thanks! Is the first code block correct? I get an error for ColorReplace. Also, in the second code block, should it be bill instead of i in HighlightImage? – Mauricio Fernández Apr 25 '17 at 21:42
• The first code block works well for me, see puu.sh/vw8EK/526dbd8804.png. And yes, you were correct about my second code bloc, thanks for catching that. – user6014 Apr 25 '17 at 21:51
• Thanks, weird, in my Mathematica version 11.0.1, I get 4 dominant colors for the bill, see drive.google.com/file/d/0B4HppN1nEJ6KSFRWbUg3U0U1UXM/… . You got 3, that was my problem in the arguments of ColorReplace – Mauricio Fernández Apr 25 '17 at 22:00
• Is there any difference between your faceColors and Sort@DominantColors@quantize? – Mauricio Fernández Apr 25 '17 at 22:21
• @MauricioLobos interesting. You can do something like quantize = ColorQuantize[face, Length@billColors] which would work pretty well. Regarding your second question, for some reason the colors look slightly different. Would take some more investigation as to why that is, but for some reason they don't look the same when I examine the underlying numbers that generate the colors. I like the idea though. – user6014 Apr 26 '17 at 0:56