Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some text #17

Open
yakir12 opened this issue Nov 24, 2017 · 15 comments
Open

Add some text #17

yakir12 opened this issue Nov 24, 2017 · 15 comments
Assignees

Comments

@yakir12
Copy link
Contributor

yakir12 commented Nov 24, 2017

Other than colored shapes, it would be great if we could also add some text to the images.

I use this to color tracked paths in a composite image from time-lapse images, but I need to some how label individual tracks with an ID (like a bunch of numbers and/or letters).

Hmmm, maybe it would be easier to combine the image with vector graphics somehow.

@yakir12
Copy link
Contributor Author

yakir12 commented Nov 27, 2017

Plots.jl's heatmap with annotate are more than sufficient for this kind of stuff. Keeping this open for your discretion.

@yakir12
Copy link
Contributor Author

yakir12 commented Feb 19, 2018

I totally missed ImageView.annotations...

@johnnychen94 johnnychen94 self-assigned this Nov 8, 2019
@johnnychen94
Copy link
Member

Missed this issue. I also want this feature implemented. Will do that when I'm available.

@IanButterworth
Copy link
Member

@johnnychen94 I made a very basic string->image renderer, that's 100% julia with no lib dependencies. It's not set up to handle line feeds or different alignment, but it's very simple, which might make it well suited to the simplicity of ImageDraw (which I really like).

https://github.com/ianshmean/BasicTextRender.jl

@johnnychen94
Copy link
Member

johnnychen94 commented Nov 11, 2019

It looks good, one potential issue is that BasicTextRender.jl depends on ImageFiltering, which is not lightweight.

julia> @time using BasicTextRender
  4.702237 seconds (4.56 M allocations: 257.833 MiB, 4.13% gc time)

julia> @time using ImageFiltering
  3.592120 seconds (3.39 M allocations: 200.497 MiB, 5.41% gc time)

@IanButterworth
Copy link
Member

Ah yes. If there's a lighter-weight way to blur an image before resizing, I'd happily swap it out

@yakir12
Copy link
Contributor Author

yakir12 commented Nov 11, 2019

Or maybe simply don't. There might be a font size that is not too large to slow the loading, nor too small for a nice resize within reasonable margins. This is very simple, so you'll run into feature-requests pretty quick. This can just be one of them.

@IanButterworth
Copy link
Member

IanButterworth commented Nov 12, 2019

Maybe it could use something like this and define the font at it's smallest size, and scale up instead of scaling down.. no blurring needed

Edit: More thought on this.. it would require font sizes to be equal to integer multiples of the height of the base font (9 pixels)

@timholy
Copy link
Member

timholy commented Nov 12, 2019

We could conceivably split ImageFiltering into smaller pieces, but since BasicTextRender uses two of the major arms (IIR and FIR) I am not sure there would be much benefit.

@IanButterworth
Copy link
Member

IanButterworth commented Nov 12, 2019

Suddenly Basic doesn't seem so basic... How about just using FreeTypeAbstraction.jl? These times seem manageable?

using ImageCore, BenchmarkTools
@time using FreeTypeAbstraction 
#1.035022 seconds (1.61 M allocations: 96.270 MiB)

@time face = newface(joinpath(@__DIR__,"monogram.ttf")) 
#0.019520 seconds (50.55 k allocations: 2.532 MiB)

img = rand(RGBA{Float64},110,1300)

@btime renderstring!(img, "String", face, (170,170), 10, 10, halign=:hleft, 
                valign=:vtop, fcolor=RGBA(0.0, 0.0, 0.0, 1.0), bcolor=nothing) 
#108.284 μs (429 allocations: 57.63 KiB)

@ashwani-rathee
Copy link
Member

ashwani-rathee commented Dec 17, 2020

Hey @ianshmean @yakir12 ,has there been any progress on this task from your side??
https://github.com/ianshmean/BasicTextRender.jl is pretty good actually

@yakir12
Copy link
Contributor Author

yakir12 commented Feb 19, 2021

no news from me...

@ashwani-rathee
Copy link
Member

I would like to work on this if that's okay

@yakir12
Copy link
Contributor Author

yakir12 commented Mar 23, 2021

I think @IanButterworth and @timholy are the main contributors to this specific problem (and many many more). I think it's safe to say that both welcome high quality PRs! But I'm sure they'll have a lot more to say about where this specific issue is at.

@ashwani-rathee
Copy link
Member

ashwani-rathee commented Mar 23, 2021

I think Ian Butterworth's solution in BasicTextRender.jl uses proper bitmap fonts method only,Luxor.jl uses Cairo toy text Text API
This should be interesting to explore
https://learnopengl.com/In-Practice/Text-Rendering
I would kind of need the text rendering feature for working on this issue: JuliaArrays/MosaicViews.jl#25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants