-
Notifications
You must be signed in to change notification settings - Fork 9
Closed
Description
I am running into some issues when iterating over the pixels of an image. The image I'm dealing with is 1920x1080px, and iterating over a single row takes 8s -- without doing any real work. Iterating over all 1080 rows by extension would take much longer than an hour.
local img = Image.new_from_file("image.jpg")
local start = os.clock()
for x = 0, (img:width() - 1) do
local _ = img(x, 0)
end
print(string.format("Elapsed time: %.02f ms", (1000 * (os.clock() - start))) # Elapsed time: 7646.47 ms
I am trying to work with the image pixels directly to experiment with different clustering algorithms in Lua. Is this something that I can improve or sidestep somehow? I was assuming the approach in https://github.com/libvips/lua-vips/blob/a050f50c/example/array.lua might be faster, but running this fails:
# lua -v
LuaJIT 2.1.1693350652 -- Copyright (C) 2005-2023 Mike Pall. https://luajit.org/
# lua array.lua
lua: array.lua:14: bad storage class near 'typedef'
stack traceback:
[C]: in function 'typeof'
array.lua:14: in main chunk
[C]: at 0x004062d0
Metadata
Metadata
Assignees
Labels
No labels