Duplicating the rows and columns of image, without using imresize.

4 次查看(过去 30 天)
I am trying to take an image and output a larger image whose height and width are twice as much as those of the input image, by duplicating the rows and columns ( without using imresize).
I have tried implementing this; however, the output is an entirely black image.
img = imread('https://people.sc.fsu.edu/~jburkardt/data/png/lena.png');
[M1,N1] = size(img);
M2 = M1*2;
N2 = N1*2;
g = zeros(M2,N2);
imshow(g);
  1 个评论
Rik
Rik 2019-2-7
Why do you not want to use imresize? Is this a homework assignment?
If you follow the flow of your program, the following things happen:
  1. you read a color image from a website to an array
  2. you determine the number of rows and columns (ignoring a possible color component, which is aparently missing from this version of the lena image)
  3. you double those numbers
  4. you create an entirely new array made up of only zeros
  5. you display that new array
From this it should be clear that you didn't change the size of the image, and it should be clear why the image you see is blank.

请先登录,再进行评论。

采纳的回答

TADA
TADA 2019-2-7
编辑:TADA 2019-2-7
The image is black because you are displaying zeros
You say that you want to duplicate the rows and columns - I assume you mean stretching each pixel to 4 identical pixels
That can be done using repelem if you don't care about the massive pixelation
img = imread('autumn.tif');
multFactor = 2;
stretchedImg = repelem(img, multFactor, multFactor);
imshow(stretchedImg);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by