Question

In: Computer Science

Given a pixel location (x1, y1), we can calculate z_i for this point as (d- ax1-...

Given a pixel location (x1, y1), we can calculate z_i for this point as (d- ax1- by1)/c. This takes 2 multiplications and a division for each pixel. Suppose the z_i value for (x1, y1) is known,

find an easier way to find the z_i for (x1+1, y1) and (x1, y1+1) (pixels bordering (x1, y1))?

Does this lead to a more efficient way of calculating z_i for each pixel? Explain.

Solutions

Expert Solution

z_i = (d - ax1 - by1)/c.

Here, 2 multiplications -> a*x1 and b*y1

and 2 divisions -> a*x1/c and b*y1/c

are used. But when we know z_i value for (x1,y1), it will take less number of operations to calculate z+i of (x1+1,y1) and (x1,y1+1).

Let z_i of (x1+1,y1) be zi_new and z_i of (x1,y1) be zi. So,

zi_new - zi = (d - a(x1+1) - by1)/c - (d - ax1 - by1)/c = -a/c

zi_new - zi = -a/c

zi_new = zi - a/c

So, given zi, we only need one division and one subtraction operation to find zi_new. Hence, given z_i of (x1,y1), it is very easy and efficient to calculate z_i of (x1+1,y1).

Similarly for (x1,y1+1), we will get

zi_new = zi -b/c.

So, it is efficient to calculate z_i of both (x1+1,y1) and (x1,y1+1) when z_i of (x1,y1) is present.

Starting from the bottom-left pixel of the image, calculate z_i using the formula, z_i = (d - ax1 - by1)/c. After that calculate z_i of a neighbor pixel by using the formula, zi_new = zi - a/c, for pixel right of the current pixel and zi_new = zi -b/c for pixel above of the neighbor pixel. This new calculated z_i will in turn be used to calculate z_i of its neighbor and hence, each pixel's z_i(other than bottom left) can be calculated with just one division and one subtraction operation in each caluculation.

Therefore, calculating z_i value of current pixel from the neighboring pixel is very much more efficient than calculating z_i through this formula (d- ax1- by1)/c.


Related Solutions

1. Let ρ: R2 ×R2 →R be given by ρ((x1,y1),(x2,y2)) = |x1 −x2|+|y1 −y2|. (a) Prove...
1. Let ρ: R2 ×R2 →R be given by ρ((x1,y1),(x2,y2)) = |x1 −x2|+|y1 −y2|. (a) Prove that (R2,ρ) is a metric space. (b) In (R2,ρ), sketch the open ball with center (0,0) and radius 1. 2. Let {xn} be a sequence in a metric space (X,ρ). Prove that if xn → a and xn → b for some a,b ∈ X, then a = b. 3. (Optional) Let (C[a,b],ρ) be the metric space discussed in example 10.6 on page 344...
We define a relation ∼ on R^2 by (x1,y1)∼(x2,y2) if and only if (y2−y1) ∈ 2Z....
We define a relation ∼ on R^2 by (x1,y1)∼(x2,y2) if and only if (y2−y1) ∈ 2Z. Show that the relation∼is an equivalence relation and describe the equivalence class of the point (0,1).
A system of point charges includes q1= +1 microC at x1 = 2m, y1 =2m, q2=...
A system of point charges includes q1= +1 microC at x1 = 2m, y1 =2m, q2= -1 microC at x2= -3m, y2= -3m, q3 = +3microC at the origin. A) what is the electric potential at location x = 1m, y = -1m? B) what is the electric potential energy Ue (i.e PE) of the system of charges? energy C) What is the electric field Ex and Ey components, magnitude E and directional angle at x=-2m, y= +3m?
A system of point charges includes q1= +1 microC at x1= 2m, y1= 2m; q2= -1...
A system of point charges includes q1= +1 microC at x1= 2m, y1= 2m; q2= -1 micro C at x2= -3m, y2= -3m; q3= +3 microC at the origin. a) What is the electrical potential (i.e. the voltage) at location x=1m, y= -1m? b) What is the electrical potential energy UE (i.e. PE) of the system of charges? c) What is the electrical field Ex and Ey components, magnitude E, and directional angle at x= -2m, y= 3m?
Closest and Farthest points. Distance between two points (x1,y1) and (x2, y2) can becalculated...
Closest and Farthest points. Distance between two points (x1, y1) and (x2, y2) can becalculated as d = sqt( (x1 − x2) ^2 + (y1 − y2)^ 2). You are given the coordinates of a sourcepoint and three destination points. Write a Python program stored in a file q8.py thattakes these information as input and determines the closest and farthest destinationpoints from the source point.ex:Enter source coordinates : 0 0Enter point A coordinates : 1 4Enter point B coordinates :...
Develop a computer program or spread sheet to calculate, for a given day and location, the...
Develop a computer program or spread sheet to calculate, for a given day and location, the hourly-changed total solar radiation onto a southeast-facing vertical wall and a flat-roof where solar panels are located. The day and location are user-defined. Show your results for May 21 in Newark, NJ.
Given the ?(?) = 30? .001? and ?(?) = 80? −.001? find: d) The equilibrium point....
Given the ?(?) = 30? .001? and ?(?) = 80? −.001? find: d) The equilibrium point. e) Determine the consumer’s surplus. Show the integral used. f) Determine the producer’s surplus. Show the integral used.
Given: Calculate the freezing point and boiling point of a solution containing 17.0 g of naphthalene...
Given: Calculate the freezing point and boiling point of a solution containing 17.0 g of naphthalene (C10H8) in 119.0 mL of benzene. Benzene has a density of 0.877 g/cm3. Part A Calculate the freezing point of a solution. (Kf(benzene)=5.12∘C/m.) Part B Calculate the boiling point of a solution. (Kb(benzene)=2.53∘C/m.)
Calculate D in rectangular coordinates at point P(2, -3, 6) produced by
D3.2. Calculate D in rectangular coordinates at point P(2, -3, 6) produced by: (a) a point charge QA-55 mC at Q(-2, 3, -6); (b a uniform line charge ?ρLB 20 mC/m on the x axis; (c) a uniform surface charge density ρsc 120 μC/ m" on the plane z =-5 m.
Which of the following statements is TRUE? A. We can sometimes know the exact location and...
Which of the following statements is TRUE? A. We can sometimes know the exact location and speed of an electron at the same time. B. All orbitals in a given atom are roughly the same size. C. Since electrons have mass, we must always consider them to have particle properties and never wavelike properties. D. Atoms are roughly spherical because when all of the four different shaped orbitals are overlapped, they take on a spherical shape. E. All of the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT