How do I overlay an rgb image onto a background image?
Show older comments
Hello, I'm quite new to MATLAB and I've been trying to find a solution to what seems like a simple problem.
I have an RGB image and I would like to create a white border around it. In particular, I want the border at the bottom to be quite a bit larger to allow for some text. Then I will loop over all images in a directory and process them in that way.
I'm sure I have to create a background image whose dimensions are simply a bit larger than the rgb image, and then just overlay the rgb image onto the background. I need some help doing the overlaying part. Is there a simple way to do this?
Thanks
Accepted Answer
More Answers (1)
Image Analyst
on 22 Oct 2016
2 votes
You can use the padarray() function.
2 Comments
John BG
on 23 Oct 2016
there are so many things one can do be do be do
Image Analyst
on 23 Oct 2016
To be explicit:
% Add a 50 pixel wide white boundary around the image.
paddedImage = padarray(rgbImage, [50, 50], 255);
Categories
Find more on Data Exploration in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

