Path: news.mathworks.com!not-for-mail
From: "David Epstein" <David.Epstein.spam@remove.warwick.ac.uk>
Newsgroups: comp.soft-sys.matlab
Subject: Re: coloured checkerboard
Date: Tue, 17 Apr 2012 22:27:07 +0000 (UTC)
Organization: Univ of Warwick
Lines: 10
Message-ID: <jmkqnr$pmo$1@newscl01ah.mathworks.com>
References: <jmkf6l$apu$1@newscl01ah.mathworks.com> <35c6f6aa-5193-4431-8491-81b14c57b8e1@r9g2000yqd.googlegroups.com>
Reply-To: "David Epstein" <David.Epstein.spam@remove.warwick.ac.uk>
NNTP-Posting-Host: www-01-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1334701627 26328 172.30.248.46 (17 Apr 2012 22:27:07 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 17 Apr 2012 22:27:07 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 319959
Xref: news.mathworks.com comp.soft-sys.matlab:764932

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.