class_docstr: Internal class for `pyspark.ml.image.ImageSchema` attribute. Meant to be private and
  not to be instantized. Use `pyspark.ml.image.ImageSchema` attribute to access the
  APIs of this class.
class_docstr_tok: ["Internal","class","for","`","pyspark.ml.image.ImageSchema","`","attribute",".","Meant","to","be","private","and","not","to","be","instantized",".","Use","`","pyspark.ml.image.ImageSchema","`","attribute","to","access","the","APIs","of","this","class","."]
docstr: Converts an image to an array with metadata.
  
  Parameters
  ----------
  image : :class:`Row`
      image: A row that contains the image to be converted. It should
      have the attributes specified in `ImageSchema.imageSchema`.
  
  Returns
  -------
  :class:`numpy.ndarray`
      that is an image.
  
  .. versionadded:: 2.3.0
docstr_tok: ["Converts","an","image","to","an","array","with","metadata",".","Parameters","--","--","--","--","--","image",":",":","class",":","`","Row","`","image",":","A","row","that","contains","the","image","to","be","converted",".","It","should","have","the","attributes","specified","in","`","ImageSchema.imageSchema","`",".","Returns","--","--","--","-",":","class",":","`","numpy.ndarray","`","that","is","an","image",".","..","versionadded",":",":","2.3.0"]
code: def toNDArray(self, image: Row) -> np.ndarray:
      """
      Converts an image to an array with metadata.
  
      Parameters
      ----------
      image : :class:`Row`
          image: A row that contains the image to be converted. It should
          have the attributes specified in `ImageSchema.imageSchema`.
  
      Returns
      -------
      :class:`numpy.ndarray`
          that is an image.
  
      .. versionadded:: 2.3.0
      """
  
      if not isinstance(image, Row):
          raise TypeError(
              "image argument should be pyspark.sql.types.Row; however, "
              "it got [%s]." % type(image)
          )
  
      if any(not hasattr(image, f) for f in self.imageFields):
          raise ValueError(
              "image argument should have attributes specified in "
              "ImageSchema.imageSchema [%s]."
              % ", ".join(self.imageFields)
          )
  
      height = image.height
      width = image.width
      nChannels = image.nChannels
      return np.ndarray(
          shape=(height, width, nChannels),
          dtype=np.uint8,
          buffer=image.data,
          strides=(width * nChannels, nChannels, 1),
      )
  
file_path: spark/python/pyspark/ml/image.py
imports: import sys
  from typing import Any, Dict, List, NoReturn, Optional, cast
  import numpy
  from pyspark import SparkContext
  from pyspark.sql.types import Row, StructType, _create_row, _parse_datatype_json_string
  from pyspark.sql import SparkSession
label_desc: Use image node_id 7 for calling the _ImageSchema obj's underlying member method code with example usage: obj.toNDArray(image) and returns: np