Доступ к файлам
Различные среды программирования обработки, пакеты анализа данных предоставляют для ввода данных, различных форматов, отработанные процедуры, классы, СОМ – объекты. Среди них выделяются универсальные, не привязанные к внутренней структуре файла функции. Примером могут служить функции среды Mathcad READBIN() и обратная функция WRITEBIN(). Их параметры описаны ниже:
READBIN("file", "type", [[endian], [cols], [skip], [maxrows]]) Returns an containing the binary data in file.
WRITEBIN("file", "type", endian, [M]) writes an of scalars to the binary data file named file. This function can be used either on the right or the left side of the . When used on the right, you must supply the argument M, the name of the matrix to write to the file. In this case, the function returns the contents of the matrix. When used on the left, do not supply the argument M, but instead place it on the right-hand side of the definition. See the QuickSheet Example.
Arguments:
· file is a containing the filename or the full and filename. Pathnames are relative to the .
· type is a that specifies the data format used in the file. READBIN supports the following data types:
· byte - 8-bit unsigned integer.
· double - 64-bit floating point number.
· float - 32-bit floating point number.
· int16 - signed 16-bit integer.
· int32 - signed 32-bit integer.
· uint16 - unsigned 16-bit integer.
· uint32 - unsigned 32-bit integer.
· endian (optional for READBIN) indicates whether the data in the file is big-endian (high byte first) or little-endian (low byte first). Big-endian is represented by a 1, while little-endian is represented by a 0. If no value is specified, endian is assumed to be 0.
· cols (optional) is the positive integer number of columns per row in the input file. Default is 1.
· skip (optional) is the non-negative integer number of bytes at the beginning of the file to ignore before reading in data. Default is 0.
· maxrows (optional) is the non-negative integer maximum number of rows of data to be read from the data file. Default is 0 (no limit).
Note:
· If you are not sure whether your data is written in big-endian (the Macintosh standard) or little-endian (the IBM-PC standard) format, please consult the system documentation for your data source before relying upon the accuracy of any result from READBIN or WRITEBIN.
Функции, ориентированные на конкретную предметную область разнообразны и сами производят дешифрацию данных, предоставляя их в наиболее удобном для анализа виде. Следующее функции преобразуют прочитанные файлы изображений представленных в различных форматах в матрицу.
READ_IMAGE("file") Creates an array containing a grayscale representation of the image file.
READBMP("file") Creates an array containing a grayscale representation of a bitmap format image file. (deprecated)
READRGB("file") Creates an array containing a red-green-blue packed matrix representation of the image file.
READ_RED("file"), READ_GREEN("file"), READ_BLUE("file") Create an array containing only the red, green, or blue component from a color image file.
WRITEBMP("file", [M]) Creates an grayscale bitmap image file. This function can be used either on the right or the left side of the definition operator. When used on the right, you must supply the argument M, the name of the matrix to write to the file. In this case, the function returns 0. When used on the left, do not supply the argument M, but instead place it on the right hand side of the definition.
WRITERGB("file", [M]) Creates an 16-million-color bitmap image file. This function can be used either on the right or the left side of the definition operator. Notes for WRITEBMP apply.
READ_HLS("file") Creates an array containing a hue, lightness, and saturation representation of the image file.
READ_HLS_HUE("file"), READ_HLS_LIGHT("file"), READ_HLS_SAT("file") Extract only the hue, light, or saturation component from a color image.
READ_HSV("file") Creates an array containing a hue, saturation, and value representation of the image file.
READ_HSV_HUE("file"), READ_HSV_SAT("file"), READ_HSV_VALUE("file") Extract only the hue, saturation, or value component from a color image.
WRITE_HSV("file", [M]) Creates an 16-million-color bitmap image file. This function can be used either on the right or the left side of the definition operator. Notes for WRITEBMP apply.
WRITE_HLS("file", [M]) Creates an 16-million-color bitmap image file. This function can be used either on the right or the left side of the definition operator. Notes for WRITEBMP apply.
Arguments:
- "file" is a string containing the file name or the full pathname and the file name. Recognized image formats are BMP, GIF, JPG, PCX, or TGA.
- M is a matrix.
Notes:
- Function names are all UPPERCASE.
- Regardless of original image file format, images in Mathcad are matrices with values between 0 (black) and 255 (white), which can be displayed with the Picture operator. Each matrix element represents the intensity of one pixel. RGB Color images are stored as three packed m x n matrices, augmented as follows:
Аналогично и в других средах, например, в С++ совокупности с SDK DirectX чтение различных форматов не вызывает затруднений. Это - данные, изображения и т. п.:
Дата добавления: 2015-03-23; просмотров: 1610;