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.
)

无忧云:洛阳/大连BGP云服务器38.4元/月,雅安物理机服务器315元/月起,香港荃湾CN2限时5折优惠

无忧云怎么样?无忧云是一家成立于2017年的老牌商家旗下的服务器销售品牌,现由深圳市云上无忧网络科技有限公司运营,是正规持证IDC/ISP/IRCS商家,主要销售国内、中国香港、国外服务器产品,线路有腾讯云国外线路、自营香港CN2线路等,都是中国大陆直连线路,非常适合免备案建站业务需求和各种负载较高的项目,同时国内服务器也有多个BGP以及高防节点,目前商家开启了夏日清凉补贴活动,商家的机器还是非常...

JUSTG提供俄罗斯和南非CN2 GIA主机年$49.99美元JUSTGgia南非cn2南非CN2justG

JUSTG,这个主机商第二个接触到,之前是有介绍到有提供俄罗斯CN2 GIA VPS主机活动的,商家成立时间不久看信息是2020年,公司隶属于一家叫AFRICA CLOUD LIMITED的公司,提供的产品为基于KVM架构VPS主机,数据中心在非洲(南非)、俄罗斯(莫斯科),国内访问双向CN2,线路质量不错。有很多服务商实际上都是国人背景的,有的用英文、繁体搭建的冒充老外,这个服务商不清楚是不是真...

A400互联37.8元/季,香港节点cn2,cmi线路云服务器,1核/1G/10M/300G

A400互联怎么样?A400互联是一家成立于2020年的商家,A400互联是云服务器网(yuntue.com)首次发布的云主机商家。本次A400互联给大家带来的是,全新上线的香港节点,cmi+cn2线路,全场香港产品7折优惠,优惠码0711,A400互联,只为给你提供更快,更稳,更实惠的套餐,香港节点上线cn2+cmi线路云服务器,37.8元/季/1H/1G/10M/300G,云上日子,你我共享。...

offsetrect为你推荐
cornerradius如何给TextView加个圆角?推广方法产品如何做推广中国电信互联星空互联星空是什么?是电信公司的吗?快速美白好方法快速美白的好点子!?(不是晒黑的)苹果5怎么越狱苹果5怎么越狱?迅雷云点播账号求个迅雷VIP 是VIP就可以 只用来看云点播 改密码是孙子。 谢了 ! 362135668@qq.comxp系统停止服务xp系统停止服务怎么办奇虎论坛360有论坛中心?奇虎论坛奇虎是中国的吗?虚拟专用网虚拟专用网 有什么用处?
域名备案 域名信息查询 分销主机 香港托管 免费网络电视 php空间推荐 支持外链的相册 in域名 银盘服务 中国电信测速器 美国盐湖城 数据库空间 cdn网站加速 如何登陆阿里云邮箱 沈阳idc alertpay 俄勒冈州 blaze 跟踪路由 qq部落18-3 更多