raw2rgb
Transform Color Filter Array (CFA) image in RAW file into RGB image
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
character vector |
string
scalar
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.
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.
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 the RGB image
false
or 0
(default) | true
or 1
Apply contrast stretching when rendering the RGB image, specified as a logical 0
(false
) or 1 (true
).
Data Types: logical
BitsPerSample
— Bits per sample of output RGB image
16
(default) | 8
Bits per sample of the output RGB image, specified as the numeric scalar
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 class
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 class 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 pair.
Limitations
The
raw2rgb
function does not support RAW file formats that employ JPEG compression.
Tips
The function uses LibRaw version 0.20.2 for reading the CFA image data.
Version History
See Also
raw2planar
| rawread
| rawinfo
| planar2raw
Beispiel öffnen
Sie haben eine geänderte Version dieses Beispiels. Möchten Sie dieses Beispiel mit Ihren Änderungen öffnen?
MATLAB-Befehl
Sie haben auf einen Link geklickt, der diesem MATLAB-Befehl entspricht:
Führen Sie den Befehl durch Eingabe in das MATLAB-Befehlsfenster aus. Webbrowser unterstützen keine MATLAB-Befehle.
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)