Effacer les filtres
Effacer les filtres

how to resize an image as per the required dimension

66 vues (au cours des 30 derniers jours)
ramya s
ramya s le 16 Mar 2011
Commenté : Walter Roberson le 16 Mai 2023
i am doing my final yr project on steganography. and my project s suit only for square matrix images. (i.e, 256*256 512*512 1024*1024) like that images. i need images for that. wen i tried to resize other images it does not works.
for eg., I=imread('post.jpg');
[m n] = size(I)
J = imresize(I, [256 256]);
[x y] = size(J)
the output i m getting is m = 324 n = 512
x = 256 y = 1156
i do not know why it is like this. i am not getting any errors. help me what to do what shall i do now? please help me its very urgent
  2 commentaires
Sarah Wait Zaranek
Sarah Wait Zaranek le 16 Mar 2011
I =randi(324,512,'uint8');
[m n] = size(I) ;
J = imresize(I, [256 256]);
[x y] = size(J);
This works for me.
ramya s
ramya s le 16 Mar 2011
thank you so much

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 16 Mar 2011
Your image is 3 dimensional (RGB), not 2 dimensional.

Plus de réponses (3)

shyama p
shyama p le 17 Mar 2011
Modifié(e) : Walter Roberson le 9 Nov 2017
I1=imread('post.jpg');
I2 = imresize(I1,[256 256]);
In=rgb2gray(I2); % use if the image containing RGB value 3
figure;imshow(In);
imwrite(In,'yi.jpg') ;
  3 commentaires
priyanka gulhane
priyanka gulhane le 7 Nov 2017
thank you
fahmii fitrii
fahmii fitrii le 11 Sep 2019
thank you for the coding.

Connectez-vous pour commenter.


dipa teraiya
dipa teraiya le 24 Avr 2018
hello friends i have image of dimension is 84 * 34 and size of image is 16.1 KB Now other image of dimension is same but size of image is different is 16.4 KB so pls tell me which code can be applied when increase the size of image?

salman saleem
salman saleem le 12 Oct 2020
My question is how we can reduce the size of image by taking mean?
  1 commentaire
Walter Roberson
Walter Roberson le 16 Mai 2023
Suppose that you replace each N x N block of pixels with the mean value of the pixels in that block. Then your image with be 1/N times as large, but still similar.
For example:
img = imread('flamingos.jpg');
imgd = im2double(img);
img2x2 = (imgd(1:2:end,1:2:end,:) + imgd(1:2:end,2:2:end,:) + imgd(2:2:end,1:2:end,:) + imgd(2:2:end,2:2:end,:))./(2*2);
imshow(imgd); title('original');
imshow(img2x2); title('mean of 2x2 blocks')
whos img img2x2
Name Size Bytes Class Attributes img 972x1296x3 3779136 uint8 img2x2 486x648x3 7558272 double
You can see that the two images are visually very very similar, but the second image is only half the number of rows and columns of the first image.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by