text image in matlab without using getframe
3 ビュー (過去 30 日間)
古いコメントを表示
Hi, I would like to create a text image in matlab, so to say write a text and save it as an image. I have already managed to implement this by the following steps,
1) Creating a new figure and create an image in the figure.
2) Type in some text using the "text" function.
3) Since text only creates text in one pixel (the text looks larger, though the text data is only located in one pixel. The scaling is external and not a part of the image), I use getframe to take a screenshot of the frame.
4) Close the figure and extract frame data from the output of getframe.
5) Extract the desired part of the frame and discards the rest, create a new figure with desired data and save it.
The method works fine except for in step 3). The problem is that get frame takes a screenshot of the current axis. This makes the whole method unstable since the a screenshot only captures what is on the screen. If I do other work on the computer on the same time, this may appear in the image instead of the expected text. I do not have the "Computer Vision System Toolbox" so I cannot use insertText. Are there any other ways to do this that does not require getframe?
Thankful for answer, Patrik
1 件のコメント
回答 (1 件)
DGM
2024 年 10 月 20 日
See:
The accepted answer has unnecessary flaws, but I give an attempt to improve upon it. I don't think figure capture is even remotely elegant, and it takes some effort to make sure the capture process doesn't cause the image to be resized/padded/distorted.
That answer also covers text insertion by basic composition and it reviews multiple user-submitted File Exchange submissions, which all have varied functionality.
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!