-
Notifications
You must be signed in to change notification settings - Fork 41
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
documentation on pixel access #31
Comments
We really wrote this in the context of torch, and in that case getting a pixel is pretty direct (access the tensor location). If you want direct pixel access in Lua, you might have to interface a few functions |
sorry I am a very basic developer, are you saying that I need to add a declaration to http://www.graphicsmagick.org/api/pixel_cache.html#acquireonepixel or http://www.graphicsmagick.org/api/pixel_cache.html#getonepixel ? is that done in the Image.lua file at the top between the [[ and ]] i suppose I could use a series of methods, clone():crop():format():tostring() I could get one pixel as a string containing raw bytes... I tried adding declarations for PixelPacket and the getOnePixel() but I don't really know what I am doing with that. I did manage to add declarations for double PixelGetRed( const PixelWand *wand ); and then wrote this function: --get pixel(s) function Image:getPixel(x, y) -- Create PixelWand: local pixelwand = ffi.gc(clib.NewPixelWand(), function(pixelwand) -- Collect: clib.DestroyPixelWand(pixelwand) end) local r,g,b r = clib.PixelGetRed(pixelwand) g = clib.PixelGetGreen(pixelwand) b = clib.PixelGetBlue(pixelwand) print(r) return r,g,b end but of course this doesn't return anything other than 0 because no x,y coordinate is set anywhere. it is probably better to use the pixelPacket approach anyway. not sure where to go from here... can anyone help? |
what is the syntax for getting the value of a pixel?
I have loaded an image and have tried:
width, length = myimage:size() --this works
but there does not appear to be a method in Image.lua that gives pixel access, does one need to be written? something like, Image:get_pixel(x,y) that returns a value and/or Image:get_pixels(x,y,w,h) that returns a table of values indexed by column, row.
or can MagickGetImagePixels be used?
The text was updated successfully, but these errors were encountered: