Tuesday, April 17, 2012

MATLAB Code to scale down the image height and scale up

% Read the image
Img = imread('plato.jpg');

% Downscale it
ihalf = Img(1 : 2 : end, :, :);
% Display the image
imshow(ihalf);

% Get the height and width of the original image
[height width dim] = size(Img);
ifull = zeros(height, width, dim);
% Upscale the image
ifull(1 : 2 : end, :, :) = ihalf;
ifull(2 : 2 : end, :, :) = ihalf;
ifull = uint8(ifull);
figure;
imshow(ifull);

Hope this works. Happy coding!!!