Code covered by the BSD License  

Highlights from
Draw a border around an image

5.0

5.0 | 1 rating Rate this file 22 Downloads (last 30 days) File Size: 2.16 KB File ID: #21005
image thumbnail

Draw a border around an image

by Eric Johnson

 

07 Aug 2008 (Updated 31 Dec 2009)

Draws a colored border around an image.

| Watch this File

File Information
Description

ADDBORDER draws a border around an image.

NEWIMG = ADDBORDER(IMG, T, C, S) adds a border to the image IMG with thickness T, in pixels. C specifies the color, and should match the color format of the image (e.g., RGB or indexed). STROKE is a string indicating the position of the border:

'inner' - border is added to the inside of the image. The dimensions of OUT will be the same as IMG.

'outer' - the border sits completely outside of the image, and does not obscure any portion of it.

'center' - the border straddles the edges of the image.

Example:

load mandrill
X2 = addborder(X, 20, 62, 'center');
image(X2);
colormap(map);
axis off
axis image

MATLAB release MATLAB 7.6 (R2008a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (3)
21 Apr 2011 jun

Where doese the X from your example come from? It is not working at all. The 't' is limited to 1 and what I get is only img2 = 'c' depends on what is entered to 'c'.

17 Nov 2011 Dave  
17 Nov 2011 Dave

Awesome. Just what I needed.

Please login to add a comment or rating.
Updates
31 Dec 2009

None

Tag Activity for this File
Tag Applied By Date/Time
enhancement Eric Johnson 22 Oct 2008 10:13:50
stroke Eric Johnson 22 Oct 2008 10:13:50
border thickness Eric Johnson 22 Oct 2008 10:13:50
pad Eric Johnson 22 Oct 2008 10:13:50
image processing Eric Johnson 22 Oct 2008 10:13:50
border Eric Johnson 22 Oct 2008 10:13:50
image processing nishant kolhe 21 Jan 2009 03:06:10
color Eric Johnson 31 Dec 2009 16:10:35
frame Eric Johnson 31 Dec 2009 16:10:35

Contact us at files@mathworks.com