Main Content

measureChromaticAberration

Measure chromatic aberration at slanted edges

Description

esfrChart Object

Use an esfrChart object when you want to automatically detect the slanted edge regions of interest (ROIs) of an Enhanced or Extended version of the Imatest® eSFR test chart [1].

aberrationValues = measureChromaticAberration(chart) measures the chromatic aberration at all slanted edge ROIs of an Imatest Enhanced or Extended test chart.

example

aberrationValues = measureChromaticAberration(chart,Name=Value) specifies a subset of ROIs to measure by using name-value arguments.

Test Chart Image (since R2024a)

Use a test chart image for other types of test charts that are not supported by the esfrChart object. You must identify the positions of the slanted edge ROIs.

aberrationValues = measureChromaticAberration(im,roiPositions) measures the chromatic aberration at all slanted edge ROIs at positions roiPositions for test chart image im.

example

Examples

collapse all

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)

Figure eSFR test chart contains an axes object. The hidden axes object contains 61 objects of type image, text.

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         {332x4 table}        {332x4 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))

Figure eSFR test chart contains an axes object. The axes object with title ROI 3 with Aberration 1.7983, xlabel Pixel, ylabel Normalized Intensity contains 3 objects of type line.

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)

Figure contains an axes object. The axes object contains an object of type image.

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  

Figure contains an axes object. The axes object contains 5 objects of type image, images.roi.rectangle.

Calculate the chromatic aberration for the selected ROIs.

aberrationValues = measureChromaticAberration(I,roiPos)
aberrationValues=4×6 table
    ROI    aberration    percentAberration     edgeProfile     normalizedEdgeProfile          ROIPosition       
    ___    __________    _________________    _____________    _____________________    ________________________

     1      0.16281          0.080547         {316×4 table}        {316×4 table}        218     83    247     78
     2      0.30988           0.15219         {376×4 table}        {376×4 table}        512    171     93    240
     3      0.16296          0.082423         {316×4 table}        {316×4 table}        262    479    262     78
     4      0.19353          0.098824         {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))

Figure contains an axes object. The axes object with title ROI 3 with Aberration 0.16296, xlabel Pixel, ylabel Normalized Intensity contains 3 objects of type line.

Input Arguments

collapse all

eSFR chart, specified as an esfrChart 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

collapse all

Chromatic aberration measurements, returned as a table. The table has one row for each measured ROI. The table always has these variables (columns):

VariableDescription
ROIIndex 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. aberration is a scalar of type double.

percentAberrationAberration, 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. edgeProfile is an s-by-4 table, where s is the number of samples across the edge. The four columns represent the red, green, blue, and luminance values, averaged along the edge.

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. normalizedEdgeProfile is an s-by-4 table with a similar structure to edgeProfile.

When you specify a test chart image im, the table has an additional variable:

VariableDescription
ROIPositionsPosition 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

collapse all

Access Chromatic Aberration Measurements

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 aberration variable is measured in the horizontal or vertical direction. However, chromatic aberration is a radial phenomenon, and radial measurements are more accurate.

References

Version History

Introduced in R2017b

expand all