anomalyMapOverlay
Description
fuses an overlay of the per-pixel anomaly scores in B
= anomalyMapOverlay(I
,map
)map
as a heatmap on
a grayscale or RGB background image, I
.
Note
This functionality requires the Computer Vision Toolbox™ Automated Visual Inspection Library. You can install the Computer Vision Toolbox Automated Visual Inspection Library from Add-On Explorer. For more information about installing add-ons, see Get and Manage Add-Ons.
specifies options using one or more name-value arguments. For example,
B
= anomalyMapOverlay(I
,map
,Name=Value
)anomalyMapOverlay(I,map,Blend="equal")
blends the score map and the
background image with equal weighting.
Examples
Display Anomaly Map Over Test Image
Load a pretrained FCDD anomaly detector. This detector has been trained to classify the digit 8 as normal and all other digits as anomalies.
load("digit8AnomalyDetector.mat");
Load test images and corresponding labels, then convert the test images to a formatted dlarray
with the format label "SSCB" for spatial-spatial-channel-batch. The data set consists of grayscale images of handwritten digits 0–9.
[Xtest,gtLabels] = digitTest4DArrayData;
Select a test image of the digit 9.
digitToTest = "9";
digitIdx = find(gtLabels==digitToTest,1);
imTest = Xtest(:,:,:,digitIdx);
Predict the per-pixel anomaly scores for the test image.
map = anomalyMap(detector,imTest);
Display the anomaly map over the test image.
overlay = anomalyMapOverlay(imTest,map); imagesc(overlay) axis image off
Input Arguments
I
— Background image
M-by-N-by-3 numeric array | M-by-N numeric matrix | M-by-N logical matrix
Background image, specified in one of these formats:
M-by-N-by-3 numeric array representing a truecolor image
M-by-N numeric matrix representing a grayscale image
M-by-N logical matrix representing a binary image
map
— Anomaly score map
M-by-N numeric matrix
Anomaly score map, specified as an M-by-N
numeric matrix. You can get an anomaly score map using the anomalyMap
function. Larger values indicate a greater chance that a pixel is an anomaly.
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: B = anomalyMapOverlay(I,map,Blend="equal")
blends the score
map and the background image with equal weighting.
MapRange
— Display range
two-element vector
Display range of the anomaly score map, map
. The default
value is [min(map(:)) max(map(:))]
.
Blend
— Weights to blend map with background image
"proportional"
(default) | "equal"
| numeric scalar
Weights to blend the map with background image I
, specified
as "proportional"
, "equal"
, or a numeric scalar
in the range [0, 1].
Value | Description |
---|---|
"proportional" | Overlay I and map using alpha
blending with per-pixel weights proportional to the corresponding values in
map . The heatmap is more opaque over regions of
interest, which have large anomaly scores. The heatmap is more transparent
over normal regions, which have small anomaly scores. |
"equal" | Overlay I and map using alpha
blending with equal weights for the map and background image. |
numeric scalar | Overlay I and map using alpha
blending with weight w for the map, where
w is the value of the Blend
argument. When w is 0 , the heatmap is
fully transparent and only the background image is visible. When you increase
the value of w, the heatmap becomes more opaque. |
For all values of Blend
, the weight of the heatmap has an
additional multiplicative scale factor, specified by BlendFactor
.
When you account for the additional scale factor, the weight of the heatmap is w*BlendFactor
and the weight of the background image is 1 – w*BlendFactor
.
BlendFactor
— Constant multiplicative scale factor
1
(default) | numeric scalar
Constant multiplicative factor to apply to the weights of the
Blend
argument, specified as a numeric scalar. Increasing the
value of BlendFactor
increases the brightness of the heatmap over
the image.
Example: BlendFactor=1.2
brightens the heatmap by increasing the
weighting by a factor of 1.2
.
Example: BlendFactor=0.6
darkens the heatmap by decreasing the
weighting by a factor of 0.6
.
Colormap
— Colormap
jet(256)
(default) | 256-by-3 numeric matrix
Colormap, specified as a 256-by-3 numeric matrix with values in the range [0, 1]. Each row is a three-element RGB triplet that specifies the red, green, and blue components of a single color of the colormap.
Data Types: single
| double
Output Arguments
B
— RGB image with heatmap overlay
M-by-N-by-3 numeric array
RGB image with heatmap overlay, returned as an M-by-N-by-3 numeric array.
Data Types: uint8
Version History
Introduced in R2022b
See Also
anomalyMap
| viewAnomalyDetectionResults
| fcddAnomalyDetector
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)