Creating border of an image
Show older comments
I need a create black border around an image:
My code:
I=ones(256,256); //size of an image
border = 2;
I(end:end+border,end:end+border)=0;
I(1:1+border,1:1+border)=0; // I know the problem is here
imshow(I)
Please help
Accepted Answer
More Answers (1)
DGM
on 16 Jul 2022
0 votes
While it may suffice to use array indexing to insert the image into a larger image, there are other methods. Depending on what's needed (black only, color, etc), and depending on what's available (Image Processing Toolbox), there may be more convenient options.
This reference answer covers the addition of black/colored/patterned image borders using base MATLAB/IPT tools, as well as third-party tools.
Categories
Find more on Convert Image Type 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!