DOC PREVIEW
UVA CS 445 - Image Warping and Sampling

This preview shows page 1-2-3-4-5-6-7-8-9-60-61-62-63-64-65-66-67-121-122-123-124-125-126-127-128-129 out of 129 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 129 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 129 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 129 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 129 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 129 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 129 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 129 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 129 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 129 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 129 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 129 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 129 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 129 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 129 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 129 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 129 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 129 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 129 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 129 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 129 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 129 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 129 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 129 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 129 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 129 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 129 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 129 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Image Warping and SamplingJason LawrenceCS445: GraphicsAcknowledgement: slides by Misha Kazhdan, Allison Klein, Tom Funkhouser,Adam Finkelstein and David DobkinOutline• Image Processing• Image Warping• Image SamplingImage Processing• What about the case when the modification that we would like to make to a pixel depends on the pixels around it?oBlurringoEdge DetectionoEtc.Multi-Pixel Operations• In the simplest case, we define a mask of weights which tells us how the values at adjacent pixels should be combined to generate the new value.Blurring• To blur across pixels, define a mask:oWhose value is largest at the center pixeloWhose entries sum to one.Original BlurFilter =BlurringOriginalFilter =Pixel(x,y): red = 36 green = 36 blue = 0BlurringOriginalFilter =Pixel(x,y): red = 36 green = 36 blue = 0Pixel(x,y).red and its red neighborsX - 1XX + 1Y - 136109146Y 3236109Y + 1323673BlurringOriginalFilter =Pixel(x,y).red and its red neighborsX - 1XX + 1Y - 136109146Y 3236109Y + 1323673New value for Pixel(x,y).red =(36 * 1/16) + (109 * 2/16) + (146 * 1/16)(32 * 2/16) + (36 * 4/16) + (109 * 2/16)(32 * 1/16) + (36 * 2/16) + (73 * 1/16)BlurringOriginalFilter =Pixel(x,y).red and its red neighborsX - 1XX + 1Y - 136109146Y 3236109Y + 1323673New value for Pixel(x,y).red = 62.69BlurringOriginalNew value for Pixel(x,y).red = 63Blur• Repeat for each pixel and each color channel• Note 1: Keep source and destination separate to avoid “drift”.• Note 2: For boundary pixels, not all neighbors are used, and you need to normalize the mask so that the sum of the values is correct.Blurring• In general, the mask can have arbitrary size:oWe can express a smaller mask as a bigger one by padding with zeros.BlurringOriginal Blur• In general, the mask can have arbitrary size:oWe can have more non-zero entries to give rise to a wider blur.BlurringOriginal Narrow BlurWide Blur• A general way for defining the entries of an nxn mask is to use the values of a Gaussian:oσ equals the mask radius (n/2 for an nxn mask)ox is i’s horizontal distance from center pixeloy is j’s vertical distance from center pixeloDon’t forget to normalize!BlurringGaussian Mask[i][j] =Edge Detection• To find the edges in an image, define a mask:oWhose value is largest at the center pixeloWhose entries sum to zero.• Edge pixels are those whose value is larger (on average) than those of its neighbors.Original Detected EdgesFilter =Edge DetectionOriginalPixel(x,y): red = 36 green = 36 blue = 0Filter =Edge DetectionOriginalPixel(x,y): red = 36 green = 36 blue = 0Pixel(x,y).red and its red neighborsX - 1XX + 1Y - 136109146Y 3236109Y + 1323673Filter =Edge DetectionOriginalPixel(x,y).red and its red neighborsX - 1XX + 1Y - 136109146Y 3236109Y + 1323673New value for Pixel(x,y).red =(36 * -1) + (109 * -1) + (146 * -1)(32 * -1) + (36 * 8) + (109 * -1)(32 * -1) + (36 * -1) + (73 * -1)Filter =Edge DetectionOriginalPixel(x,y).red and its red neighborsX - 1XX + 1Y - 136109146Y 3236109Y + 1323673New value for Pixel(x,y).red = -285Filter =Edge DetectionOriginalPixel(x,y).red and its red neighborsX - 1XX + 1Y - 136109146Y 3236109Y + 1323673New value for Pixel(x,y).red = 0Filter =Detected EdgesEdge DetectionOriginalNew value for Pixel(x,y).red = 0Outline• Image Processing• Image Warping• Image SamplingImage Warping• Move pixels of imageoMappingoResamplingSource image Destination imageWarpOverview• MappingoForwardoReverse• ResamplingoPoint samplingoTriangle filteroGaussian filterMapping• Define transformationoDescribe the destination (x,y) for every location (u,v) in the source (or vice-versa, if invertible)vuyxExample Mappings• Scale by factor:ox = factor * uoy = factor * vScale0.8yxvuExample Mappings•Rotate by θ degrees:x = ucosθ - vsinθ y = usinθ + vcosθ Rotate30vuyxExample Mappings• Shear in X by factor:x = u + factor * vy = v• Shear in Y by factor:x = uy = v + factor * uShear X1.3Shear Y1.3vuvuyxyxOther Mappings• Any function of u and v:ox = fx(u,v)oy = fy(u,v)Fish-eye“Swirl”“Rain”Image Warping Implementation I• Forward mapping:"for (int u = 0; u < umax; u++) for (int v = 0; v < vmax; v++) float x = fx(u,v); float y = fy(u,v); dst(x,y) = src(u,v); Source imageDestination image(u,v)(x,y)fForward MappingRotate-30vuyx• Iterate over source image• Iterate over source imageForward Mapping – BAD!Rotate-30vuyxMany source pixels can map to same destination pixel• Iterate over source imageForward Mapping – BAD!Rotate-30vuyxMany source pixels can map to same destination pixelSome destination pixels may not be coveredImage Warping Implementation II• Reverse mapping:"for (int x = 0; x < xmax; x++) for (int y = 0; y < ymax; y++) float u = fx-1(x,y); float v = fy-1(x,y); dst(x,y) = src(u,v); Source imageDestination image(u,v)(x,y)fReverse Mapping – GOOD!Rotate-30vuyx• Iterate over destination imageoMust resample sourceoMay oversample, but much simpler!Resampling• Evaluate source image at arbitrary (u,v)Source imageDestination image(u,v)(x,y)(u,v) does not usuallyhave integer coordinatesOverview• MappingoForwardoReverse• ResamplingoNearest Point SamplingoBilinear SamplingoGaussian SamplingNearest Point Sampling• Take value at closest pixel:int iu = trunc(u+0.5);int iv = trunc(v+0.5);dst(x,y) = src(iu,iv);Rotate-30Scale0.5vuyxBilinear Sampling• Bilinearly interpolate four closest pixelsa = linear interpolation of src(x1,y1) and src(x2,y1)b = linear interpolation of src(x1,y2) and src(x2,y2) dst(x,y) = linear interpolation of “a” and “b”x1 = floor( x );x2 = x1 + 1;y1 = floor( y );y2 = y1 + 1;dx = x – x1;dy = y – y1;a = src(x1,y1)*(1-dx) + src(x2,y1)*dx;b = src(x1,y2)*(1-dx) + src(x2,y2)*dx;dst(x,y) = a*(1-dy) + b*dy;(x1,y1)(x2,y2)(x2,y1)(x1,y2)(x,y)baBilinear Sampling• Bilinearly interpolate four closest pixelsa = linear interpolation of src(x1,y1) and src(x2,y1)b = linear interpolation of src(x1,y2) and src(x2,y2) dst(x,y) = linear interpolation of “a” and “b”x1 = floor( x );x2 = x1 + 1;y1 = floor( y );y2 = y1 + 1;dx = x – x1;dy = y – y1;a = src(x1,y2)*(1-dx) + src(x2,y2)*dx;b = src(x1,y1)*(1-dx) + src(x2,y1)*dx;dst(x,y) = a*(1-dy) + b*dy;(x1,y1)(x2,y2)(x2,y1)(x1,y2)(x,y)baMake sure to test that the pixels (x1,y1), (x2,y2), (x1,y2), and (x2,y1) are within the image.Gaussian Sampling• Compute weighted


View Full Document

UVA CS 445 - Image Warping and Sampling

Documents in this Course
Lighting

Lighting

49 pages

Color

Color

20 pages

Clipping

Clipping

10 pages

Shadows

Shadows

95 pages

Color

Color

37 pages

Radiosity

Radiosity

49 pages

Clipping

Clipping

59 pages

Assign 3

Assign 3

28 pages

Splines

Splines

17 pages

Color

Color

17 pages

Load more
Download Image Warping and Sampling
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Image Warping and Sampling and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Image Warping and Sampling 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?