lroca
lroca

Reputation: 633

Matlab - padarray background

Is it possible that the background of the new image generated by the padarray will be white and not black?

clc;
clear;
Image = (imread('rice.png'));
h = size(Image,1);  
w = size(Image,2);  

imageNew = padarray(Image,[w*2, h*2]);
imshow(imageNew);

Upvotes: 0

Views: 198

Answers (1)

rayryeng
rayryeng

Reputation: 104555

Yes. padarray has a third optional parameter where you can specify what values the padded values should take on, instead of them being zero:

imageNew = padarray(Image,[w*2, h*2], 255); %// Change from black to white

BTW, if you read the documentation, it would tell you this: http://www.mathworks.com/help/images/ref/padarray.html.

As a word of advice, try reading the documentation before posting a question in the future. I'm certainly not criticizing your skills for reading, but MATLAB's documentation is very comprehensive. Your answer was found by reading the docs!

Upvotes: 1

Related Questions