def cl_is_grey(p_rgb, p_cl_context: cl.Context, p_cl_queue: cl.CommandQueue, p_cl_program: cl.Program) -> bool: """Check if an image is grey using OpenCL""" pixels = numpy.array(p_rgb) dev_buf = cl.image_from_array(p_cl_context, pixels, 4) color = numpy.uint32(0) dev_color = cl.Buffer(p_cl_context, cl.mem_flags.COPY_HOST_PTR, hostbuf=color) p_cl_program.isGrey(p_cl_queue, (pixels.shape[0], pixels.shape[1]), None, dev_buf, dev_color) nb_colors = numpy.empty_like(color) cl.enqueue_copy(p_cl_queue, nb_colors, dev_color) return bool(nb_colors == 0)