Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
|
|
Re: coloured checkerboard
Posted:
Apr 17, 2012 6:27 PM
|
|
ImageAnalyst <imageanalyst@mailinator.com> wrote in message <35c6f6aa-5193-4431-8491-81b14c57b8e1@r9g2000yqd.googlegroups.com>... > I'd probably make one colored square and one white (or black) square > stitched together. Then use repmat() to replicate that pair to > complete the checkerboard.
Thanks. I did manage to figure this out soon after posting my question, though I'm still not sure I'm doing it as efficiently as possible. Despite what I originally said, I have decided it is simpler to index into the colormap.
I have d colours, not one and not two. My procedure is to stitch together d squares, each kxk and each with its own colour, in a column. This is now a d*k by k matrix. Using circshift(columnAlreadyConstructed,k) and stitching, I get a d*k x 2*k matrix. Applying circshift(matrixAlreadyConstructed, 2*k), I get a d*k x 4*k matrix. Continue like this until 2 to the appropriate power is greater than d. Cut the matrix down to a d*k by d*k matrix. Then use repmat to fill out the matrix completely. This actually gives a matrix that will be bigger than the original MxN asked for, but one can just take the first M rows and N columns.
That's the best I can do for now. I was missing circshift when I posted my question. I need to make these chequerboards as quickly as possible, because my code uses the operation quite often.
|
|
|
|