Add text to an image

Put text into the corner of an image in order to make their presentation better.
42 Downloads
Updated 11 Jul 2023

View License

Hi there,
convert_text_to_image is a function that put text into the corner of an image in order to makes their presentation better.
The main idea is put a text plus a data in the corner of the image, with the option of tuneate their scale. Inputs:
imatge_ficar_text - the main image. This can be in different formats
text_introduir - the text to introduce. If you don't want to put text, just put "".
dades_introduir - the data to introduce. If you don't want to put numbers, just put "".
escala_opci - if you want to scale the dimensions of the letters. Eye with do not put a too-much scale.
As ouput is the image.
This function works with the neat function text2im.m, Convert text to an image, developed by Tobias Kiessling(Tboias Kiessling 2021). This function I modificate just the first part because gave me an error.
Reference
Tobias Kiessling (2021). Convert Text to an image (https://www.mathworks.com/matlabcentral/fileexchange/19896-convert-text-to-an-image), MATLAB Central File Exchange. Retrieved August 6, 2021.
As code example:
I_celeg_raw = imread('http://www.news.wisc.edu/newsphotos/images/Kimble_worm_c_elegans2_02.jpg');
I_celeg_BW = rangefilt(I_celeg); I_celeg_BW = imbinarize(I_celeg_BW); SE = strel("disk", 8); I_celeg_BW = imclose(I_celeg_BW, SE); I_celeg_BW = imfill(I_celeg_BW, "holes");
imshow(I_celeg_BW)
[sfMaskBurn_new] = add_text_to_image(I_celeg_BW, "This is the text, and could be numbers: ", 1234);
imshow(sfMaskBurn_new)
[sfMaskBurn_new] = add_text_to_image(I_celeg_BW, "This is the text, and could be numbers: ", "", 2);
imshow(sfMaskBurn_new)
Thank you for reading, I hope it will be useful.
PS: I am working in image process of C.elegans, if anyone would like to share content in private I would be glad of discuss that.

Cite As

Josep Llobet (2024). Add text to an image (https://www.mathworks.com/matlabcentral/fileexchange/97207-add-text-to-an-image), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2021a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.1

asdf

1.0.0