raw2rgb
Description
Examples
Convert CFA Image to RGB
Convert the color filter array (CFA) image in the file into a 16-bit RGB image in the sRGB colorspace.
rgb = raw2rgb("colorCheckerTestImage.NEF");
imshow(rgb)
Convert the CFA image into a 8-bit RGB image in the Adobe RGB 1998 colorspace.
rgb = raw2rgb("colorCheckerTestImage.NEF",BitsPerSample=8,ColorSpace="adobe-rgb-1998"); imshow(rgb)
Convert the CFA image into a 16-bit image, in the camera's native colorspace, white-balanced against a D65 illuminant.
rgb = raw2rgb("colorCheckerTestImage.NEF",ColorSpace="camera", ... WhiteBalanceMultipliers="D65"); imshow(rgb)
Input Arguments
filename
— Name of RAW file
string scalar | character vector
Name of RAW file, specified as a string scalar or character vector. Specify
filename
as a full path, containing the file name and extension,
or as a relative path from the current folder or from any folder on the MATLAB® path.
The raw2rgb
function does not support RAW file formats that
employ JPEG compression.
Data Types: char
| string
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Example: rgb =
raw2rgb("colorCheckerTestImage.NEF",BitsPerSample=8,ColorSpace="adobe-rgb-1998");
Before R2021a, use commas to separate each name and value, and enclose
Name
in quotes.
Example: rgb =
raw2rgb("colorCheckerTestImage.NEF","BitsPerSample",8,"ColorSpace","adobe-rgb-1998");
ApplyContrastStretch
— Apply contrast stretching when rendering RGB image
false
or 0
(default) | true
or 1
Apply contrast stretching when rendering the RGB image, specified as a numeric or
logical 0
(false
) or 1
(true
)
BitsPerSample
— Bits per sample of output RGB image
16
(default) | 8
Bits per sample of the output RGB image, specified as 8
or
16
.
ColorSpace
— Color space of output RGB values
"srgb"
(default) | "camera"
| "adobe-rgb-1998"
Color space of the output RGB values, specified as "srgb"
,
"camera"
, or "adobe-rgb-1998"
. For more
information about the "srgb"
and
"adobe-rgb-1998"
color spaces, see Understanding Color Spaces and Color Space Conversion.
The "camera"
color space is native to the device.
Data Types: char
| string
WhiteBalanceMultipliers
— White balance adjustment for rendering
"AsTaken"
(default) | "D65"
| "ComputeFromImage"
| 1-by-N numeric vector
White balance adjustment for rendering the RGB image, specified as one of the
strings in this list, or as a 1-by-N vector of data type
double
.
Value | Description |
---|---|
"AsTaken" | White balance multipliers used by the camera to capture the image |
"D65" | White balance multipliers required to balance image using the D65 illuminant |
"ComputeFromImage" | White balance multipliers determined by analyzing the CFA image |
1-by-N vector | Custom white balance multipliers specified as a 1-by-N
vector of data type single or double .
For Bayer sensor images, N must be 4 and the order of the
coefficients should match the CFALayout field reported by
rawinfo . For non-Bayer sensors, N should
match the SamplesPerPixel field reported by
rawinfo . |
Data Types: double
| char
| string
Output Arguments
rgbImage
— RGB image
numeric array
RGB image, returned as an M-by-N-by-3 numeric
array. The values of M and N correspond to the
first and second elements of the RenderedImageSize
field reported by
rawinfo
,
respectively.
rgbImage
can be either uint8
or
uint16
, depending on the value of the
BitsPerSample
name-value argument.
Extended Capabilities
Thread-Based Environment
Run code in the background using MATLAB® backgroundPool
or accelerate code with Parallel Computing Toolbox™ ThreadPool
.
This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
Version History
Introduced in R2021aR2024a: LibRaw version updated to 0.21.1
The function now uses LibRaw version 0.21.1 for reading the CFA image data.
R2022b: Support for thread-based environments
raw2rgb
now supports thread-based
environments.
R2021b: LibRaw version updated to 0.20.2
The function now uses LibRaw version 0.20.2 for reading the CFA image data. Before, the function used LibRaw version 0.20.0.
See Also
raw2planar
| rawread
| rawinfo
| planar2raw
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)