Be the first to rate this file! 25 Downloads (last 30 days) File Size: 17.59 KB File ID: #31187
image thumbnail

Label Image

by Amitabh Verma

 

25 Apr 2011 (Updated 13 Apr 2012)

Script to place text label on the image without losing on the pixel information by pixel replacement

| Watch this File

File Information
Description

This function is useful in placing text label, time-stamps, legends, etc. on the image without any loss in image quality. It also does not depend on the getframe method which renders the desktop useless during the process.

This is a function representation of the ImagePatchTool
http://www.mathworks.com/matlabcentral/fileexchange/25111-imagepatchtool
Different character set / fonts can also be generated using the ImagePatchTool and incorporated into this script.

Usage:
       iout = labelimg(original, label_text)
       iout = labelimg(original, label_text, location)

Please feel free to report bugs, feature request, comments and suggestions.

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
ImagePatchTool

Required Products Image Processing Toolbox
MATLAB release MATLAB 7.10 (2010a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (5)
11 Apr 2012 E B

Could you provide an example of using this function with a given figure?

11 Apr 2012 Amitabh Verma

You can try it out using the following

figure
ax(1) = subplot(1,2,1);
I = imread('rice.png');
imshow(I); title('Unlabelled image')

ax(2) = subplot(122);
iout = labelimg(I, 'This is a Rice Image');
imshow(iout); title('Labelled image')
imwrite(iout, 'rice_labelled.png')
% The saved image looks better than the figure window

12 Apr 2012 E B

Thanks! Problem is, even with your code above, i can't see the label. i don't get any errors or problems, it displays and saves just fine, but just no label!

12 Apr 2012 Amitabh Verma

I tested with R2012a and 2011b and it works fine for me.
I am suspecting it could be with the character encoding. Could you try the following and tell what output you get

>> unicode2native('abc')

19 Apr 2012 E B

The output was 97 98 99. I'm running R2011a. I haven't tried anything else yet with your file but will be working on it again today. Thanks for your help.

Please login to add a comment or rating.
Updates
13 Apr 2012

12 Apr 2012

Changes in ver 1.01
1. Fix for Matlab's default character encoding

Tag Activity for this File
Tag Applied By Date/Time
image Amitabh Verma 26 Apr 2011 10:47:24
label Amitabh Verma 26 Apr 2011 10:47:24
overlay Amitabh Verma 26 Apr 2011 10:47:24
patching Amitabh Verma 26 Apr 2011 10:47:24
stitching Amitabh Verma 26 Apr 2011 10:47:24
text Amitabh Verma 26 Apr 2011 10:47:24
timestamp Amitabh Verma 26 Apr 2011 10:47:24
watermark Amitabh Verma 26 Apr 2011 10:47:24

Contact us at files@mathworks.com