Group Abstract Group Abstract

Message Boards Message Boards

Creating composite ambigrams from Chinese characters in Voxelverse

Posted 4 years ago

enter image description here

If we were to develop three dimensional voxel shanshui (山水) art, then we would definitely need three dimensional voxelized creator and collector stamps when processing transactions. I almost didn't say anything, but Erik Mahieu and Frederick Wu brought up ambigrams in another recent successful team effort. The purpose of this memo (at min) is to uncover a new mathematical conjecture, which occurs when creating composite ambigrams from Chinese characters in the voxelverse.

Here's the scenario.

An exercise involving a $3 \times 3$ matrix.

九gram = "道江湖金水木山自然";
dat = Rasterize[#] & /@ Characters[九gram];
RastToBitmap[im_, trim_] := With[{
   rect = Map[Mod[Mean[#] + 1, 2] &,
     Round[ImageData[im]], {2}]},
  Map[Join[{0, 0, 0}, #, {0, 0, 0}] &,
    rect][[1 + trim ;; -1 - trim, 1 + trim ;; -1 - trim]]]
bitmaps = RastToBitmap[#, 2] & /@ dat;
bitmapIms = Image[Mod[# + 1, 2]] & /@ bitmaps;
Partition[bitmapIms, 3] // Grid  

nine gram

The mission objective that shows up on the teleprompter is to encipher this matrix into the form of $8$ & an extra perfectly decodable voxel ambigrams. The problem (as mentioned by Fredrick) is that the symbols are too high genus for monotonic data to suffice.

Here's the solution I came up with, using the chosen topology of rows + columns + diagonals + knight moves from Square $1$. The lexicon is over three symbols $\{R,G,B\}$ plus another for clear space. After encoding, we can check partial projections:

Partials[gram1_, gram2_, gram3_] := With[{
   dat123 = Position[Outer[
      gram1[[#1, #2]] gram2[[#2, #3]] gram3[[#3, #1]] & ,
      Range[14], Range[14], Range[14], 1], 1]},
  MapIndexed[Function[{grams, ind},
      Complement[RotateRight[#, ind] & /@ Position[
         Outer[grams[[1, #1, #2]] grams[[2, #2, #3]] & ,
          Range[14], Range[14], Range[14], 1], 1], dat123]
      ][#1, #2[[1]] - 1] &, Partition[{gram1, gram2, gram3}, 2, 1, 1]]]

imDat[partials_] := Outer[Image[ReplacePart[
     Table[1, {i, 1, 14}, {j, 1, 14}],
     # -> 0 & /@ #1[[All, #2]]]] &,
  partials[[{2, 3, 1}]], {{1, 2}, {2, 3}, {3, 1}}, 1]

rowDat = Partition[bitmaps, 3];
colDat = Transpose[Partition[bitmaps, 3]];
xDat = {bitmaps[[{1, 5, 9}]], bitmaps[[{3, 5, 7}]], 
   bitmaps[[{1, 6, 8}]]};

rows = Map[imDat[Partials[Sequence @@ #]] &, rowDat];
cols = Map[imDat[Partials[Sequence @@ #]] &, colDat];
diags = Map[imDat[Partials[Sequence @@ #]] &, xDat];

TableForm /@ rows
TableForm /@ cols
TableForm /@ diags

partials

These matrices in themselves have some interesting structure and are worth more detailed analysis, but for now, we need only one superposition function

Superpose[mat_] :=  Map[ImageMultiply@mat[[Complement[Range[3], {#}], #]] &, Range[3]]
TableForm[Superpose /@ #] & /@ {rows, cols, diags}

valid outs

These look correct, but for sake of rigor ++ QA +

MapThread[ImageSubtract[#1, #2] &,
 {Flatten[Superpose /@ rows], bitmapIms}]

MapThread[ImageSubtract[#1, #2] &,
 {Flatten[Superpose /@ cols],
  Flatten[Transpose[Partition[bitmapIms, 3]]]}]

MapThread[ImageSubtract[#1, #2] &,
 {Flatten[Superpose /@ diags],
  bitmapIms[[{1, 5, 9, 3, 5, 7, 1, 6, 8}]]}]

blackbox1 blackbox2 blackbox3

These $9 \times 3$ black boxes mean proof complete, and it may even be possible to recover the secret extra data "knight's move" by comparing regular first two prints, with odd third (proof unknown). More importantly, since this experiment was successful on 9 varied attempts, we have a new mission objective to prove the conjecture that the same process produces perfectly decodable data for any possible bitmap input.

We can also formulate another similar conjecture for fully layered projections. Using the following functions, we obtain new results in three colors:

Ambigram[TriadData_] := With[
{partials = Partials[Sequence @@ #] &@TriadData},
  Graphics3D[ Transpose[{{Blue, Red, Green}, Map[Cuboid, partials, {2}]}]]]

OrthoProj[Ambigram_] :=  GraphicsGrid[
Transpose[Partition[MapThread[Show[Ambigram,
       Boxed -> False, ViewProjection -> "Orthographic", 
       ViewPoint -> #1, ViewVertical -> #2] &,
     {{{0, 0, 1}, {0, 0, -1}, {1, 0, 0}, {-1, 0, 0}, {0, 1, 0}, {0, -1, 0}},
      {{-1, 0, 0}, {-1, 0, 0}, {0, -1, 0}, {0, -1, 0}, {0, 0, -1}, {0, 0, -1}}}], 2]]]

RGBResults[TriadData_] := With[{amb = Ambigram[TriadData]},
  GraphicsRow[Show[#, ImageSize -> 400] & /@ {
     Show[amb, ViewProjection -> "Orthographic",
      ViewPoint -> {1, 1, 1}, Boxed -> False], OrthoProj[amb]}]]

amb1

amb2

amb3

amb4

amb5

amb6

amb7

amb8

amb9

Face first projections appear to be correct, but is this always the case? Does correctness of Black and White projections imply correctness of RGB projections? These questions must be answered, and theorems proven before we can even begin to think about making voxel NFTs for certain choices of three ASCII characters (or about 玄学X).

POSTED BY: Brad Klee
12 Replies
Posted 4 years ago
POSTED BY: Brad Klee
Posted 4 years ago

Counter

Okay guys, I really think you're hassling me on this one little issue but here is a fix:

PadIm[bitmap_, len_, delta_] :=  With[{FixWidth = Join[
  Table[0, {i, Floor[delta[[2]]/2]}],
       #, Table[0, {i, Ceiling[delta[[2]]/2]}]] & /@ bitmap},
  Join[Table[0, {i, Ceiling[delta[[1]]/2]}, {j, len}],
   FixWidth, Table[0, {i, Floor[delta[[1]]/2]}, {j, len}]]]

RastToBitmap[im_, len_] := With[{ rect = Transpose[
        DeleteCases[Transpose[DeleteCases[
        Map[Mod[Round[Mean[#]] + 1, 2] &, ImageData[im], {2}],
        {0 ..}]], {0 ..}]]},   PadIm[rect, len, {len, len} - Dimensions[rect]]]

xuanxue = "玄学";
FullForm /@ Characters[xuanxue]
Image[RastToBitmap[Rasterize[#], 15], ImageSize -> 15*10] & /@ 
 Characters[xuanxue]
Image[RastToBitmap[Rasterize[Style[#, Large]], 18], 
   ImageSize -> 18*10] & /@ Characters[xuanxue]

square chars

Some other functions need also to be changed for variable sized input. Rather than posting essentially the same code again, I have attached a test notebook with a complete implementation. Meanwhile, output data files for frames of the animation above can be found at github. Nomenclature has changed, with introduction of revised "Trigram" function.

Maybe the hassle will be worth something though. Considering how many CJK ideographs there are, plus the crypto market's hyper+hyper++ trending rn, it could be possible soon to launch the richest set of NFTs ever minted, ha ha. Just imagine if we generalize Autoglyphs to 3D, then ReplacePart trigrams into one of $8$ corners. Hopefully block sizes are big enough, IDK just yet, lol. Then again, maybe not.

Attachments:
POSTED BY: Brad Klee

The retreat from RGB to black and white for a better visualizing is best choice we have. I have no further comments at the moment. Go on with your crypto or NFT.

POSTED BY: Frederick Wu
Posted 4 years ago
POSTED BY: Brad Klee

Hi Brad,

As today is weekend, I have more time to introduce you another puzzle.

  • In letter form (see attached PDF Escher) enter image description here

He played a global symmetry transformation of letters like N and Z, or V and L(in Dutch version)

  • In Chinese character form (See the ancient Chinese coin image) enter image description here

On the obverse side, 4 Characters share a square in center, that make the four different Chinese characters “唯吾知足”. (Read ordering: from left to right, from top to bottom). It plays a game of rotation and reflection transformation, partially. On the reverse side, two independent characters “长乐”. All together "唯吾知足长乐" is a phrase and make sense, "I am a man who is contented and will be happy."

Hopefully, that will amuse you and inspired us to develop more puzzles from letters or characters.

Attachments:
POSTED BY: Frederick Wu

Oh, that is I-Ching‘s binary( 伏羲八卦六十四方位图),I thought it was 图(圖)“plot” in traditional form. Usually we state I Ching‘s binary all together like plot below. enter image description here

Well, as for I-Ching‘s binary, I would say instead of brute force, why not "divide and conquer"?

牛B is 牛逼 in short form, 牛郎 is completely different meaning. ^_^ In modern mandarin, there are more and more imported words or letters. So people are used to mix the Chinese characters with English letters or words. E.g. With the latest updating, Brad's code is 牛B-class(Super cool first-class).

POSTED BY: Frederick Wu
Posted 4 years ago

Hi Frederick,

Thanks for the compliment, but why not 牛逼 or 牛郎? Tradition? Don't worry, I have another trigram, which I will release soon, as part of a decryption challenge.

It turns out RastToBitmap does have a problem (try input "i"), but not exactly as you were saying. Here are two updated functions and appropriate usage.

RastToBitmap[im_, len_] := With[{rect =
    Map[Mod[Round[Mean[#]] + 1, 2] &,
     ImageData[ImageCrop[im]], {2}]},
  PadIm[rect, len, {len, len} - Dimensions[rect]]]

Hexagram[uniHex_, scale_] := With[{
   hex = ReplacePart[RastToBitmap[Round[Rasterize[uniHex]], 16], {
      {1, _} -> 1, {16, _} -> 1, {_, 1} -> 1, {_, 16} -> 1}]},
  ArrayFlatten[Map[Table[#, {i, scale}, {j, scale}] &,
    ReplacePart[hex, Join[{#, 3} -> hex[[#, 4]] & /@ Range[16],
      {#, 14} -> hex[[#, -4]] & /@ Range[16]]], {2}]]]

fix

SeedRandom["opinion"]
RandHex =  RandomSample[
   FromCharacterCode[#, "Unicode"] & /@ Range[19904, 19967], 1][[1]]
Image[Hexagram[RandHex, #]] & /@ Range[4]

big family

Interoperability with hexagrams requires content size power of $2$ g.t.e. $16$.

Some chatter today about whether RandomSample could/should be weaponized for whatever imaginary fight tends to be happening again and again. If you're also annoyed by that, use SeedRandom for Reproducibility (almost as important to science as originality). The problem here, with a sample size only $64$, is possibility to brute force search until a desired hit is found. So I just said okay "let's just go from the last word of Frederick's nice post, opinion". Lucky output, because it is possible to get burnt casting yarrow stalks.

POSTED BY: Brad Klee

Hi Brad,

I found a bug for you.

The pixel data through function bitmapsL should be in dimension {16,16} but it wasn't. It's in {22,23}. So It results the 1st and 2nd character only top-left half-data-plot. enter image description here

At the moment, I just resize the dimension in next line of code, then all the rest works well.

bitmapsL = 
 ImageData[Binarize@ImageResize[Image[#], {16, 16}]] & /@ bitmapsL1

But you need to check and verify the function bitmapsL. I upload the notebook for you.

It might be caused by your changing something, but not all variables are completely updated in your notebook. I recommend you to add a Initializing cell at top for clearing all global variables, then automatically evaluate all cells again.

Clear["Global`*"];

It is not just a compliment, I really think it is 牛B. The old-fashion puzzle are probably unchanged for decades. You are reinventing the puzzle and solve it, Now you try to find a theorem from it. So it is 牛B in my opinion.

Attachments:
POSTED BY: Frederick Wu
Posted 4 years ago
FullForm /@ Characters["玄学"]
Flatten[Outer[Rasterize[Style[#1, #2]] &, 
  Characters["玄学"], {{}, Small, Medium, Large}, 1]]
Partition[ImageDimensions /@ %, 4] // MatrixForm

sizes out

Notice, there are two distinct renders for each character, and changing style size changes padding. The inflexible function may need to be rewritten to identify bounding box, take contents, then pad with white space. Would be interesting to look at higher precision models. Slab size $128^3 \sim 10^6 vox$ seems like a reasonable bound for number of multiplications. For now, $9+2$ 2D characters used so far can be recovered by projecting from data found here.

Thanks for the compliment, happy holidays!

Enjoy year of the OX until February 1, 2021.

--Brad

POSTED BY: Brad Klee
Posted 4 years ago

Same issue for me on "12.3.1 for Mac OS X ARM (64-bit) (July 8, 2021)".

POSTED BY: Rohit Namjoshi

Hi Brad,

Thanks for your kindly explanation.

My version still runs with some warnings, so I check it on Wolfram Cloud, It's same warning. I uploaded my notebook and Wolfram Cloud images. enter image description here

The diagonal finding is absolutely big progress for this puzzle. Congratulation! Character pixel like "---"," | “, works only in one direction, but fails in another. Projection to row and column must be full.So," / "or " \ " can works in both directions, then "C" or "S" that might be also works.

In my opinion, your project is 牛B (Super-cool) !

Attachments:
POSTED BY: Frederick Wu
POSTED BY: Frederick Wu
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard