联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp

您当前位置:首页 >> Java编程Java编程

日期:2024-03-20 08:42

Homework5

ComputerVision,Spring 2024

DueDate:March 22,2024

TotalPoints:10

Thishomeworkcontainsoneprogrammingchallenge.Allsubmissionsaredueat

midnightonMarch 22,2024, andshouldbesubmittedaccordingtothe

instructionsinthedocument“GuidelinesforProgrammingAssignments.pdf”.

runHw5.py willbeyourmaininterfaceforexecutingandtestingyourcode.

Parametersforthedifferentprogramsorunittestscanalsobesetinthatfile.

Beforesubmission,makesureyoucanrunallyourprogramswiththecommand

python runHw5.py withnoerrors.

Thenumpypackage isoptimizedforoperationsinvolvingmatricesand

vectors.Avoidusingloops(e.g.,for,while)wheneverpossible—loopingcan

resultinlongrunningcode.Instead,youshould“vectorize”loopstooptimize

yourcodeforperformance.Inmanycases,vectorizationalsoresultsinmore

compactcode(fewerlinestowrite!).

Challenge1: Yourtaskistodevelopavisionsystemthatrecoverstheshape,

surfacenormalandreflectanceofanobject.Forthispurposeyouwilluse

photometricstereo.

Youwillbegiven5imagesofanobjecttakenusingfivedifferentlightsources.Your

taskistocomputethesurfacenormalandalbedofortheobject.Forthispurpose,

however,youwillneedtoknowthedirectionsandintensitiesofthefivelight

sources.Thus,inthefirstpartoftheassignment,youwillcomputethelight

sourcesdirectionsandintensities from5imagesofasphereandusethis

informationinthesecondparttorecovertheorientationandreflectance.

The11images,sphere0…sphere5,andvase1…vase5 areprovidedtoyou.

Beforeyoubegin,payattentiontothefollowingassumptionsyoucanmakeabout

thecapturesettings:

2

? Thesurfacesofallobjects(includingthesphere)areLambertian.Thismeans

thereareonlydiffusepeaksinthereflectancemaps(nospecular

components).

? Fortheimages,assumeorthographicprojections.

? Imagefileswiththesameindicesaretakenusingthesamelightsource.For

example,sphere1 andvase1 aretakenusinglightsourcenumber1only.

? Theobjectsmaintainthesameposition,orientationandscalethroughthe

differentimages– theonlydifferenceisthelightsource.Forexample,the

sphereinsphere0…sphere5 hasthesamecoordinatesandthesameradius.

? Thelightsourcesarenotinsingularconfiguration,i.e.,theS-matrixthatyou

willcomputeshouldnotbesingular.

? YoumayNOT assumethatthelightsourcesareofequalintensities.This

meansthatyouneedtorecovernotonlythedirectionsofthelightsources

butalsotheirintensities.

? Thebackgroundintheimageisblack(0pixelvalue)inallimages.

Thetaskisdividedintofourparts,eachcorrespondingtoaprogramyouneedto

writeandsubmit.

a. Firstyouneedtofindthelocationsofthesphereanditsradius.Forthis

purposeyouwillusetheimagesphere0,whichistakenusingmanylight

sources(sothattheentirefronthemisphereisvisible).

WriteaprogramfindSphere thatlocatesthesphereinanimageand

computesitscenterandradius.

center, radius = findSphere(input_img)

Assuminganorthographicproject,thesphereprojectsintoacircleonthe

imageplane.Findthelocationofthecirclebycomputingitscentroid.Also

estimatetheareaofthecircleandfromthis,computetheradiusofthecircle.

ReportyourresultsinREADME file.

Youmayuse skimage.filters.threshold_otsu and

skimage.measure.regionprops.

(1points)

b. Nowyouneedtocomputethedirectionsandintensitiesofthelightsources.

Forthispurposeyoushouldusetheimagessphere1…sphere5.

Deriveaformulatocomputethenormalvectortothesphere’ssurfaceata

3

givenpoint,knowingthepoint’scoordinates(intheimagecoordinateframe),

andthecenterandradiusofthesphere’sprojectionontotheimageplane

(again,assumeanorthographicprojection).Thisformulashouldgiveyouthe

resultingnormalvectorina3-Dcoordinatesystem,originatingatthe

sphere’scenter,havingitsx-axisandy-axisparallelrespectivelytothex-axis

andthey-axisoftheimage,andz-axischosensuchastoformanorthonormal

left-handcoordinatesystem.Don’tforgettoinclude yourformulainyour

READMEfile.

WriteaprogramcomputeLightDirections thatusesthisformula,along

withtheparameterscomputedin(a),tofindthenormaltothebrightest

surfacespotonthesphereineachofthe5images.Assumethatthisisthe

directionofthecorrespondinglightsource(Whyisitsafetoassumethis?

StatethisintheREADME).

Finally,fortheintensityofthelightsource,usethemagnitude(brightness)of

thebrightnesspixelfoundinthecorrespondingimage.Scalethedirection

vectorsothatitslengthequalsthisvalue.

light_dirs_5x3 = computeLightDirections(center, radius,

img_list)

Center andradius aretheresultedcomputedin(a).img_list containsthe

5imagesofthesphere.Theresultinglight_dirs_5x3 isa5x3matrix.Rowi

oflight_dirs_5x3 containsthex-,y-,andz-componentsofthevector

computedforlightsourcei.(2points)

c. WriteaprogramcomputeMask tocomputeabinaryforegroundmaskforthe

object.Apixelinthemaskhasavalue1ifitbelongstotheobjectand0ifit

belongstothebackground.Distinguishingbetweentheforegroundand

backgroundissimple:ifapixeliszeroinall5images,thenitisbackground.

Otherwise,itisforeground.

mask = computeMask(img_list)

Theimg_list containsthe5imagesofanobjectandmaskisthebinary

imagemask.(1points)

d. WriteaprogramcomputeNormals that,given5imagesofanobject,

computesthenormalsandalbedotothatobject’ssurface.

normal, albedo_img = computeNormals(light_dirs, img_list,

mask)

4

Youmaywanttousetheformulagivenintheclasslecturenotes.Becareful

here!Makesuretotakeintoaccountthedifferentintensitiesofthelight

source.

Photometricstereorequirestheobjecttobelitbyatleast3lightsources.

However,inour case,wehaveatotalof5lightsources.Thelightinghasbeen

arrangedinsuchawaythatallvisiblesurfacepointsonanobjectarelitbyat

least3lightsources.Therefore,whilecomputingthesurfacenormalata

point,choosethe3lightsourcesforwhichthepointappearsbrightest.Be

careful– choosingthewronglightsourceswillresultinerroneoussurface

normal.(Youmayalsodecidetochoosemorethan3lightsourcestocompute

thesurfacenormal.Thisresultsinanover-determinedlinearsystemandcan

providerobustestimates.However,suchacomputationisnotmandatory.)

Donotcomputethesurfacenormalforthebackground.Youcanassumethat

thesurfacenormalinthisregionislookingtowardthecamera.Usethemask

generatedinthepreviousprogramtoidentifywhetheragivenpixel

correspondstotheobjectorthebackground.

Scalethealbedoupordowntofitintherange0…1andshowtheminthe

outputimage.Thuseachpixelintheoutputimageshouldbethepixel’s

albedoscaled byaconstantfactor.(6points)

Atthispointyoucanusetheoutputsofyourprogramtoreconstructthe

surfaceoftheobject.demoSurfaceReconstruction and

reconstructSurf demonstrate howtousetheFrankot-Chellappa

algorithmtocomputethe3Dshapefromsurfacenormals. Surface

reconstructionisprovidedasademo--nosubmissionisrequired.


版权所有:留学生编程辅导网 2020 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp