Code covered by the BSD License
-
AddTextToImage(Image,String,P...
Image = AddTextToImage(Image,String,Position,Color,Font,FontSize)
-
AddTextToImageWithBorder(Imag...
Image = AddTextToImage(Image,String,Position,Color,Font,FontSize,BorderWidth,BorderColor)
-
RasterizeText(String,Font,Fon...
Image = RasterizeText(String,Font,FontSize)
-
AddTextToImageDemo.m
-
AddTextToImageWithBorderDemo.m
-
BitmapFont.m
-
View all files
|
|
| File Information |
| Description |
Sometimes it's nice to be able to place text on an image and know precisely where it will render irrespective of the figure size and shape and other whims of the text() function. This submission achieves that by directly overwriting part of the image matrix with rasterized text generated using bitmapped fonts. It allows the use of any system font that text() will take. Text size, colour and position can also be controlled.
This code can undoubtedly be tweaked (or maybe just rewritten) to produce more aesthetically pleasing results. Feel free to build upon it! |
| Required Products |
MATLAB
|
| MATLAB release |
MATLAB 7.14 (R2012a)
|
|
Tags for This File
|
| Everyone's Tags |
|
| Tags I've Applied |
|
| Add New Tags |
Please login to tag files.
|
| Updates |
| 27 Mar 2013 |
Wrote a demonstration script to produce the screenshot, which revealed a vertical clipping bug when using large fonts - this has been fixed. Also avoided some error conditions when requested position is almost or completely outside the image. |
| 18 Apr 2013 |
Included drawnow call in BitmapFont and removed dependency on Image Processing Toolbox as suggested by B Treeby. Also added a separate version which adds a border to the text with custom colour and thickness. |
|
Contact us