How to downsize image in x and y direction?

1 vue (au cours des 30 derniers jours)
john karli
john karli le 24 Nov 2021
Commenté : KSSV le 25 Nov 2021
I have image with size 484x680 and i want to downsize with fector 2. final size should be 241x340.
i have tried it but it downsized in only one direction
img = imread('img')
new_img2 = downsample(img, 2);
imshow(new_img2)
I have also uplod the result of imshow(new_img2) which is img2

Réponse acceptée

KSSV
KSSV le 24 Nov 2021
Modifié(e) : KSSV le 24 Nov 2021
Read about imresize.
img = imread('img')
new_img2 = imresize(img, 1/2);
imshow(new_img2)
  2 commentaires
john karli
john karli le 24 Nov 2021
is downsampling and imresize are same ?
KSSV
KSSV le 25 Nov 2021
downsample skips the elements by the input N given by user. imresize does interpolation and reduces/ increases the dimensions/ size.

Connectez-vous pour commenter.

Plus de réponses (1)

yanqi liu
yanqi liu le 25 Nov 2021
yes, sir,may be use
clc; clear all; close all;
img = imread('https://ww2.mathworks.cn/matlabcentral/answers/uploaded_files/811604/img1.png');
new_img2 = img(1:2:end,1:2:end,:);
imshow(new_img2)

Catégories

En savoir plus sur Image Processing Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by