measureChromaticAberration
R2026bMeasure chromatic aberration at slanted edges
Syntax
Description
Test Chart Object
measures the chromatic aberration at all slanted edge ROIs of an Imatest® Enhanced or Extended test chart, or a simulated eSFR test
chart.aberrationValues = measureChromaticAberration(chart)
specifies a subset of ROIs to measure by using name-value arguments.aberrationValues = measureChromaticAberration(chart,Name=Value)
Test Chart Image
measures the chromatic aberration at all slanted edge ROIs at positions
aberrationValues = measureChromaticAberration(im,roiPositions)roiPositions for test chart image
im.
Examples
Read an image of an eSFR chart into the workspace.
I = imread("eSFRTestImage.jpg");Create an esfrChart object, then display the chart with ROI annotations. The 60 slanted edge ROIs are labeled with green numbers.
chart = esfrChart(I);
displayChart(chart,displayColorROIs=false,...
displayGrayROIs=false,displayRegistrationPoints=false)
Measure the chromatic aberration in all slanted edge ROIs. Examine the contents of the returned table, chTable, for a single ROI.
chTable = measureChromaticAberration(chart); ROIIndex = 3; chTable(3,:)
ans = 1×5 table
ROI aberration percentAberration edgeProfile normalizedEdgeProfile
___ __________ _________________ _____________ _____________________
3 1.7983 0.13956 {332×4 table} {332×4 table}
Store the normalized edge profile in a separate variable, edgeProfile, for clarity. Examine the normalized color intensity of the first and last pixel of edgeProfile.
edgeProfile = chTable.normalizedEdgeProfile{ROIIndex};
edgeProfile([1 end],:)ans = 2×4 table
normalizedEdgeProfile_R normalizedEdgeProfile_G normalizedEdgeProfile_B normalizedEdgeProfile_Y
_______________________ _______________________ _______________________ _______________________
0.003784 0.0026729 0.011565 0.0041317
0.98932 0.98978 1.0076 0.99009
Plot the normalized intensity for the ROI.
npix = length(edgeProfile.normalizedEdgeProfile_R); plot(1:npix,edgeProfile.normalizedEdgeProfile_R,"r", ... 1:npix,edgeProfile.normalizedEdgeProfile_G,"g", ... 1:npix,edgeProfile.normalizedEdgeProfile_B,"b") xlabel("Pixel") ylabel("Normalized Intensity") title("ROI "+ROIIndex+" with Aberration "+chTable.aberration(ROIIndex))

The blue channel has a higher intensity than the red and green channels immediately before the edge, and a lower intensity than the red and green channels immediately after the edge. This difference in intensity contributes to the measured value of chromatic aberration.
The measured values of aberration and percentAberration for this edge are relatively small. Visual inspection of the image confirms that the sides of the edge do not have a strong color tint.
Read and display an image of a custom test chart with slanted edge ROIs.
I = imread("slantedSquare.jpg");
imshow(I)
Draw ROIs for the edges, starting at the top and moving clockwise.
numROIs = 4; roiPos = zeros(numROIs,4); for cnt = 1:numROIs hrect = drawrectangle; roiPos(cnt,:) = hrect.Position; end

Calculate the chromatic aberration for the selected ROIs.
aberrationValues = measureChromaticAberration(I,roiPos)
aberrationValues = 4×6 table
1 0.1628 0.0805 316×4 table 316×4 table 218 83 247 78
2 0.3099 0.1522 376×4 table 376×4 table 512 171 93 240
3 0.1630 0.0824 316×4 table 316×4 table 262 479 262 78
4 0.1935 0.0988 388×4 table 388×4 table 114 207 96 256
Plot the normalized intensity of the red, green, and blue color channels for one of the ROIs.
ROIIndex = 3;
edgeProfile = aberrationValues.normalizedEdgeProfile{ROIIndex};
p = plot(edgeProfile, ...
["normalizedEdgeProfile_R" "normalizedEdgeProfile_G" "normalizedEdgeProfile_B"]);
p(1).Color = "r";
p(2).Color = "g";
p(3).Color = "b";
xlabel("Pixel")
ylabel("Normalized Intensity")
title("ROI "+ROIIndex+" with Aberration "+aberrationValues.aberration(ROIIndex))
Input Arguments
eSFR chart, specified as an esfrChart
or SimulatedESFRChart (since R2026b) object.
Since R2024a
Test chart image, specified as an RGB image.
Since R2024a
ROI positions, specified as an n-by-4 numeric array,
where n is the number of ROIs. Each ROI has the form
[X Y Width Height], where X and
Y are the coordinates of the top-left corner of the
ROI. Width and Height are the width
and height of the ROI, in pixels.
For horizontal edges, specify ROIs with a horizontal aspect ratio (a greater width than height). Likewise, for vertical edges, specify ROIs with a vertical aspect ratio (a greater height than width).
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: aberrationValues =
measureChromaticAberration(chart,ROIIndex=2) measures the chromatic
aberration only of ROI 2.
Before R2021a, use commas to separate each name and value, and enclose
Name in quotes.
Example: aberrationValues =
measureChromaticAberration(chart,"ROIIndex",2) measures the chromatic
aberration only of ROI 2.
ROI indices to include in measurements, specified as a numeric scalar
or numeric vector with values between 1 and the number of ROIs. By
default, measureChromaticAberration function
includes all ROI indices in the measurements.
Note
measureChromaticAberration uses the
intersection of ROIs specified by ROIIndex
and ROIOrientation.
You can specify this argument only when you use a chart object
chart.
Example: 29:32
Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32
ROI orientation, specified as "both",
"vertical", or "horizontal".
The measureChromaticAberration function performs
measurements only on ROIs with the specified orientation.
Note
measureChromaticAberration uses the
intersection of ROIs specified by ROIIndex
and ROIOrientation.
You can specify this argument only when you use a chart object
chart.
Data Types: char | string
Output Arguments
Chromatic aberration measurements, returned as a table. The table has one row for each measured ROI. The table always has these variables (columns):
| Variable | Description |
|---|---|
ROI | Index of the sampled ROI. The value of
ROI is an integer in the range
[1, 60]. |
aberration | Chromatic aberration, measured as the area
between the maximum and the minimum red, green, and
blue edge intensity profiles. The measured chromatic
aberration indicates perceptual chromatic
aberration. |
percentAberration | Aberration, expressed as a percentage of the distance in pixels between the center of the image and the center of the ROI. |
edgeProfile | Intensity profile of each color channel across
the edge in the ROI. Luminance (Y) is a linear combination of the red (R), green (G), and blue (B) channels according to: Y = 0.213R + 0.715G + 0.072B
Note The sampling rate for the chromatic aberration measurement is about four times the sampling rate of the image.
|
normalizedEdgeProfile | Intensity profile, normalized between [0, 1]
using 5% of the front end and tail end of data.
|
When you specify a test chart image im, the table has
an additional variable:
| Variable | Description |
|---|---|
ROIPositions | Position of the ROI, returned as a 4-element vector of
the form [X Y Width Height].
X and Y are the
coordinates of the top-left corner of the ROI.
Width and Height
are the width and height of the ROI, in pixels. |
More About
The order of the variables in the chromatic aberration table depends on whether
you input a test chart image, im, or a chart object,
chart. If you need to access variables of the chromatic
aberration table, refer to variable names and not numeric indices.
For example, to access the aberration variable of the chromatic
aberration table, use code such as this.
aberration = aberrationValues.aberration;
For another example, to access the measured chromatic aberration values of the ROI
with index 3, use code such as this. The first command returns the
normalizedEdgeProfile variable in a table for the ROI with
index 3. The second command converts the table into a numeric row vector.
edgeProfiles = aberrationValues.normalizedEdgeProfile{ROIIndex};
edgeProfilesRGB = measuredRGB3{1,:};For more information, see Access Data in Tables and Access Data in Cell Arrays.
Tips
Chromatic aberration is best measured at slanted edges that are:
Roughly orthogonal to the line connecting the center of the image and the center of the ROI
Farthest from the center of the image
Because chromatic aberration increases radially from the center of the image, you can ignore measurements at slanted edges near the center of the image.
The absolute chromatic aberration reported in the
aberrationvariable is measured in the horizontal or vertical direction. However, chromatic aberration is a radial phenomenon, and radial measurements are more accurate.
References
[1] Imatest. "Esfr". https://www.imatest.com/mathworks/esfr/.
Version History
Introduced in R2017bYou can now measure the chromatic aberration of slanted edges for simulated eSFR
test charts rendered through an optical system. Use the renderChart object function to render the test chart and create a
SimulatedESFRChart object. To measure the chromatic aberration,
specify the rendered test chart, chart.
This functionality requires Optical Design and Simulation Library for Image Processing Toolbox™. You can install the Optical Design and Simulation Library for Image Processing Toolbox from Add-On Explorer. For more information about installing add-ons, see Get and Manage Add-Ons.
You can now measure the chromatic aberration of slanted edges for test charts
other than the Imatest Enhanced or Extended eSFR test chart. To measure the sharpness of
additional types of test charts, specify the test chart image,
im, and the position of the slanted edge ROIs,
roiPositions.
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.
Website auswählen
Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .
Sie können auch eine Website aus der folgenden Liste auswählen:
So erhalten Sie die bestmögliche Leistung auf der Website
Wählen Sie für die bestmögliche Website-Leistung die Website für China (auf Chinesisch oder Englisch). Andere landesspezifische Websites von MathWorks sind für Besuche von Ihrem Standort aus nicht optimiert.
Amerika
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- 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)