Thursday, 15 January 2015

insert text into image without computer vision system toolbox - Matlab -



insert text into image without computer vision system toolbox - Matlab -

in matlab central (http://www.mathworks.com/matlabcentral/answers/26033-how-to-insert-text-into-image) found code:

text = sprintf('create text inserter object \nwith same property values'); h = vision.textinserter(text); h.color = [1.0 1.0 0]; h.fontsize = 20; h.location = [25 25]; = im2double((imread('football.jpg'))); insertedimage = step(h, i); imshow(insertedimage);

how can same without using computer vision scheme toolbox?

thanks

to follow on comment:

a = imread('football.jpg'); yourtext = sprintf('create text inserter object \nwith same property values'); figure; imshow(a); htext = text(25,25,yourtext,'color',[1 1 0],'fontsize',20);

giving following:

look @ doc page see options available modify/customize text. notice don't have utilize sprintf generate string, newline character (\n) must used within sprintf in order work.

edit in response comment below, if need save image text embedded in can utilize getframe content of figure , imwrite save it:

hframe = getframe(gca) %// content of figure imwrite(hframe.cdata,'myimage.tif','tif') %// save actual data, contained in cdata property of hframe

edit #2 alternatives using getframe, here there 2 nice ideas proposed, i.e. using saveas or avi files.

matlab

No comments:

Post a Comment