當前位置:成語大全網 - 新華字典 - Matlab中如何只把figure中的圖像區域保存為圖片文件

Matlab中如何只把figure中的圖像區域保存為圖片文件

似乎很難該的哦。如果妳真的很想那樣的話,建議使用屏幕截圖工具。

Vista系統的話有自帶的截圖工具。

QQ上面也有截圖工具,如果有運行QQ程序的話,按下

Alt+Ctrl+A就可以截圖了,想怎麽截就怎麽截。

這個函數妳看看不是是可以

>> help imwrite

IMWRITE Write image to graphics file.

IMWRITE(A,FILENAME,FMT) writes the image A to the file specified by

FILENAME in the format specified by FMT.

A can be an M-by-N (grayscale image) or M-by-N-by-3 (color image)

array. A cannot be an empty array. If the format specified is TIFF,

IMWRITE can also accept an M-by-N-by-4 array containing color data

that uses the CMYK color space.

FILENAME is a string that specifies the name of the file.

FMT is a string specifying the format of the file. See the reference

page, or the output of the IMFORMATS function, for a list of

supported formats.

IMWRITE(X,MAP,FILENAME,FMT) writes the indexed image in X and its

associated colormap MAP to FILENAME in the format specified by FMT.

If X is of class uint8 or uint16, IMWRITE writes the actual values in

the array to the file. If X is of class double, IMWRITE offsets the

values in the array before writing, using uint8(X-1). MAP must be a

valid MATLAB colormap. Note that most image file formats do not

support colormaps with more than 256 entries.

IMWRITE(...,FILENAME) writes the image to FILENAME, inferring the

format to use from the filename's extension. The extension must be

one of the legal values for FMT.

IMWRITE(...,PARAM1,VAL1,PARAM2,VAL2,...) specifies parameters that

control various characteristics of the output file. Parameters are

currently supported for HDF, JPEG, TIFF, PNG, PBM, PGM, and PPM files.

Class Support

-------------

The input array A can be of class logical, uint8, uint16, or double.

Indexed images (X) can be of class uint8, uint16, or double; the

associated colormap, MAP, must be double.

The class of the image written to the file depends on the format

specified. For most formats, if the input array is of class uint8,

IMWRITE outputs the data as 8-bit values. If the input array is of

class uint16 and the format supports 16-bit data (JPEG, PNG, and

TIFF), IMWRITE outputs the data as 16-bit values. If the format does

not support 16-bit values, IMWRITE issues an error. Several formats,

such as JPEG and PNG, support a parameter that lets you specify the

bit depth of the output data.

If the input array is of class double, and the image is a grayscale

or RGB color image, IMWRITE assumes the dynamic range is [0,1] and

automatically scales the data by 255 before writing it to the file as

8-bit values.

If the input array is of class double, and the image is an indexed

image, IMWRITE converts the indices to zero-based indices by

subtracting 1 from each element, and then writes the data as uint8.

If the input array is of class logical, IMWRITE assumes the data is a

binary image and writes it to the file with a bit depth of 1, if the

format allows it. BMP, PNG, or TIFF formats accept binary images as

input arrays.

HDF-specific parameters

-----------------------

'Compression' One of these strings: 'none' (the default),

'rle' (only valid for grayscale and indexed

images), 'jpeg' (only valid for grayscale

and RGB images)

'Quality' A number between 0 and 100; parameter applies

only if 'Compression' is 'jpeg'; higher

numbers mean quality is better (less image

degradation due to compression), but the

resulting file size is larger

'WriteMode' One of these strings: 'overwrite' (the

default) or 'append'

JPEG-specific parameters

------------------------

'Quality' A number between 0 and 100; higher numbers

mean quality is better (less image degradation

due to compression), but the resulting file

size is larger

'Comment' A column vector cell array of strings or a

char matrix. Each row of input is written out

as a comment in the JPEG file.

'Mode' Either 'lossy' (the default) or 'lossless'

'BitDepth' A scalar value indicating desired bitdepth;

for grayscale images this can be 8, 12, or 16;

for truecolor images this can be 8 or 12

TIFF-specific parameters

------------------------

'Colorspace' One of these strings: 'rgb', 'cielab', or

'icclab'. The default value is 'rgb'. This

parameter is used only when the input array,

A, is M-by-N-by-3. See the reference page

for more details about creating L*a*b* TIFF

files.

'Compression' One of these strings: 'none', 'packbits'

(default for nonbinary images), 'ccitt'

(default for binary images), 'fax3', 'fax4';

'ccitt', 'fax3', and 'fax4' are valid for

binary images only

'Description' Any string; fills in the ImageDescription

field returned by IMFINFO

'Resolution' A two-element vector containing the

XResolution and YResolution, or a scalar

indicating both resolutions; the default value

is 72

'WriteMode' One of these strings: 'overwrite' (the

default) or 'append'

PNG-specific parameters

-----------------------

'Author' A string

'Description' A string

'Copyright' A string

'CreationTime' A string

'Software' A string

'Disclaimer' A string

'Warning' A string

'Source' A string

'Comment' A string

'InterlaceType' Either 'none' or 'adam7'

'BitDepth' A scalar value indicating desired bitdepth;

for grayscale images this can be 1, 2, 4,

8, or 16; for grayscale images with an

alpha channel this can be 8 or 16; for

indexed images this can be 1, 2, 4, or 8;

for truecolor images with or without an

alpha channel this can be 8 or 16

'Transparency' This value is used to indicate transparency

information when no alpha channel is used.

For indexed images: a Q-element vector in

the range [0,1]; Q is no larger than the

colormap length; each value indicates the

transparency associated with the

corresponding colormap entry

For grayscale images: a scalar in the range

[0,1]; the value indicates the grayscale

color to be considered transparent

For truecolor images: a 3-element vector in

the range [0,1]; the value indicates the

truecolor color to be considered

transparent

You cannot specify 'Transparency' and

'Alpha' at the same time.

'Background' The value specifies background color to be

used when compositing transparent pixels.

For indexed images: an integer in the range

[1,P], where P is the colormap length

For grayscale images: a scalar in the range

[0,1]

For truecolor images: a 3-element vector in

the range [0,1]

'Gamma' A nonnegative scalar indicating the file

gamma

'Chromaticities' An 8-element vector [wx wy rx ry gx gy bx

by] that specifies the reference white

point and the primary chromaticities

'XResolution' A scalar indicating the number of

pixels/unit in the horizontal direction

'YResolution' A scalar indicating the number of

pixels/unit in the vertical direction

'ResolutionUnit' Either 'unknown' or 'meter'

'Alpha' A matrix specifying the transparency of

each pixel individually; the row and column

dimensions must be the same as the data

array; may be uint8, uint16, or double, in

which case the values should be in the

range [0,1]

'SignificantBits' A scalar or vector indicating how many

bits in the data array should be regarded

as significant; values must be in the range

[1,bitdepth]

For indexed images: a 3-element vector

For grayscale images: a scalar

For grayscale images with an alpha channel:

a 2-element vector

For truecolor images: a 3-element vector

For truecolor images with an alpha channel:

a 4-element vector

In addition to these PNG parameters, you can use any

parameter name that satisfies the PNG specification for

keywords: only printable characters, 80 characters or

fewer, and no leading or trailing spaces. The value

corresponding to these user-specified parameters must be a

string that contains no control characters except for

linefeed.

RAS-specific parameters

-----------------------

'Type' One of these strings: 'standard'

(uncompressed, b-g-r color order with

truecolor images), 'rgb' (like 'standard',

but uses r-g-b color order for truecolor

images), 'rle' (run-length encoding of 1-bit

and 8-bit images)

'Alpha' A matrix specifying the transparency of each

pixel individually; the row and column

dimensions must be the same as the data

array; may be uint8, uint16, or double. May

only be used with truecolor images.

PBM, PGM, and PPM-specific parameters

------------------------

'Encoding' One of these strings: 'ASCII' for plain encoding

or 'rawbits' for binary encoding. Default is 'rawbits'.

'MaxValue' A scalar indicating the maximum gray or color

value. Available only for PGM and PPM files.

For PBM files, this value is always 1. Default

is 65535 if image array is 'uint16' and 255 otherwise.

Table: summary of supported image types

---------------------------------------

BMP 1-bit, 8-bit and 24-bit uncompressed images

TIFF Baseline TIFF images, including 1-bit, 8-bit, 16-bit,

and 24-bit uncompressed images; 1-bit, 8-bit, 16-bit,

and 24-bit images with packbits compression; 1-bit

images with CCITT 1D, Group 3, and Group 4 compression;

CIELAB, ICCLAB, and CMYK images

JPEG Baseline JPEG images

PNG 1-bit, 2-bit, 4-bit, 8-bit, and 16-bit grayscale

images; 8-bit and 16-bit grayscale images with alpha

channels; 1-bit, 2-bit, 4-bit, and 8-bit indexed

images; 24-bit and 48-bit truecolor images; 24-bit

and 48-bit truecolor images with alpha channels

HDF 8-bit raster image datasets, with or without associated

colormap; 24-bit raster image datasets; uncompressed or

with RLE or JPEG compression

PCX 8-bit images

XWD 8-bit ZPixmaps

RAS Any RAS image, including 1-bit bitmap, 8-bit indexed,

24-bit truecolor and 32-bit truecolor with alpha.

PBM Any 1-bit PBM image, ASCII (plain) or raw (binary) encoding.

PGM Any standard PGM image. ASCII (plain) encoded with

arbitrary color depth. Raw (binary) encoded with up

to 16 bits per gray value.

PPM Any standard PPM image. ASCII (plain) encoded with

arbitrary color depth. Raw (binary) encoded with up

to 16 bits per color component.

PNM Any of PPM/PGM/PBM (see above) chosen automatically.

See also imfinfo, imread, imformats, fwrite, getframe.

Reference page in Help browser

doc imwrite

>>