Documentation Center

  • Trial Software
  • Product Updates

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. 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'.

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

str = getClassType(imgmodel) returns a string indicating the class of the image, where imgmodel is a valid image model and str is a text string, such as 'uint8'.

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), where imgmodel is a valid image model and str is one of the text strings ('intensity', 'truecolor', 'binary', or 'indexed'), returns a text string indicating the image type.

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 string

fun = getNumberFormatFcn(imgmodel), where imgmodel is a valid image model, returns the handle to a function that converts a numeric value into a string.

For example, str = fun(getPixelValue(imgmodel, 100, 100)) converts the numeric return value of the getPixelValue method into a text string.

getPixelInfoString — Return value of specific pixel as text string

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

getPixelRegionFormatFcn — Return handle to function that formats value of pixel into text string

fun = getPixelRegionFormatFcn(imgmodel), takes a valid image model, imgmodel, and returns fun, 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 — 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 text string

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

getDefaultPixelRegionString — Return type of information displayed in Pixel Region tool

str = getDefaultPixelRegionString(imgmodel), where imgmodel is a valid image model, 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. 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 — 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

Was this topic helpful?