Question

In: Computer Science

Develop a program that magnifies (monochrome) image by a factor of 2^N using bilinear interpolation. Implement...

Develop a program that magnifies (monochrome) image by a factor of 2^N using bilinear interpolation. Implement this up-scaling in 2 different ways: 1) directly, i.e. calling interp2 once; and 2) ? times iteratively doubling the size. Compare the outputs and discuss the variation in the output (if any).

Solutions

Expert Solution

Answer:

Program using interp2 to upscale the image

clear all

% read the image and convert to 2D array

image1=rgb2gray(imread('CuteFace.png'));

% display the image

figure

imshow(image1)

% convert to double values

image1=double(image1);

% get the size of the image1

[m n]= size(image1);

% define the meshgrid

[x,y] = meshgrid(1:n, 1:m);

% define the scaling factor

upScalingFactor = 2;

% define the meshgrid with the scaling factor

[p,q]=meshgrid(1:upScalingFactor:n, 1:upScalingFactor:m);

% user the interp2 to get the upscaling factor

image2=interp2(x,y,image1,p,q,'linear');

% plot the image

figure

subplot(1,2,1), imagesc(image1), axis, image

title('Original image','FontSize',18)

% plot the upscaled image

subplot(1,2,2), imagesc(image2), axis, image

title('Bilinear interpolation','FontSize',18)

% conver the image

i3 = cast(image2, class(image2));

% store the image

imwrite(i3,'gray1.png');

% display the new image

figure

imshow('gray1.png')

Program to upscale the image using iteration:

% Import my original picture file

N = 2;

image1 = imread('tiger.jpg');

% convert the image to monochrome

image1 = rgb2gray(image1);

% get the dimensions of the image1

[rows columns] = size(image1);

% define the scaling factor

factor = 2 ^ N;

row_new = rows * factor;

column_new = k * factor;

% define the scaling for the new image

x_scale = row_new./(rows - 1);

y_scale = column_new./(columns - 1);

% define the array for the new image

newZoomImage = zeros(row_new, column_new);

% create the output image by using bilinear interpolation

for count1 = 0 : row_new - 1

    for count2 = 0 : column_new - 1

        newZoomImage(count1+1,count2+1) = image1(1+round(count1./x_scale),1+round(count2./y_scale));

    end

end

% plot the images

subplot(1,2,1);

imagesc(image1);

colormap gray;

subplot(1,2,2);

imagesc(newZoomImage);

colormap gray;

% Write the images to files

imwrite(image1,gray(256),'original.jpg');

imwrite(newZoomImage,gray(256),'newZoom.jpg');

In both the programs,

  • The first one using interp2, the image size remains same but the internal pixel where refactorized. So that the image is zoomed to detail.
  • The second program, due to iteration process, the size of the image is resized to 2^N factor and size of the image increases.

But at final, the images are up scaled to the given factor size.


Related Solutions

Language: Java Design and implement a program that implements an Interpolation Search method. Interpolation search is...
Language: Java Design and implement a program that implements an Interpolation Search method. Interpolation search is similar to binary search, except it tries to begin the search nearer to the location of the item. Instead of the using the middle value of the sorted array, interpolation search estimates the location of the target with respect to the first & last values in the array. The implementation is the same as binary search except that you should calculate the mid value...
Explian interpolation: bilinear interpolation, subject is digital image processing.
Explian interpolation: bilinear interpolation, subject is digital image processing.
Explain Interpolation: Reverse neighbor interpolation, subject is digital image processing
Explain Interpolation: Reverse neighbor interpolation, subject is digital image processing
Factor Values Find the numerical value of the following factors using (a) linear interpolation (b) the...
Factor Values Find the numerical value of the following factors using (a) linear interpolation (b) the appropriate formula 1. (F/P,18%,33) 2. (A/G,12%,54)
Make a program for LAGRANGE INTERPOLATION METHOD using C++ program and can be evaluated both polynomial...
Make a program for LAGRANGE INTERPOLATION METHOD using C++ program and can be evaluated both polynomial and Transcendental Functions.
Power Factor Code Arduino Develop a Power factor Program in C and upload it into your...
Power Factor Code Arduino Develop a Power factor Program in C and upload it into your Arduino #include <LiquidCrystal.h> LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
prove 2 is a factor of (n+1)(n+2) for all positive integers
prove 2 is a factor of (n+1)(n+2) for all positive integers
java 2. Write a program to implement heapsort. Sort the following elements using your program. 6,...
java 2. Write a program to implement heapsort. Sort the following elements using your program. 6, 12, 34, 29, 28, 11, 23, 7, 0, 33, 30, 45
i. How can you reduce the effects of aliasing during image interpolation (in the case of...
i. How can you reduce the effects of aliasing during image interpolation (in the case of most typical images and interpolation schemes)? ii. Explain why this works (in most of the typical cases).
Develop an algorithm and implement a Preemptive Priority scheduling algorithm using C++ and using bubble sorting...
Develop an algorithm and implement a Preemptive Priority scheduling algorithm using C++ and using bubble sorting .Arrival time, burst time and priority values.The code should also display: (i) Gantt chart and determine the following: (ii) Determine the Turnaround time(TAT), waiting time(WT) of each process (iii) Determine the Average Waiting Time (AWT) and Average Turnaround Time (ATAT) of all processes. please write the comments
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT