Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

imagemodel

Image Model object

Syntax

imgmodel = imagemodel(himage)

Description

imgmodel = imagemodel(himage) creates an image model object associated with a target image. The target image 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. imagemodel works by querying the image object's CData.

API Functions

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. Brief descriptions of these methods follow.

Methods

imagemodel supports the following methods. Type methods imagemodel to see a list of methods, or type help imagemodel/methodname for more information about a specific method.

getClassType — Return class of image

imageclass= getClassType(imgmodel) returns the class associated with the imagemodel, imgmodel. The return value, imageclass is a character vector, such as 'uint8', specifying the class of the image object's CData. imgmodel is expected to contain only one imagemodel object.

getDisplayRange — Return display range of intensity image

disp_range = getDisplayRange(imgmodel), where imgmodel is a valid image model and disp_range is an array of doubles such as [0 255], 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.

getImageHeight — Return number of rows

height = getImageHeight(imgmodel), where imgmodel is a valid image model and height is a double scalar, returns a double scalar containing the number of rows.

getImageType — Return image type

str = getImageType(imgmodel) returns the type of image associated with the imagemodel,imgmodel. The return value, str, is one of the following: 'intensity', 'truecolor', 'binary', or 'indexed'.

getImageWidth — Return number of columns

width = getImageWidth(imgmodel), where imgmodel is a valid image model and width is a double scalar, returns a double scalar containing the number of columns.

getMinIntensity — Return minimum value in image

minval = getMinIntensity(imgmodel), where imgmodel is a valid image model and minval is a numeric value, 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. The class of minval depends on the class of the target image.

getMaxIntensity — Return maximum value in image

maxval = getMaxIntensity(imgmodel), where imgmodel is a valid image model and maxval is a numeric value, 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. The class of maxval depends on the class of the target image.

getNumberFormatFcn — Return handle to function that converts numeric value into character vector

fun = getNumberFormatFcn(imgmodel) returns the handle to a function that converts a numeric value into a character vector, where imgmodel is a valid image model. For example, str = fun(getPixelValue(imgmodel, 100, 100)) converts the numeric return value of the getPixelValue method into a character vector.

getPixelInfoString — Return value of specific pixel as character vector

str = getPixelInfoString(imgmodel, row, column) returns a character vector containing the value of the pixel at the location specified by row and column, where str is a character array, imgmodel is a valid image model and row and column are numeric scalar values. For example, for an RGB image, the method returns a character vector such as '[66 35 60]'.

getPixelRegionFormatFcn — Return handle to function that formats value of pixel into character vector

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

str = fun(100,100)

getPixelValue — Return value of specific pixel as numeric array

val = getPixelValue(imgmodel, row, column), where imgmodel is a valid image model and row and column are numeric scalar values, returns the value of the pixel at the location specified by row and column as a numeric array. The class of val depends on the class of the target image.

getDefaultPixelInfoString — Return pixel information type as character vector

str = getDefaultPixelInfoString(imgmodel) returns a character vector indicating the pixel information type, where imgmodel is a valid image model. This character vector can be used in place of actual pixel information values. Depending on the image type, str can be the value 'Intensity','[R G B]','BW', or '<Index> [R G B]'.

getDefaultPixelRegionString — Return type of information displayed in Pixel Region tool

str = getDefaultPixelRegionString(imgmodel) returns a character vector indicating the type of information displayed in the Pixel Region tool for each image type, where imgmodel is a valid image model. This character vector can be used in place of actual pixel values. Depending on the image type, str can be '000','R:000 G:000 B:000]', '0', or '<000> R:0.00 G:0.00 B:0.00'.

getScreenPixelRGBValue — Return screen display value of specific pixel

val = getScreenPixelRGBValue(imgmodel, row, col) returns the screen display value of the pixel at the location specified by row and col as a double array. imgmodel is a valid image model, row and col are numeric scalar values, and val is an array of doubles, such as [0.2 0.5 0.3].

Examples

Create an image model.

h = imshow('peppers.png');
im = imagemodel(h);
figure,subplot(1,2,1)
h1 = imshow('hestain.png');
subplot(1,2,2)
h2 = imshow('coins.png');
im = imagemodel([h1 h2]);

See Also

Introduced before R2006a

Was this topic helpful?