Image Processing Toolbox User's Guide Previous page   Next Page
imagemodel

Access to properties of an image relevant to its display

Syntax

Description

imgmodel = imagemodel(himage) create an image model object associated with the target image himage. himage is a handle to an image object or an array of handles to image objects.

imagemodel returns an image model object or, if himage is an array of image objects, an array of image model objects.

An image model object stores information about an image such as class, type, display range, width, height, minimum intensity value and maximum intensity value.

The image model object supports methods that you can use to access this information, get information about the pixels in an image, and perform special text formatting. The following lists these methods with a brief description. Use methods(imgmodel) to get a list of image model methods.

Method
Description
getClassType
Returns a string indicating the class of the image.

str = getClassType(imgmodel)

where imgmodel is a valid image model and str is a text string, such as 'uint8'.
getDisplayRange
Returns a double array containing the minimum and maximum values of the display range for an intensity image. For image types other than intensity, the value returned is an empty array.

disp_range = getDisplayRange(imgmodel)

where imgmodel is a valid image model and disp_range is an array of doubles, such as [0 255].
getImageHeight
Returns a double scalar containing the number of rows.

height = getImageHeight(imgmodel)

where imgmodel is a valid image model and height is a double scalar.
getImageType
Returns a text string indicating the image type.

str = getImageType(imgmodel)

where imgmodel is a valid image model and str is one of the text strings 'intensity', 'truecolor', 'binary', or 'indexed'.
getImageWidth
Returns a double scalar containing the number of columns.

width = getImageWidth(imgmodel)

where imgmodel is a valid image model and width is a double scalar.
getMinIntensity
Returns the minimum value in the image calculated as min(Image(:)). For an intensity image, the value returned is the minimum intensity. For an indexed image, the value returned is the minimum index. For any other image type, the value returned is an empty array.

minval = getMinIntensity(imgmodel)

where imgmodel is a valid image model and minval is a numeric value. The class of minval depends on the class of the target image.
getMaxIntensity
Returns the maximum value in the image calculated as max(Image(:)). For an intensity image, the value returned is the maximum intensity. For an indexed image, the value returned is the maximum index. For any other image type, the value returned is an empty array.

maxval = getMaxIntensity(imgmodel)

where imgmodel is a valid image model and maxval is a numeric value. The class of maxval depends on the class of the target image.
getNumberFormatFcn
Returns the handle to a function that converts a numeric value into a string.

fun = getNumberFormatFcn(imgmodel)

where imgmodel is a valid image model. fun is a handle to a function that accepts a numeric value and returns the value as a text string. For example, you can use this function to convert the numeric return value of the getPixelValue method into a text string.

str = fun(getPixelValue(imgmodel,100,100))
getPixelInfoString
Returns a text string containing value of the pixel at the location specified by row and column.

str = getPixelInfoString(imgmodel,row,column)

where imgmodel is a valid image model and row and column are numeric scalar values. str is a character array. For example, for an RGB image, the method returns a text string such as '[66 35 60]'.
getPixelRegionFormatFcn
Returns a handle to a function that formats the value of a pixel into a text string.

fun = getPixelRegionFormatFcn(imgmodel)

where imgmodel is a valid image model. fun is a handle to a function that accepts the location (row,column) of a pixel in the target image and returns the value of the pixel as a specially formatted text string. For example, when used with an RGB image, this function returns a text string of the form 'R:000 G:000 B:000' where 000 is the actual pixel value.

str = fun(100,100)
getPixelValue
Returns the value of the pixel at the location specified by row and column as a numeric array.

val = getPixelValue(imgmodel,row, column)

where imgmodel is a valid image model and row and column are numeric scalar values. The class of val depends on the class of the target image.
getDefaultPixelInfoString
Returns a text string indicating the type of information returned in a pixel information string. This string can be used in place of actual pixel information values.

str = getDefaultPixelInfoString(imgmodel)

where imgmodel is a valid image model. Depending on the image type, str can be the text string 'Intensity','[R G B]','BW', or '<Index> [R G B]'.
getDefaultPixelRegionString
Returns a text string indicating the type of information displayed in the Pixel Region tool for each image type. This string can be used in place of actual pixel values.

str = getDefaultPixelRegionString(imgmodel)

where imgmodel is a valid image model. Depending on the image type, str can be the text string '000','R:000 G:000 B:000]', '0', or '<000> R:0.00 G:0.00 B:0.00'.
getScreenPixelRGBValue
Returns the screen display value of the pixel at the location specified by ROW and COLUMN as a double array.

val = getScreenPixelRGBValue(imgmodel,row, col)

where imgmodel is a valid image model and row and col are numeric scalar values. val is an array of doubles, such as [0.2 0.5 0.3].

Note

imagemodel works by querying the image object's CData. For a single or int16 image, the image object converts its CData to double. For example, in the case of h = imshow(int16(ones(10))), class(get(h,'CData')) returns 'double'. Therefore, getClassType(imgmodel) returns 'double'.

Examples

This example creates an image model.

See Also

getimagemodel


Previous page  imageinfo imapprox Next page

© 1994-2005 The MathWorks, Inc.