Hi all,
I'm writing code to take a bunch of images and concatenate them into one
big image (you can see the attached picture for an example of what this can
look like).
The code I wrote to generate the above picture is fairly hideous; I arrived
at it after trying a number of approaches that seemed more natural and then
giving up in despair.
The code I initially wanted to write looked something like this:
grid = Char[
'A' 'B' 'C' 'D' 'E';
'F' 'G' 'H' 'I' 'J';
'K' 'L' 'M' 'N' 'O';
'P' 'Q' 'R' 'S' 'T';
'U' 'V' 'W' 'X' 'Y';
'Z' 0 0 0 0 ;
]
arr = map(c -> c == 0 ? zeros(Ufixed8, 64, 64) : convert(Array,
imread("$prefix/sdf/$c.png")), grid)
imwrite(arr, "$prefix/atlas.png")
This approach fails in imwrite because the individual elements in the array
are themselves arrays, rather than numbers. I couldn't figure out a way to
flatten the resulting array-of-arrays into a single matrix and ended up
writing code that preallocates a big matrix of the right output size and
assigns to calculated subranges in a loop.
My background is in user interface design and web programming, and right
now I'm fairly new to writing matrix-manipulation code. If there's a
natural way to express this computation in Julia I'd love to know.
Cheers,
Yuri