Magnify or Resized Coloured Image

1 view (last 30 days)
NURUL DIANA BINTI MOHD RIDUAN
Answered: Image Analyst on 20 Jun 2021
Is it possible to change certain part of code below to magnify coloured image? When i tried this on coloured image, it comes out in grayscale image.
%READ AN INPUT IMAGE
A=imread('colouredpic.jpg');
% DEFINE THE RESAMPLE SIZE
Col = 512;
Row = 512;
%FIND THE RATIO OF THE NEW SIZE BY OLD SIZE
rtR = 3; %Row/size(A,1);
rtC = 3; %Col/size(A,2);
%OBTAIN THE INTERPOLATED POSITIONS
IR = ceil([1:(size(A,1)*rtR)]./(rtR));
IC = ceil([1:(size(A,2)*rtC)]./(rtC));
%ROW_WISE INTERPOLATION
B = A(:,IR);
%COLUMN-WISE INTERPOLATION
B = B(IC,:);
figure,imshow(A);title('old image');
figure,imshow(B);title('resized image');
i had tried to add few things in the code but didnt seem to get the result I want. help me

Answers (2)

Walter Roberson
Walter Roberson on 20 Jun 2021
%ROW_WISE INTERPOLATION
B = A(:,IR,:);
%COLUMN-WISE INTERPOLATION
B = B(IC,:,:);

Image Analyst
Image Analyst on 20 Jun 2021
What does magnify mean to you? It's ambiguous.
Do you want to zoom in without changing the number of pixels? You can use xlim() and ylim() to do that. this will not change the image, just what's displayed.
Do you want to change the number of pixels? Perhaps cropping some off? Try imresize() or imcrop().
Another way to zoom is shown in the attached demo.

Categories

Find more on Read, Write, and Modify Image in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!