knowloffsetrect

offsetrect  时间:2021-02-21  阅读:()
BehaviorResearchMethods,Instruments,&Computers1996,28(4),611-621Simplealgorithmsforcreatingrandom-elementstereogramsontheMacintoshJOHNA.
BAROWheelingJesuitUniversity,Wheeling,WestVirginiaTraditionally,thecreationofrandom-elementstereo-gramsisacomputation-intensiveprocess.
However,bytakingadvantageofroutinesbuiltintotheMacintoshop-eratingsystem,multiple-depthstereogramanaglyphscanbeeasilycreatedfromanyblack-and-whiteorgrayscaleimage.
Anycomplexshapecanbeselectedfromthepat-ternandoffsetinoneeye'sviewrelativetotheother'stocreatetheillusionofdepth,withouttheneedtocalculateoffsetsonanelement-by-elementbasis.
Random-elementstereograms,firstdescribedbyJulesz(1971),areaspecialtypeofstereogrammadeupoftwosetsofsmall,randomlyplacedelements.
Formanyoftheseelements,thereisanexactmatchintheimagesseenbythetwoeyes.
Thereare,however,otherelementsinoneimageshiftedeithertotherightorleftrelativetothepositionsofthematchingelementsintheotherimage.
Thisshiftinpositionofsomeoftheelementscreatesadifference,ordisparity,betweentheimagesseenbythetwoeyes.
Thoseareasthatcontainadisparityareperceivedtobeindepth,relativetothosethathavenodisparity.
Thistypeofpatternisespeciallyinterestingtovisionscientistsbe-causeeachofthetwoimagesalonecontainsnoapparentorganizationorform.
Theformis"created"bythevisualsystem,whichperformsthecomplexcalculationsneededtomatchuptheelementsviewedbyeacheyeandcreatetheperceptionofformanddepth.
Onemeansofviewingthesestereogramsistoplacethetwoimagessidebysideandviewthemthroughprisms,sothat,visually,theyap-peartooccupythesamepositioninspace.
Analternativemethodistotintoneoftheimagesredandtheothergreen(anydissimilarcolorswilldo),thenphysicallysuperim-posethetwoimages.
Thistypeofstereogramiscalledan"anaglyph"andisviewedthroughredandgreenlenses-inthisway,each"half"ofthecombinedimageisseenbyonlyoneeye.
Thecreationofrandom-elementstereogramsistradi-tionallyaverycomputation-intensiveprocess.
Theposi-tionsofthousandsofelements(i.
e.
,typicallydots)needtobecalculatedandoffset,basedonalgorithms,tocreateAppleandMacintosharetrademarksofAppleComputer,lnc.
,reg-isteredintheUnitedStatesandothercountries.
QuickDraw,Mac,andMacOSaretrademarksofAppleComputer,Inc.
PowerPCisatrade-markofInternationalBusinessMachinesCorporation.
CodeWarriorisatrademarkofMetrowerks,Inc.
Allothertrademarksaretheprop-ertyoftheirrespectiveowners.
Correspondenceshouldbeaddressedto1.
A.
Baro,NASAClassroomoftheFuture,WheelingJesuitUni-versity,Wheeling,WV26003(e-mail:jabaro@cotf.
edu).
regionsofdisparitybetweentwosetsofotherwiseiden-ticalelements.
Fortunately,theMacintoshToolbox(thesetofroutinesthatmakeuptheMacintoshOperatingSys-tem,orMacOS)containsfunctioncallsthatcangreatlysimplifythisprocessofcreatingrandom-elementstereo-grams.
Ratherthangeneratingpatternsofdisparitiesalgo-rithmicallytocreate3-Dforms,stereogramsofarbitrarycomplexitycaneasilybegeneratedfromblack-and-whiteorgrayscaleimages.
Whenablack-and-whiteimageisusedtorepresentdepthinastereogram,itwillhaveonlytwolevelsofdepth(i.
e.
,twooffsetsordisparities),onedepthcorrespondingtotheblackregionsoftheimageandtheotherdepthcorrespondingtothewhiteregions.
Whenagrayscaleimageisused,thestereogramcanhaveanynumberofdepthlevels,eachdepthlevelcorrespondingtoagraylevelintheimage.
Formostpracticalpurposes,however,15levelsofdepth(disparitiesrangingfrom-7to+7pixels)aresufficient.
Disparitieslargerthanabout8-10pixelsaredifficultfortheviewertofuseundermostcircumstances.
Todistinguishbetweenthestereogramsgeneratedfromthetwotypesofimages,thosebasedonblack-and-whiteimageswillbereferredtoas"simple"stereograms,havingonlytwolevelsofdepth,andthosebasedongrayscaleimageswillbereferredtoas"complex"stereograms,havingmultiplelevelsofdepth.
Theblack-and-whiteorgrayscaleimageusedtocreatethestereo-gramwillbereferredtoasthe"mask.
"Maskimagescanbecreatedinanycolorpaintordraw-ingprogram.
'IfthemaskissavedinPICTformat,ratherthanintheprogram'snativeformat,thenitisasimplemattertoopenuptheimageinyourprogram.
ThePICTfileformatspecificationandsamplecodesegmentsthatillustrateopeningandsavingPICTfilesareprovidedinInsideMacintosh:ImagingwithQuickDrawandFiles(AppleComputer,Inc.
[Apple],I992a,1994).
Itisas-sumedthatthereadercanwritethenecessarycodetoloadaPICTfilefromdisk(orcreateone"onthefly")anddrawit.
Theexamplesbelowillustratehowtocreatetheoffscreenenvironmentinwhichamaskimageisdrawn,buttheydonotillustratehowtoloadordrawtheImage.
Theexamplesdescribedhereillustratehowtocreatestereogramsinanaglyphformonthecomputer'sdisplay;thatis,withredandgreenportionsthatareviewedwithcoloredlenses(viewingglassesareavailablefrommostoptometricsupplycompanies).
Thediscussionofthesam-plecodesegmentsandalgorithmsbelowislimitedtotheToolboxroutinesusedinconjunctionwithcreatinganddisplayingstereograms.
Basicgraphicsandothercom-monlyusedToolboxfunctionsarenotdescribed.
RefertoInsideMacintoshforinformationaboutunfamiliarrou-tines.
Itisassumedthatthereaderhasaworkingknowl-edgeofMacintoshprogramming,isfamiliarwithcom-monlyusedToolboxroutines,andisfamiliarwithaPascalcompiler(translationtoCisfairlystraightforwardifthat611Copyright1996PsychonomicSociety,Inc.
612BAROlanguageispreferred).
SomeofthecodesegmentswerecreatedinThinkPascalandothersinCodeWarriorPas-cal(commentsineachindicateinwhichenvironmentacodesegmentwascreatedandcompiled).
IncaseswherePowerPCnativecodediffersfromthecorresponding68kcode,thePowerPCcodeisusedandthe68kcodeisin-cludedinacomment.
Allcodesegmentsarecompatiblewithandwillrunonanycolor-capableMacintoshwithSystem7.
0orlaterandadisplaywith256ormorecolors(theyshouldalsoworkwithSystem6.
x,with32-bitQuickDraw;however,theyhavenotbeentestedwithsuchaconfiguration).
Refertothe"GestaltManager"chapterinInsideMacintosh:OperatingSystemUtilities(Apple,1992b)forinformationondeterminingthema-chine'ssystemconfiguration.
OtTscreenGWoridsOffscreengraphicsworlds(GWorlds)areusedbytheMacOStostoregraphicsdatathatdonotappearonscreen(seeApple,1994).
Withtheadventof32-bitQuickDraw,thecreation,maintenance,andmanipulationofGWorldsbecamequitesimple.
Invirtuallyallrespects,anoffscreen{ThinkPascal}varGWorldbehavesidenticallytoanonscreenwindow.
Alldrawingandothergraphicsoperationsfunctioninthesamewaywitheither.
ThecreationofaGWorldrequiresonlyasingleTool-boxcall,NewGWorld(varoffscreenGWorld:GWorldPtr;pixelDepth:integer;boundsRect:rect;cTable:CTab-Handle;aGDevice:GDHandle;flags:GWorldFlags).
AhandletothenewlycreatedGWorldisreturnedinthevariableoffscreenGWorld.
TheremainingparametersdefinetheGWorld:pixelDepth-numberofbitsperpixel;boundsRect-sizeandpositionofthepixMap;cTable-eolortable,usenilforthedefault;aGDevice-graphicsdevice,useniltocreateanewdevice;andflags-additionalparameters.
Additionalroutinesusedtomod-ifyandmaintainaGWorld,suchasUpdateGWorld,willnotbediscussedhere.
OnceaGWorldiscreated,draw-ingoperationscanbedirectedtoitbycallingSetGWorld(port:CGrafPtr;gdh:GDHandle),whereportandgdharetheparametersusedintheNewGWorldcall(offscreenGWorldandaGDevice).
DrawingisredirectedbacktoanonscreenwindowbycallingSetGWorldagain,pass-ingtoitparametersthatpointtothewindow.
OSDev:GDHandle;err:QDErr;redOSWorld,greenOSWorld,flag:GWorldFlags;pictRect:rect;myColorTable:CTabHandle;myPalette:PaletteHandle;maskOSWorld:GWorldPtr;{settosizeoftheimage}{custom-16colors}{custom-16colors}flag:;[];{defaultflagsettings}SetRect(pictRect,0,0,639,479);InsetRect(pictRect,-10,0);{biggeroffscreenrecttoshiftdots}err:;NewGWorld(redOSWorld,4,pictRect,myColorTable,nil,flag);iferrnoErrthenbegin{handletheerror}end;SetPalette(GrafPtr(redOSWorld),myPalette,true);OSDev:;GetGWorldDevice(redOSWorld);{usesamedeviceforgreendots}flag:;[noNewDevice];err:;NewGWorld(greenOSWorld,4,pictRect,myColorTable,OSDev,flag);iferrnoErrthenbegin{handletheerror}end;SetPalette(GrafPtr(redOSWorld),myPalette,true);flag:;[];err:;NewGWorld(maskOSWorld,iferrnoErrthenbegin{handletheerror}end;{maskGWorldmustbe16bits}16,pictRect,nil,nil,flag);Listing1.
SetupthreeofTscreenGWorlds.
Thefirsttwo,redOSWorldandgreenOSWorld,arewheretheredandgreendotsaredrawn.
Theirbitdepthis4(16colors)andtheyuseacustomcolortable.
SincebothoftheseGWorldsarethesamesizeandusethesamecolortable,theycanshareaGDevice.
ThelastGWorld,maskOSWorld,iswherethemaskisdrawn.
AccordingtoInsideMacintosh(1994),amaskcanbeanybitdepth;however,experiencehasshownthatthesealgorithmswillonlyworkcorrectlywitha16-bitmask.
SettingThingsUpPreparationsforthecreationofsimple(twodepthlev-els)andcomplex(multipledepthlevels)stereogramsaresimilar.
Unlessotherwiseindicated,thefollowingdiscus-sionappliestobothcases.
ThreeGWoridsarerequired,oneforthereddotportionoftheimage,oneforthegreendotportion,andoneforthemask(additionalGWoridsareneededforcomplexstereograms,asdescribedbelow).
Listing1illustratesthecreationoftheseGWorids.
TheGWoridsredOSWoridandgreenOSWoridarewherethereddotandgreendotportions,respectively,ofthestereo-gramaredrawn.
Thesearelatercombinedtocreatethecompositeanaglyph.
Themask,usedtoindicatewhichareasoftheimagearedrawnatwhichdepthlevel,isdrawninmaskOSWorid.
Sinceonlyfourcolorswillbeusedinthecompositeimage(red,green,yellow,andblack),red-OSWoridandgreenOSWorldarecreatedwithabitdepthof4(16colors),andareassignedacustom4-bit(16-color)colortable(refertoBaro&Hughes,199I,forex-MACINTOSHSTEREOGRAMS613amplesoftheprogrammaticcreationofcolortables,orusetheToolboxfunctionGetCTabletoloadanexistingcolortableresource).
TheGWoridinwhichthemaskisdrawn,maskOSWorld,iscreatedwithabitdepthof16(al-thoughInsideMacintosh(1994)indicatesthatmaskscanbedrawnatanydepth,theseroutinesworkcorrectlyonlywhenthemaskisdrawnat16bits).
OncetheGWoridsarecreated,theappropriateim-agesmustbedrawninthem.
Forsimplestereograms,onceamaskimageisloaded(orcreated),itisdrawninmaskOSWoridjustasitwouldotherwisebedrawninawindowonscreen.
Theprocessusedtocreateamaskforacomplexstereograminvolvesadditionalsteps,asde-scribedbelow.
TheimagesdrawninredOSWoridandgreenOSWoridareidentical,exceptthatinredOSWoridtheforegroundcolorissettored,andingreenOSWoridtheforegroundcolorissettogreen(thesecolorsshouldbeselectedtobestmatchthelensesinyourviewingglasses).
Listing2illustrateshowtocreateandfillthe{ThinkPascal}{globaldefinitions)typeDotBackType~packedarray[-lO.
.
650,O.
.
480Jofboolean;DotBackTypePtrADotBackType;DotBackTypeHdl=ADotBackTypePtr;vardotBack:DotBackTypeHdl;dotProb:integer;constNumDotsH640;NumDotsV=480;{indicateswhethera){givenpixelcontains){adot.
){setupdotsarray-usesahandlesoarraysizeisnotlimited)dotBack:=DotBackTypeHdl(NewHandle(SizeOf(DotBackType)));if(dotBack~nil)thenbegin(handletheerror)end;dotProb:=2;{probabilitythatagivenpixelwillcontainadotis0.
5)procedureFillDotArray;vari,j:integer;beginGetDateTime(randSeed);fori:=-10toNumDotsH+10dobeginforj:=0toNumDotsVdobeginifabs((RandommoddotProb))dotBackAA[i,j]trueelsedotsack""[i,jJfalse;end;end;end;{FillDotArray){seedsrandomnumbergenerator){addextradotssoimagecanbeshifted)othenListing2.
Setupandfilldotsarray.
Abooleanarrayisusedtodeterminewheredotsaredrawn.
Toavoidpo-tentialmemorylimitations,itisgenerallyagoodideatoreferencealargearraywithahandle.
Inthisexample,theimagewillbe640x480pixels,sothearrayneedstobepaddedhorizontallytoenableshiftingofthedotimagesbe-yondtheboundariesofthemaskimage.
Inthiscase,thedotscouldbeshiftedbyupto10pixelstotherightorleft.
Anegativearrayindexisusedtosimplifythings-theoriginofthemaskanddotimagesisalwayszero.
Aproba-bilityvalue(dotProb)determineshowdensethedotsare.
Avalueof2indicatesthat,overall,50%ofthearraypo-sitionswillcontainadot.
Asthisvalueincreases,dotdensitydecreases.
614BAROarraysusedtodrawthedots.
Inthisexampletheimagesizeis640X480pixels,sothearray,dotBack,is660X480elementsinsize.
Thispermitspaddingofthedotim-agestotheleftandright(arrayindicesrangefrom-10to650)by10pixels,themaximumamountofdisparitypermittedinthisexample.
Thebooleanvaluesinthearrayarerandomlyset,basedonthevalueofthevariabledot-Prob,whichdetermineshowdenselythedotsaredrawn.
Avalueof2indicatesthatabouthalfthedotswillbedrawn;thehigherthisvalueis,thefewerdotsthatwillbedrawn.
Thearrayisreferencedviaahandletopreventpotentialmemoryproblems.
Whenanarrayisreferenced{ThinkPascal}procedureDrawDotBacks;constBlackColor=15;BrightRed=1;BrightGreen=5;vark,1,x,y,dotSize:integer;tempRect:recticurrDev:GDHandle;currPort:CGrafPtr;begindotSize:=2;GetGWorld(currPort,currDev);inthisway,itssizeisunlimitedandthesystemwillbepermittedtomoveitaroundinmemoryifnecessarytopreventmemoryfragmentation.
Theredandgreendotimagesareerasedtoblackbe-forethedotsaredrawninListing3.
Asimpleloopstepsthroughallthepixelsintheimage,firstforthereddotportion(drawninredOSWorld),andthenforthegreendotportion(drawningreenOSWorld).
Ifanarrayele-mentistrue,adotisdrawn;otherwisethepixelisleftblack.
NotethatbeforeonedrawsinaparticularGWorld,drawingmustberedirectedwithacalltoSetGWorld.
Sincebothdrawingloopsareidentical,withtheexcep-{colorconstantsarebasedona}{custom16-colorpalette}{dotsize,inpixels}{saveforlater}SetGWorld(redOSWorld,OSDev);PMForeColor(BrightRed);PMBackColor(BlackColor);EraseRect(redOSWorldA.
portRect);{eraseinblack}x:=-10;y:=0;fork:=-10to(NumDotsH+10)divdotSizedo{drawthereddots}beginy:=0;for1:=0to(NumDotsV)divdotSizedobeginifdotBackAA[k,1]thenbeginSetRect(tempRect,x,y,x+dotSize,y+dotSize);PaintRect(tempRect);end;y:=y+dotSize;end;x:=x+dotSize;end;{repeatthesectionmarkedbyasterisks,thistimewiththeGWorldset}{togreenOSWorldandwiththeforegroundcolorsettogreen}SetGWorld(currPort,currDev);end;{DrawDotBacks}{resetGWorld}Listing3.
Drawtheredandgreendotpatterns.
ThisproceduredrawstheredandgreendotsintheirrespectiveoffscreenGWorlds.
Beforedrawing,eachareaiserasedinblack.
Thesizeofthedotscanbevariedandisautomaticallytakenintoaccountduringdrawing.
Sincebothdrawingroutinesareidentical(withtheexceptionofwhichGWorldisdrawninto),thesecondpartoftheprocedurehasbeenomittedinthislisting.
tionoftheforegroundcolorandGWorldsettings,thesecondpartoftheroutinehasbeenomittedforbrevity.
Alsonoticethatdotsizecanbevariedintheroutine;inthisexample,thedotsare2X2pixels.
CopyBitsandCopyDeepMaskThemostcommonmethodusedtotransferimagesbackandforthbetweenwindowsandGWorldsusestheToolboxroutineCopyBits(seeApple,1994).
CopyBitscopiesaspecifiedrectanglefromoneGWorldorwindowtoanother.
IttakesasparameterspointerstothesourceanddestinationgrafPorts,thesourceanddestinationrectan-gles,thecopymode(inthiscase,srcCopy),andamaskre-gion(inthiscase,settonil).
ThefirststepincreatingacompositeanaglyphistouseCopyBitstodrawtheentirereddotportionoftheimage.
Thesecondstepisalittlemorecomplex.
First,thegreendotportionoftheimagemustbeoverlaidontothereddotportion.
Whenbotharedandgreendotaretobedrawninthesameposition,theircol-orsmustaddtogether,creatingayellowdot.
Todothis,thecopymodeaddPinisused.
ThistellsthecopyroutinetoaddRGBvaluesfromthesourceanddestinationto-RedDotsMACINTOSHSTEREOGRAMS615gether,butnottoexceedaparticularvalue.
ThemaximumvalueissetwithacalltoOpColor.
Inthisexample,themaximumRGBvaluecorrespondstotheindividualredandgreencolorsused;blueissettozero.
Thesecondim-portantaspectincreatingthecompositeistheuseofamask.
CopyDeepMaskissimilartoCopyBits,withoneim-portantexception.
CopyDeepMaskpermitstheuseofamasktodeterminewhichpixelsaredrawnandwhicharenot(seeApple,1994).
Apixelfromthegreendotimagewillbecopiedonlyifthecorrespondingmaskpixelisblack.
Ifamaskpixeliswhite,thecorrespondinggreendotpixelwillnotbecopied.
Thethirdaspectimportanttocreatingthecompositeimageinvolvesshifting,oroffsetting,themaskhorizontallytocreateadisparitybetweentheredandgreenportionsoftheimage.
Thisprocessdiffersforcre-atingsimpleversuscomplexstereograms.
SimpleStereogramsOncetheoffscreenGWorldsarecreatedandtheredandgreendotpatternsarecreatedanddrawninthem,thecompositeanaglyphcanbecreated,asshowninListing4andillustratedinFigure1.
First,theentirereddotpatternSourceNoMaskIIDestinationFigure1.
Asimplestereogram,madeupofasinglerectangularobjectonasolidback-ground.
Theentirereddotpattern(notincludingthe"padding"pixelsontheleftandrightedges)iscopiedfirst,fromthesourceonthelefttothedestinationontheright.
Next,themaskisinvertedandoffset1pixeltotheright,producingabackgroundofgreendotsoffset1pixeltotheleft(thewhitedotsshowwhichpixelsarecopied).
Finally,themaskisinvertedagainandoffset]pixeltotheleft,producinganobjectofgreendotsoffset]pixeltotheright.
616BARO(ThinkPascal)procedureMakeComposite;varobjectRect,backRect:rect;objectShift:integer;backShift:integer;beginobjectShift:~5;backShift:~0;GetGWorld(currPort,currDev);{amountbywhichblackpartofmaskisoffset){amountbywhichwhitepartofmaskisoffset}(saveforlater){firstdrawthereddotpattern-entireimageisdrawn)PMForeColor(Black);{mustsetforgroundandbackgroundtoblack}PMBackColor(O);{andwhitebeforedoingCopyBits}ifLockPixels(redOSWorldA.
portPixMap)thenCopyBits(GrafPtr(redOSWorld)A.
portBits,myWindowPtrA.
portBits,pictRect,pictRect,srcCopy,nil);UnlockPixels(redGSWorldA.
portPixMap);(setupanddrawwhitepartofmaskwithgreendotpattern)SetGWorld(maskOSWorld,maskDev);InvertRect(maskOSWorldA.
portRect);backRect:~pictRect;objectRect:~pictRect;OffsetRect(backRect,backShift,0);OffsetRect(objectRect,-objectShift,0);(swapblackandwhiteareas)(shiftformask)SetGWorld(currPort,currDev);{drawwhiteareafirst}PMForeColor(Black);{mustsetforgroundandbackgroundtoblack)PMBackColor(O);{andwhitebeforedoingCopyBits)OpColor(SetRGBColor(60000,50000,0));{neededforaddPincopymode)if(LockPixels(greenOSWorldA.
portPixMap))and(LockPixels(maskOSWorldA.
portPixMap))thenCopyDeepMask(GrafPtr(greenOSWorld)A.
portBits,GrafPtr(maskOSWorld)A.
portBits,myWindowPtrA.
portBits,pictRect,objectRect,backRect,addPin,nil);Unlockpixels(greenOSWorldA.
portPixMap);UnlockPixels(maskOSWorldA.
portPixMap);{setupanddrawblackpartofmaskwithgreendotpattern(overreddotpattern)}SetGWorld(maskOSWorld,maskDev);InvertRect(maskOSWorldA.
portRect);{swapblackandwhiteareasback}objectRect:~pictRect;OffsetRect(objectRect,objectShift,0);SetGWorld(currPort,currDev);{nowdrawblackarea}PMForeColor(Black);{mustsetforgroundandbackgroundtoblack}PMBackColor(O);{andwhitebeforedoingCopyBits}OpColor(SetRGBColor(60000,50000,0));{neededforaddPincopymode}if(LockPixels(greenOSWorldA.
portPixMap))and(LockPixels(maskOSWorldA.
portPixMap))thenCopyDeepMask(GrafPtr(greenOSWorld)A.
portBits,GrafPtr(maskOSWorld)A.
portBits,myWindowPtrA.
portBits,pictRect,pictRect,objectRect,addPin,nil);Unlockpixels(greenOSWorldA.
portPixMap);UnlockPixels(maskOSWorldA.
portPixMap);SetGWorld(currPort,currDev);end;(MakeComposite){resetGWorld}Listing4.
Combinesredandgreendotpatternsintoacompositeimage.
First,theentirereddotpatternisdrawnwithasimplecalltoCopyBlts.
BeforecopyingfromanotTscreenGWorld,youmustbesuretosettheforegroundcolortoblack,setthebackgroundcolortowhite,andchecktomakesuretheGWoridhasnotbeenpurged(bycall-ingLockPixels).
Next,thegreendotpatternisdrawnoverthereddotpatternusingCopyDeepMaskandtheaddPincopymode.
CopyDeepMaskissimilartoCopyBits,exceptthatpixelsarecopiedonlywherethemaskimageisblack.
Tocopythewhitereglon(s)ofthemaskimage,themaskisinverted,theninvertedbackagaintocopytheblackregion(s).
TheaddPincopymodeaddstheredandgreencolorvaluesandensuresthatthesumwillnotex-ceedtheRGBvaluesetinthecalltoOpColor(SetRGBColorisafunctionthatreturnsanRGBcolorvalue---refertoListing5).
Beforeeachcopy,themaskisshiftedasnecessarytocreateadisparity.
iscopiedtotheonscreenwindowwithacalltoCopyBits.
Thesecondstepinvolvesseparatingthemaskintotwocomponentimages,onemadeupoftheblackportionsofthemask(referredtointheexamplesasthe"object")andonemadeupofthewhiteportionsofthemask(re-ferredtoasthe"background").
Sincetherewillbeonlytwolevelsofdepthinthesimplestereogram,thegreendotsthatmakeuptheobjectareshiftedbyaparticularamountrelativetothecorrespondingreddots.
Likewise,thegreendotsthatmakeupthebackgroundareshiftedbyadifferentamount.
AsimplecaseisillustratedinFig-ureI-theobjectisshiftedbyIpixeltotheleftandthebackgroundisshiftedbyIpixeltotheright.
Thus,over-layingthegreendotsontotheredrequirestwosteps.
First,themaskisinverted(black-and-whiteareasareswapped)anditisshiftedbytheamountspecifiedforthebackground,whichisblackafterinversion.
TheshiftedmaskisusedinthecalltoCopyDeepMasktode-terminewhichpixelsarecopiedfromthegreendotpat-tern.
Pleasenotethatthedestinationarea(theregionofthereddotpatternontowhichthegreendotsareover-laid)isnotshifted-onlythemaskisshifted.
TheresultMACINTOSHSTEREOGRAMS617isthatwhenthegreendotsareoverlaidontothered,cor-respondinggreendotsareoffsetbytheamountbywhichthemaskwasshifted(intheoppositedirection-seeFig-ure1),creatingadisparity.
Next,themaskisinvertedtoitsoriginalstate,shiftedbytheamountspecifiedfortheobject,andCopyDeepMaskiscalledagain.
Thisover-laystheremainderofthegreendotsontothered.
Sincethedestinationareaisneveroffset,thetwoportionsoftheimageregisterexactlyinthecomposite,leavingnogapsinthestereogram.
ComplexStereogramsThesamebasicprocessesofcreatingandoffsettingamaskforeachdepthlevelareusedinthecreationofacomplexstereogram.
However,oneadditionalstepisrequired-separatingagrayscaleimageintoseveralblack-and-whitemasks,oneforeachdepthlevel.
Onceagain,theMacintoshToolboxprovidesasimplemethodforaccomplishingthispotentiallycomplextask-customcolorsearchprocedures.
Colorsearchprocedureshavemanyuses,buthereonewillbeusedtomap256graylevelsto13graylevels(disparityinthisexampleisar-functionSetRGBColor(r,g,b:longint):RGBColor;varsetRGB:RGBColor;beginifr>32767thenr:~r-65536;if9>32767then9:~9-65536;ifb>32767thenb:=b-65536;withsetRGBdobeginRed:~r;Green:=g;Blue:=b;end;SetRGBColor:=setRGB;end;ISetRGBColor}procedureGetRGBColor(setRGB:RGBColor;varr,g,b:longint);beginwithsetRGBdobeginr:=red;9:=green;b:=blue;end;ifr=rangeMin)and(meanOffsetRect(srcRect,i-6,0);maskRect:=pictRect;{shiftrangeis-6to+6pixels}{mustsetforgroundandbackgroundtoblack}{andwhitebeforedoingCopyBits}SetGWorld(currPort,currDev);tempRGB:=SetRGBColor(O,0,0);RGBForeColor(tempRGB);tempRGB:=SetRGBColor(65535,65535,65535);RGBBackColor(tempRGB);tempRGB:=SetRGBColor(60000,50000,0);OpColor(tempRGB);if(LockPixels(greenOSWorldA.
portPixMap)and(LockPixels(maskOSWorldA.
portPixMap)CopyDeepMask(GrafPtr(greenOSWorld)A.
portBits,GrafPtr(maskOSWorld)A.
portBits,myWindowPtrA.
portBits,srcRect,maskRect,pictRect,addPin,nil);UnlockPixels(greenOSWorldA.
portPixMap);UnlockPixels(maskOSWorldA.
portPixMap);end;thenSetGWorld(currPort,currDev);end;{MakeComposite}{resetGWor.
ld}Listing8.
Combinesredandgreendotpatternsintoacompositeimage.
First,theentirereddotpatternisdrawnwithasimplecalltoCopyBits(refertoListing4).
Next,thegreendotpatternisdrawnoverthereddotpattern13times--oneforeachmask.
Beforeeachcopy,aI-bitmaskiscopiedtotheI6-bitGWorldthatisusedasamaskwiththecalltoCopyDeepMask.
Themaskisshiftedasneces-saryeachtimethroughthelooptocreatedifferentamountsofdisparity,rangingfrom-6pixels(left)to+6pixels(right).
MACINTOSHSTEREOGRAMS621RedDots--_.
~OriginalMaskBlack&WhiteMasksI1+[I1+III+~IIJ+~I1+JFigure2.
Acomplexstereogram,withfivedifferentdepthlevels(Le.
,disparities).
Aswithasimplestereogram,theentirereddotpatterniscopiedfirst.
Next,theoriginalmaskiscon-vertedtofiveseparateblack-and-whitemasks,oneforeachgraylevelintheoriginal.
Finally,eachmaskisshiftedbytheappropriatenumberofpixelsandusedtocopyaportionofthegreendotpattern.
ofdynamicrandom-elementstereograms(i.
e.
,aseriesofstereogramsdisplayedinrapidsuccession-framesinamovie-inwhichelementcorrelationsarethesame,butinwhichadifferentsetofrandomelementsisgen-eratedforeachframe),intheQuickTimemovieformat.
REFERENCESApPLECOMPUTER,INC.
(I992a).
InsideMacintosh:Files.
Reading,MA:Addison-Wesley.
ApPLECOMPUTER,INC.
(1992b).
InsideMacintosh:Operatingsystemutilities.
Reading,MA:Addison-Wesley.
ApPLECOMPUTER,INC.
(1993).
InsideMacintosh:Advancedcolorimaging(preliminarydraft).
Reading,MA:Addison-Wesley.
ApPLECOMPUTER,INC.
(1994).
InsideMacintosh:ImagingwithQuickDraw.
Reading,MA:Addison-Wesley.
BARO,J.
A.
,&HUGHES,H.
C.
(1991).
Thedisplayandanimationoffull-colorimagesinrealtimeontheMacintoshcomputer.
Behav-iorResearchMethods,Instruments.
&Computers,23,537-545.
JULESZ,B.
(1971).
Foundationsofcyclopeanperception.
Chicago:UniversityofChicagoPress.
WINTERMYRE,J.
(1995).
Customcolorsearchprocedures.
Develop,22,66-80.
NOTESI.
Pleasenotethatthealgorithmsdescribedherearemeanttobeappliedonlytoimagescreatedwiththeexpresspurposeofrepresent-ingdepthwithgrayscale.
Ifthesealgorithmsareappliedtophoto-graphs,oranyimagecreatedforotherpurposes,theresultswilltypi-callybeunsatisfactory.
2.
Pleasenotethattheredandgreenvalues(60000and50000)usedhereandelsewhereintheexamplesaredifferent.
Thesevaluesareem-piricallyderivedtomatchthecolorsofthedisplaymonitortothecol-orsofthelensesusedtoviewthestereograms.
Inthisauthor'sexperi-ence,amonitor'sgreenphosphoristypicallybrighterthanitsredphosphor.
WhereverRGBvaluesaresetinthesamplecode,itislefttothereadertodeterminethebestvaluesonthebasisofthemonitorusedfordisplayandthelensesusedforviewing.
(ManuscriptreceivedJune9,1995;revisionacceptedforpublicationAugust3J,1995.
)

HostYun全场9折,韩国VPS月付13.5元起,日本东京IIJ线路月付22.5元起

HostYun是一家成立于2008年的VPS主机品牌,原主机分享组织(hostshare.cn),商家以提供低端廉价VPS产品而广为人知,是小成本投入学习练手首选,主要提供基于XEN和KVM架构VPS主机,数据中心包括中国香港、日本、德国、韩国和美国的多个地区,大部分机房为国内直连或者CN2等优质线路。本月商家全场9折优惠码仍然有效,以KVM架构产品为例,优惠后韩国VPS月付13.5元起,日本东京...

简单测评melbicom俄罗斯莫斯科数据中心的VPS,三网CN2回国,电信双程cn2

melbicom从2015年就开始运作了,在国内也是有一定的粉丝群,站长最早是从2017年开始介绍melbicom。上一次测评melbicom是在2018年,由于期间有不少人持续关注这个品牌,而且站长貌似也听说过路由什么的有变动的迹象。为此,今天重新对莫斯科数据中心的VPS进行一次简单测评,数据仅供参考。官方网站: https://melbicom.net比特币、信用卡、PayPal、支付宝、银联...

酷番云78元台湾精品CN2 2核 1G 60G SSD硬盘

酷番云怎么样?酷番云就不讲太多了,介绍过很多次,老牌商家完事,最近有不少小伙伴,一直问我台湾VPS,比较难找好的商家,台湾VPS本来就比较少,也介绍了不少商家,线路都不是很好,有些需求支持Windows是比较少的,这里我们就给大家测评下 酷番云的台湾VPS,支持多个版本Linux和Windows操作系统,提供了CN2线路,并且还是原生IP,更惊喜的是提供的是无限流量。有需求的可以试试。可以看到回程...

offsetrect为你推荐
中国电信互联星空中国电信互联星空是什么!怎么取消天天酷跑刷积分教程最近一直有人说天天酷跑刷积分,怎么刷的。安卓应用平台安卓手机下软件哪个网站好9flashIE9flash模块异常。直播加速请问哪种播放器的可以播放加速,并且可以保存硬盘人500G的硬盘容量是多少啊?qq空间打扮QQ空间打扮免费免费建站最好的免费建站机械键盘轴机械键盘的轴哪种好?虚拟专用网拨号网络与虚拟专用网的区别
如何查询域名备案号 80vps linode代购 pccw wavecom 创宇云 12306抢票助手 服务器架设 全能主机 圣诞节促销 100mbps 实惠 1美元 创速 美国十大啦 godaddy中文 发证机构 服务器机柜 hosts文件 screen 更多