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

MineServer:香港CMI/洛杉矶GIA VPS,2核/2GB内存/20GB NVME/3.5TB流量/200Mbps/KVM,288元/年

mineserver怎么样?mineserver是一家国人商家,主要提供香港CN2 KVM VPS、香港CMI KVM VPS、日本CN2 KVM VPS、洛杉矶cn2 gia端口转发等服务,云服务器网(yuntue.com)介绍过几次,最近比较活跃。现在新推出了3款特价KVM VPS,性价比高,香港CMI/洛杉矶GIA VPS,2核/2GB内存/20GB NVME/3.5TB流量/200Mbps...

云基Yunbase无视CC攻击(最高500G DDoS防御),美国洛杉矶CN2-GIA高防独立服务器,

云基yunbase怎么样?云基成立于2020年,目前主要提供高防海内外独立服务器,欢迎各类追求稳定和高防优质线路的用户。业务可选:洛杉矶CN2-GIA+高防(默认500G高防)、洛杉矶CN2-GIA(默认带50Gbps防御)、香港CN2-GIA高防(双向CN2GIA专线,突发带宽支持,15G-20G DDoS防御,无视CC)。目前,美国洛杉矶CN2-GIA高防独立服务器,8核16G,最高500G ...

SugarHosts糖果主机圣诞节促销 美国/香港虚拟主机低至6折

SugarHosts 糖果主机商我们算是比较熟悉的,早年学会建站的时候开始就用的糖果虚拟主机,目前他们家还算是为数不多提供虚拟主机的商家,有提供香港、美国、德国等虚拟主机机房。香港机房CN2速度比较快,美国机房有提供优化线路和普通线路适合外贸业务。德国欧洲机房适合欧洲业务的虚拟主机。糖果主机商一般是不会发布黑五活动的,他们在圣圣诞节促销活动是有的,我们看到糖果主机商发布的圣诞节促销虚拟主机低至6折...

offsetrect为你推荐
找不到光驱找不到光驱怎么办啊手游运营手册游戏策划新手应该看那些书籍?如何免费开通黄钻怎么免费开黄钻?xp系统停止服务XP停止服务后该怎么办?创维云电视功能创维电视怎么用,我买了个创维云电视,现在不知道怎么用手机往电视上传照片,谁能解答以下,网页打开很慢如何解决网速正常 网页打开很慢问题电子商务网站模板电子商务网站策划书宽带接入服务器什么是宽带接入系统?怎样绕过宽带接入系统上网网页打不开的原因网页打不开是什么原因?2018最火爆的歌曲2018最火十大歌曲是哪些?
香港bgp机房 rackspace sockscap dropbox网盘 html空间 灵动鬼影 全站静态化 服务器托管什么意思 域名与空间 智能dns解析 net空间 美国迈阿密 防盗链 免费服务器 ddos是什么 ddos攻击器下载 大容量存储控制器 2000元电脑主机配置 厦门电信宽带 更多