how to count visible lines in textArea?
7 次查看(过去 30 天)
显示 更早的评论
I have a long text in Text Area, which is too long to fit. As the app window and the text area is changing size (possibly also font size), the text is partially hidden. I'd like to know, how many lines of text are actually visible.
0 个评论
回答(1 个)
Image Analyst
2022-6-29
I'd take a vertical profile and threshold it. You forgot to attach your picture. But if you have an image with black text on a white background
verticalProfile = mean(grayImage, 2);
mask = verticalProfile < 128;
[labeledLines, numberOfLines] = bwlabel(mask)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!