3.0

3.0 | 2 ratings Rate this file 12 Downloads (last 30 days) File Size: 3.83 KB File ID: #26940
image thumbnail

Render RGB text over RGB or Grayscale Image

by Davide Di Gloria

 

12 Mar 2010 (Updated 05 May 2010)

Utility which renders text over RGB o grayscale image matrices. (no line feed support)

| Watch this File

File Information
Description

by Davide Di Gloria
with the great contribution of Franz-Gerold Url

Render RGB text over RGB or grayscale images of ANY RESOLUTION!

usage:
out=rendertext(target, text, color, pos, mode1, mode2)

target ... MxNx3 or MxN matrix
text ... string (NO LINE FEED SUPPORT)
color ... vector in the form [r g b] 0-255
pos ... position (r,c)

optional arguments: (default is 'ovr','left')
mode1 ... 'ovr' to overwrite, 'bnd' to blend text over image
mode2 ... text aligment 'left', 'mid' or 'right'.

out ... has same size of target

example (generates the sceenshot above):

in=imread('football.jpg');
out=rendertext(in,'OVERWRITE mode',[0 255 0], [1, 1]);
out=rendertext(out,'BLEND mode',[255 0 255], [30, 1], 'bnd', 'left');
out=rendertext(out,'left',[0 0 255], [101, 150], 'ovr', 'left');
out=rendertext(out,'mid',[0 0 255], [130, 150], 'ovr', 'mid');
out=rendertext(out,'right',[0 0 255], [160, 150], 'ovr', 'right');
imshow(out

have fun (and give credit)!

MATLAB release MATLAB 7.8 (R2009a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (8)
08 Apr 2010 Stiphu

How about adding the pictures you used? Absolutely crab...

05 May 2010 Rob Campbell

The images are included in the default Matlab install, Stiphu. At least they are on my machine. However am confused by this function. It just seems like an over-complicated and crippled version of the text command. Question to author: What does this function do that the text command does not?

14 May 2010 Davide Di Gloria

This function RENDERS the text over any matrix, not over the figure. This function allows you to save the image matrix with imwrite() and not by using getframe(). Please consider re-rating :)

14 May 2010 Rob Campbell

I still don't understand the point. Combining text with getframe gives you more flexibility and still gets the job done easily. This function renders in only one font face and (apparently?) only one size.

15 May 2010 Davide Di Gloria

if you have to write a timestamp or something on a 3000x2000 pixels image, getframe() will shrink the image...

27 May 2010 Rob Campbell

Fair enough!

03 Jun 2010 Davide Di Gloria

:)

10 Dec 2010 Ajaxel

very nice, thank you!

Please login to add a comment or rating.
Updates
05 May 2010

added missing chars.bmp file, sorry!

05 May 2010

slight modification to description

Tag Activity for this File
Tag Applied By Date/Time
render text over image Davide Di Gloria 15 Mar 2010 12:36:54
print text over image Davide Di Gloria 15 Mar 2010 12:36:54
image rgb Davide Di Gloria 15 Mar 2010 12:36:54
timestamp Davide Di Gloria 15 Mar 2010 12:36:54
data export Davide Di Gloria 15 Mar 2010 12:36:54

Contact us at files@mathworks.com