.. highlightlang:: us .. index:: ImageGetPixelGray .. _imagegetpixelgray: ImageGetPixelGray ================= .. us.tag ImageGetPixelGray NOTREADYENGLISH Image ImageGet New520 Changed532 :ref:`ImageGetPixelGray` returns the gray value of a pixel. .. function:: gray = ImageGetPixelGray(hImg, x, y) grayMat = ImageGetPixelGray(hImg) .. us.return **Return Value** *gray* is the gray value of the specified pixel in the range 0 to 255. If x or y is out of range the function returns the gray value of the pixel x=1, y=1. In case of an error the functions returns -1. .. us.params **Parameters** .. uparam:: hImg *hImg* identifies the picture created with :ref:`ImageCreate`. .. uparam:: x *x* is the horizontal pixel position in the range 1 to :ref:`ImageGetWidth`. .. uparam:: y *y* is the vertical pixel position in the range 1 to :ref:`ImageGetHeight`. .. us.example **Example** The following saves the gray value in a text file. The data file can be loaded with :ref:`filemore-file-functionsload-3d-data-matrix`. If the image size is big the image size should be reduced to approx. 500 * 500. :: def image_save_pixel(hImg, ssFile) { fp = fopen(ssFile, "wt"); if (!fp) { return FALSE; } dx = ImageGetWidth(hImg); dy = ImageGetHeight(hImg); for (j in 1:dy) { for (i in 1:dx) { g = ImageGetPixelGray(hImg, i, j) fprintf(fp, "%d\t", g); } fprintf(fp, "\n"); } fclose(fp); return TRUE; } .. us.history **History** .. list-table:: :header-rows: 1 * - Version - Description * - 5.3.2 - * - 5.2.0 - New .. seealso:: :ref:`overview-pictures`, :ref:`ImageGetWidth`, :ref:`ImageGetHeight`, :ref:`ImageGetPixelColor`, :ref:`ImageSetPixelGray` :sub:`id-552611`