-
Notifications
You must be signed in to change notification settings - Fork 55
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
Surface for 8-bit grayscale image #125
Comments
CAIRO_FORMAT_A8 (see http://cairographics.org/manual/cairo-Image-Surfaces.html#cairo-format-t) is 8 bit, but alpha channel only. This is usually used as a alpha mask for painting. You could e.g. use this to paint black color source to a white background with your image in the _A8 alpha map to paint a grayscale image, but the easier way is to use one of the color formats (_RGB). |
Thanks @lobingera. |
Is there any reason you need to use Cairo? The ColorTypes and Images packages supports 8-bit grayscale natively. In previous benchmarking, we've found julia code, especially when dealing with grayscale, to be faster than libcairo by fairly large factors (3-10 or so). |
@timholy Can ColorTypes/Images deal with drawing shapes/lines? What I need is to make arrays whose elements can form many "shapes" (such as rectangles or triangles...) |
@timholy, could you please link to this benchmarking? |
@xanadupark, no, there is no drawing. You could see if Drawing.jl would be interested in a non-Cairo backend, but then someone would have to implement it. Two benchmarks that come to mind:
@lobingera, you were on both of those threads, if you wanted links you could have provided them yourself 😛 |
@timholy, i'm always hoping for something more recent. |
By all means, run the code in those benchmarks and report the results. |
Just for the record, after copying the code Tim's code from the first thread and working around the dep warnings in 0.4.1 -> julia> include("image-resize.jl") |
Fascinating. On my machine the julia code is still faster, especially if I replace The difference is that the Cairo version got faster, not that the julia code (if you make that change) got slower. Nice! |
I think there was some work on pixman (the SW that deals with pixel operations and blitting) especially on interpolation in finishing 1.14. But still, Cairo is not the place for image operations, but elegant and efficient image display. |
Thanks everybody. I found out there is no proper Julia package at this time for my use. Thanks all for your advise. |
Hello all,
I recently tried to use Julia/Cairo for an image generation of 8-bits gray scale.
In fact, what I need is an uint8 array with each element represent the gray scale for the further calculation. (It is conventional 8-bit grayscale image, I think)
However, I cannot find the way to make grayscale surface with Cairo.
At first, I assumed that CAIRO_FORMAT_A8 is the grayscale surface and also assumed that the data array has to be an uint8 array. However, there's error like follows:
dt
isArray{UInt8,2}
And then, I convert the
dt
array to uint32:Of course, I can make the image surface with ARGB or RGB format.
Is this a bug or my short knowledge of Cairo?
Thanks in advance
The text was updated successfully, but these errors were encountered: