-
|
Thanks for the interesting work. How can one replicate the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Hi! First of all, thank you for showing interest in zignal. I had no idea There's no direct support in zignal (the Python bindings only allow you to work with RGBA images, because they can easily be optimized with SIMD operations, as 4 Basic Line Drawing (skimage.draw.line → zignal DrawMode.FAST)# scikit-image
from skimage import draw
canvas = np.zeros((100, 100), dtype=bool)
rr, cc = draw.line(10, 10, 90, 90)
canvas[rr, cc] = True
# Zignal equivalent
from zignal import Image, DrawMode
img = Image(100, 100, 0)
canvas = img.canvas()
canvas.draw_line((10, 10), (90, 90), 255, width=1, mode=DrawMode.FAST)
result = img.to_numpy()[:, :, 0] > 0 # Convert to booleanAntialiased Line Drawing (skimage.draw.line_aa → zignal DrawMode.SOFT)# scikit-image
from skimage import draw
canvas = np.zeros((100, 100), dtype=float)
rr, cc, val = draw.line_aa(10, 10, 90, 90)
canvas[rr, cc] = val
# Zignal equivalent
from zignal import Image, DrawMode
img = Image(100, 100, 0)
canvas = img.canvas()
canvas.draw_line((10, 10), (90, 90), 255, width=1, mode=DrawMode.SOFT)
result = img.to_numpy()[:, :, 0] / 255.0 # Normalized float valuesBut how does it compare to Visual inspection
I would say pretty close
Performance comparisonI drew 100 random lines Fair comparison: including the numpy conversion
Raw drawing comparison: just modifying the pixels in the image
So, I would say zignal is quite fast, but the headstart is counterbalanced as the image gets larger, since we have to perform more operations to binarize/normalize it in NumPy. Note that, if you use an RGBA color in the Anyway, I hope this answers your question. It was fun for me to do it :) |
Beta Was this translation helpful? Give feedback.



Hi! First of all, thank you for showing interest in zignal.
While researching this I found (and fixed 77fea30) a bug in the
draw_lineimplementation, so please use zignal 0.4.1 (just released).I had no idea
skimage.draw.linehad such a feature, it's very versatile and cool!There's no direct support in zignal (the Python bindings only allow you to work with RGBA images, because they can easily be optimized with SIMD operations, as 4
u8can be seen as just au32).However, you can do it with one extra line:
Basic Line Drawing (skimage.draw.line → zignal DrawMode.FAST)