how to increase the number of rows and columns of an image in Matlab?

Hello,
I would like to increase the number of rows and columns of an image in Matlab since I have different images and they should have the same number of rows and columns for special application. I want to fill the new rows and columns with zero value. How can I do that?

 Accepted Answer

Something like this:
a = rand(2,2,3)
a(3,3,3) = 0

1 Comment

Thank you very much Grzegorz Knor .Well,I some images which have different sizes but same pixel size. These images are requirements for an application which needs all the entry images in the same size and pixels. So I though I can open the small images in MATLAb and fill more rows and columns of an image with zero to make it the same size of bigger image. do you think that this code would work for this reason?

Sign in to comment.

More Answers (1)

Another option is padarray() (in the Image Processing Toolbox) if you want the zeros evenly distributed around the border instead of just along the bottom and right edge. Or if you want to stretch or scale the image instead of padding it with zeros, you can use imresize().

Community Treasure Hunt

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

Start Hunting!