Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: coloured checkerboard
Replies: 5   Last Post: Apr 18, 2012 6:18 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
David Epstein

Posts: 84
Registered: 12/24/07
Re: coloured checkerboard
Posted: Apr 17, 2012 6:27 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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.



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.