comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » making a checkerboard array?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: making a checkerboard array? [message #55985 is a reply to message #55935] Wed, 26 September 2007 10:27 Go to previous messageGo to previous message
JD Smith is currently offline  JD Smith
Messages: 850
Registered: December 1999
Senior Member
On Tue, 25 Sep 2007 15:52:33 -0600, David Fanning wrote:

> JD Smith writes:
>
>>> I'm trying to make a checkerboard mask for an array, but I'm missing
>>> something that is likely to be obvious to the IDL array masters.
>>
>> l=lindgen(nx,ny)
>> l=(l mod (xside*2) lt xside) XOR (l/nx mod (yside*2) ge yside)
>
> Well, uh, it's not obvious to me. :-(


Well, l mod (xside*2) produces a horizontal ramp from 0... xside*2,
repeating over and over, the same for each row (as long as the array
width is an even multiple of xside). Comparing this ramp to xside,
ala (ramp lt xside) produces alternating vertical bars of width xside.
Similarly for l/nx (the row number), producing alternating horizontal
bars of height yside. Put them on top of each other and you have a
lovely quilt pattern. But we don't want a quilt, we want a
checkerboard, i.e. we want only those spots where the two bar patterns
don't overlap, hence the exclusive or (XOR).

In case that wasn't clear, here it is dfanning style ;)

theRamp = LINDGEN( theNumberofXPixels , theNumberofYPixels )
theCheckerBoardHorizontalPeriod = 2 * theCheckWidth
theHorizontalRamp = theRamp MOD theCheckerBoardHorizontalPeriod
theHorizontalBands = theHorizontalRamp LT theCheckWidth

theRowNumbers = theRamp/theNumberofXPixels
theCheckerBoardVerticalPeriod = 2 * theCheckHeight
theVerticalRamp = theRowNumbers MOD theCheckerBoardVerticalPeriod
theVerticalBands = theVerticalRamp GE theCheckHeight

theCheckerBoard = theHorizontalBands XOR theVerticalBands

JD
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Parsing C -> Generating DLL/DLM
Next Topic: selection box in widget program

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sun Oct 12 06:40:22 PDT 2025

Total time taken to generate the page: 1.59955 seconds