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

SunthyCloud阿里云国际版分销商注册教程,即可PayPal信用卡分销商服务器

阿里云国际版注册认证教程-免绑卡-免实名买服务器安全、便宜、可靠、良心,支持人民币充值,提供代理折扣简介SunthyCloud成立于2015年,是阿里云国际版正规战略级渠道商,也是阿里云国际版最大的分销商,专业为全球企业客户提供阿里云国际版开户注册、认证、充值等服务,通过SunthyCloud开通阿里云国际版只需要一个邮箱,不需要PayPal信用卡就可以帮你开通、充值、新购、续费阿里云国际版,服务...

ZJI:520元/月香港服务器-2*E5-2630L/32GB/480G SSD/30M带宽/2IP

ZJI发布了一款7月份特别促销独立服务器:香港邦联四型,提供65折优惠码,限量30台(每用户限购1台),优惠后每月520元起。ZJI是原来Wordpress圈知名主机商家:维翔主机,成立于2011年,2018年9月启用新域名ZJI,提供中国香港、台湾、日本、美国独立服务器(自营/数据中心直营)租用及VDS、虚拟主机空间、域名注册等业务。下面列出这款服务器的配置信息。香港邦联四型CPU:2*E5-2...

数脉科技8月促销,新客减400港币,BGP、CN2+BGP、阿里云线路低至350元

数脉科技(shuhost)8月促销:香港独立服务器,自营BGP、CN2+BGP、阿里云线路,新客立减400港币/月,老用户按照优惠码减免!香港服务器带宽可选10Mbps、30Mbps、50Mbps、100Mbps带宽,支持中文本Windows、Linux等系统。官方网站:https://www.shuhost.com* 更大带宽可在选购时选择同样享受优惠。* 目前仅提供HKBGP、阿里云产品,香港...

offsetrect为你推荐
苏州商标注册在苏州怎么注册商标!找不到光驱我的电脑里找不到光驱中国电信互联星空中国电信互联星空是什么!怎么取消ghostxp3目前最好的ghost xp3是什么?百度抢票浏览器百度手机浏览器怎么抢票 手机百度浏览器抢票方法bluestacksbluestacks到底是叫蓝手指还是叫蓝叠在线代理网站最好的免费在线代理网站有哪些~急!显卡温度多少正常显卡温度是多少才算正常的?ps抠图技巧ps的抠图技巧是什么今日热点怎么删除如何彻底删除今日热点
播放vps上的视频 主机优惠码 187邮箱 google镜像 美国仿牌空间 哈喽图床 网通服务器ip 长沙服务器 hnyd 国外在线代理 php空间购买 优酷黄金会员账号共享 中国电信网络测速 cdn网站加速 apnic 七十九刀 asp.net虚拟主机 西部主机 木马检测 留言板 更多