text¶
-
odl.phantom.misc_phantoms.
text
(space, text, font=None, border=0.2, inverted=True)[source]¶ Create phantom from text.
The text is represented by a scalar image taking values in [0, 1]. Depending on the choice of font, the text may or may not be anti-aliased. anti-aliased text can take any value between 0 and 1, while non-anti-aliased text produces a binary image.
This method requires the
pillow
package.- Parameters
- space
DiscretizedSpace
Discretized space in which the phantom is supposed to be created. Must be two-dimensional.
- textstr
The text that should be written onto the background.
- fontstr, optional
The font that should be used to write the text. Available options are platform dependent. Default: Platform dependent. ‘arial’ for windows, ‘LiberationSans-Regular’ for linux and ‘Helvetica’ for OSX
- borderfloat, optional
Padding added around the text. 0.0 indicates that the phantom should occupy all of the space along its largest dimension while 1.0 gives a maximally padded image (text not visible).
- invertedbool, optional
If the phantom should be given in inverted style, i.e. white on black.
- space
- Returns
- phantom
space
element The text phantom in
space
.
- phantom
Notes
The set of available fonts is highly platform dependent, and there is no obvious way (except from trial and error) to find what fonts are supported on an arbitrary platform.
In general, the fonts
'arial'
,'calibri'
and'impact'
tend to be available on windows.Platform dependent tricks:
Linux:
$ find /usr/share/fonts -name "*.[to]tf"