getDefaultPixelInfoString
Get default pixel value as character vector
Description
returns a default pixel value character vector matching the information displayed in the
Pixel Information tool, based on the type of image in
pixval = getDefaultPixelInfoString(imgmodel)imgmodel. This character vector can be used in place of actual pixel
information values.
Examples
Pixel values obtained from an imagemodel object can be returned in several formats suitable for display in different interactive image processing tools.
Create an image model associated with a color image.
h = imshow('flamingos.jpg');![]()
im = imagemodel(h)
im =
IMAGEMODEL object accessing an image with these properties:
ClassType: 'uint8'
DisplayRange: []
ImageHeight: 972
ImageType: 'truecolor'
ImageWidth: 1296
MinIntensity: []
MaxIntensity: []
Select a pixel by specifying row and column coordinates. This pixel has (row, column) coordinates (100, 200).
r = 100; c = 200;
Get the numeric value of the pixel using the getPixelValue function.
pxValue = getPixelValue(im,r,c)
pxValue = 1×3 uint8 row vector
104 95 54
Get the default pixel information string using the getDefaultPixelInfoString function. This string depends on the type of image but does not use the pixel values. The pixel information string is suitable for use with the Pixel Information tool.
defaultPxInfoStr = getDefaultPixelInfoString(im)
defaultPxInfoStr = '[R G B]'
Using the same string format, get the pixel information string for the specified pixel by using the getPixelInfoString function.
pxInfoStr = getPixelInfoString(im,r,c)
pxInfoStr = '[104 95 54]'
Get the default pixel region string using the getDefaultPixelRegionString function. This string depends on the type of image but does not use the pixel values. The pixel region string is suitable for use with the Pixel Region tool.
defaultPxRegStr = getDefaultPixelRegionString(im)
defaultPxRegStr =
'R:000
G:000
B:000'
There are two steps to get the pixel region string for the specified pixel in the same string format. First, get a function formatFcn that formats numeric pixel values by using the getPixelRegionFormatFcn function. Then, specify the row and column coordinate of the pixel as input arguments to formatFcn to get the formatted string.
formatFcn = getPixelRegionFormatFcn(im); pxRegStr = formatFcn(r,c)
pxRegStr = 1×1 cell array
{'R:104↵G: 95↵B: 54'}
Pixel values obtained from an imagemodel object can be returned in several formats suitable for display in different interactive image processing tools.
Create an image model associated with a grayscale image.
h = imshow('liftingbody.png');![]()
im = imagemodel(h)
im =
IMAGEMODEL object accessing an image with these properties:
ClassType: 'uint8'
DisplayRange: [0 255]
ImageHeight: 512
ImageType: 'intensity'
ImageWidth: 512
MinIntensity: 0
MaxIntensity: 255
Select a pixel by specifying the row and column coordinates. This pixel has (row, column) coordinates (50, 250).
r = 50; c = 250;
Get the numeric value of the pixel using the getPixelValue function.
pxValue = getPixelValue(im,r,c)
pxValue = uint8
151
Convert the numeric pixel value to a string. First, get a function formatFcn that formats numeric pixel values by using the getNumberFormatFcn. Then, specify the numeric value of the pixel as the input argument to formatFcn to get the formatted string.
formatFcn = getNumberFormatFcn(im); pxValueStr = formatFcn(pxValue)
pxValueStr = '151'
Get the default pixel information string using the getDefaultPixelInfoString function. This string depends on the type of image but does not use the pixel values. The pixel information string is suitable for use with the Pixel Information tool.
defaultPxInfoStr = getDefaultPixelInfoString(im)
defaultPxInfoStr = 'Intensity'
Using the same string format, get the pixel information string for the specified pixel by using the getPixelInfoString function.
pxInfoStr = getPixelInfoString(im,r,c)
pxInfoStr = '151'
Get the default pixel region string using the getDefaultPixelRegionString function. This string depends on the type of image but does not use the pixel values. The pixel region string is suitable for use with the Pixel Region tool.
defaultPxRegStr = getDefaultPixelRegionString(im)
defaultPxRegStr = '000'
There are two steps to get the pixel region string for the specified pixel in the same string format. First, get a function formatFcn that formats numeric pixel values by using the getPixelRegionFormatFcn function. Then, specify the row and column coordinate of the pixel as input arguments to formatFcn to get the formatted string.
formatFcn = getPixelRegionFormatFcn(im); pxRegStr = formatFcn(r,c)
pxRegStr = 1×1 cell array
{'151'}
Input Arguments
Image model, specified as a scalar imagemodel object.
Output Arguments
Default pixel value, returned as one of the following.
| Image Type | Default Pixel Value |
|---|---|
| Grayscale | 'Intensity' |
| Truecolor (RGB) | '[R G B]' |
| Binary | 'BW' |
| Indexed | '<Index> [R G B]' |
Data Types: char
Version History
Introduced before R2006a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)