Professional Documents
Culture Documents
The Assign Value Is Taken From The Pixel Closest To The Generated Loaction
The Assign Value Is Taken From The Pixel Closest To The Generated Loaction
LAB NUMBER#05
“GEOMETRIC TRANFORMATION”
TASK#01: Write the generalized function for two methods like nearest neighbor
interpolation and bilinear interpolation code in MATLAB?
Objective:
1.To understand nearest neighbor interpolation.
2.To understand bilinear interpolation.
Mathematical Steps:
The assign value is taken from the pixel closest to the generated loaction:
The closest neighbor is chossen, by rounding the “new” indexes to original image’s coordinates.As
shown below:
Flow Chart:
Code:
Result:
By entering the scaling factor 2 one row and one column is inserted replace that pixels By nearest
neighbor and bilinear(By taking averge of neighbors ).If you enter choice 1 then nearest neighbor
is implement and if choice is 2 then bilinear is implemented.First fill the columns and then rows.e.g
If choice is 1 the simple replicate the neighbor as shown above.If choice is 2 the taking average of
neighbors as shown above.
(1+2)/2=1.5 & (1+6)?2=3.5 similarly this done with all inserted pixels and obtained the above
results.