image_get_pixel_gray()

Returns the grayscale intensity of a specific pixel in an image.

Computes grayscale value using the formula: Gray = (0.299 * R + 0.587 * G + 0.114 * B) / 255.0

Syntax

planetcnc.image_get_pixel_gray(image, x, y)

Parameters

Parameter Type Description Comment
image capsule Image object capsule.
x int X coordinate of the pixel.
y int Y coordinate of the pixel.

Return Value

Examples

#! /usr/bin/env python
 
import planetcnc
 
# Assuming 'img' is a valid image capsule object
gray_value = planetcnc.image_get_pixel_gray(img, 10, 20)
print(f"Grayscale intensity at (10,20): {gray_value}")

See also

image_open
image_open_data
image_close
image_save
image_size
image_get_pixel
image_get_pixel_gray
image_to_cam
image_from_cam