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

SugarHosts糖果主机商更换域名

昨天,遇到一个网友客户告知他的网站无法访问需要帮他检查到底是什么问题。这个同学的网站是我帮他搭建的,于是我先PING看到他的网站是不通的,开始以为是服务器是不是出现故障导致无法打开的。检查到他的服务器是有放在SugarHosts糖果主机商中,于是我登录他的糖果主机后台看到服务器是正常运行的。但是,我看到面板中的IP地址居然是和他网站解析的IP地址不同。看来官方是有更换域名。于是我就问 客服到底是什...

易探云2核2G5M仅330元/年起,国内挂机宝云服务器,独立ip

易探云怎么样?易探云是国内一家云计算服务商家,致力香港服务器、国内外服务器租用及托管等互联网业务,目前主要地区为运作香港BGP、香港CN2、广东、北京、深圳等地区。目前,易探云推出深圳或北京地区的适合挂机和建站的云服务器,国内挂机宝云服务器(可选深圳或北京地区),独立ip;2核2G5M挂机云服务器仅330元/年起!点击进入:易探云官方网站地址易探云国内挂机宝云服务器推荐:1、国内入门型挂机云服务器...

ZJI:韩国BGP+CN2线路服务器,国内三网访问速度优秀,8折优惠码每月实付440元起

zji怎么样?zji最近新上韩国BGP+CN2线路服务器,国内三网访问速度优秀,适用8折优惠码zji,优惠后韩国服务器最低每月440元起。zji主机支持安装Linux或者Windows操作系统,会员中心集成电源管理功能,8折优惠码为终身折扣,续费同价,全场适用。ZJI是原Wordpress圈知名主机商:维翔主机,成立于2011年,2018年9月启用新域名ZJI,提供中国香港、台湾、日本、美国独立服...

offsetrect为你推荐
ov单片机汇编语言中 CY AC OV 分别是什么意思?木马病毒木马病毒的区别windows优化大师怎么用Windows优化大师怎么用?快速美白好方法有什么变白的好方法ps抠图技巧photoshop最基本的抠图方法和技巧!唱吧电脑版官方下载电脑上可以安装唱吧吗?童之磊华硕的四核平板电脑,怎么样?开机滚动条电脑开机有滚动条的画面xv播放器下载xv播放器怎么下载?怎么点亮qq空间图标QQ空间图标怎么点亮?
我的世界服务器租用 vps教程 电信测速器 大硬盘 namecheap jsp主机 安云加速器 全能主机 骨干网络 台湾谷歌地址 股票老左 免费dns解析 服务器硬件防火墙 中国电信宽带测速器 域名dns 空间登入 国外在线代理服务器 国内域名 湖南idc 秒杀品 更多