CS代考计算机代写 Assignment 1: Airbrush Worksheet

Assignment 1: Airbrush Worksheet
1. What does RGBA stand for?
Red, Green, Blue, Alpha
2. What range of values can each component take when stored as unsigned 8-bit numbers?
[0,255]
3. What color and opacity is ¡°255, 0, 0, 64¡±?
Red at 25% opacity.
4. Write the formula to calculate the RGB color Composite obtained by compositing Foreground.RGBA over Background.RGB.
Composite.R = Foreground.R * Foreground.A/255. + Background.R * ( 1 – Foreground.A )/255. Composite.G = Foreground.G * Foreground.A/255. + Background.G * ( 1 – Foreground.A )/255. Composite.B = Foreground.B * Foreground.A/255. + Background.B * ( 1 – Foreground.A )/255.
5. Write the formula for linear interpolation lerp( a, b, t ) so that we obtain a for t=0 and b for t=1. (1-t)*a + t*b
6. Rewrite the formula to calculate the RGB color Composite obtained by compositing Foreground.RGBA over Background.RGB, this time using lerp.
Composite.R = lerp( Background.R, Foreground.R, Foreground.A/255. ) Composite.G = lerp( Background.R, Foreground.R, Foreground.A/255. ) Composite.B = lerp( Background.R, Foreground.R, Foreground.A/255. )

7. An airbrush image with radius r is being sprayed onto a canvas image with width w and height h at location x, y. The illustration shows the airbrush image falling off the left side of the canvas. In general, the airbrush image could fall off the canvas on the left, right, top, or bottom. Answer the following questions for the general case. The top-left pixel in an image is (0,0).
a. The pixel labeled F is the top-left pixel for the area of overlap between airbrush and canvas. What is the formula for F¡¯s row and column in canvas?
column: max( 0, x – r ) row: max( 0, y – r )
b. What is the formula for F¡¯s row and column in airbrush?
column: max( 0, x – r ) – (x-r) row: max( 0, y – r ) – (y-r)
w
r
canvas
h
F
(x,y)
airbrush
G
c. The pixel labeled G is the bottom-right pixel for the area of overlap between airbrush and canvas. What is the width and height of the area of overlap between airbrush and canvas (the rectangle whose opposite corners are F and G)?
width: min( w-1, x + r ) – max( 0, x – r ) + 1 height: min( h-1, y + r ) – max( 0, y – r ) + 1

Posted in Uncategorized

Leave a Reply

Your email address will not be published. Required fields are marked *