当前位置:网站首页>Matlab imoverlay function (burn binary mask into two-dimensional image)

Matlab imoverlay function (burn binary mask into two-dimensional image)

2022-07-05 11:58:00 **inevitable**

grammar

B = imoverlay(A,BW)
B = imoverlay(A,BW,color)

explain

B = imoverlay(A,BW)
% Fill grayscale with solid color or RGB Images A, Where the binary mask is input BW by true.
B = imoverlay(A,BW,color)
% Appoint imoverlay The color used to fill the image .

Example

Burn binary images into grayscale images

% Read the grayscale image into the work area 
A = imread('cameraman.tif');
figure(1)
imshow(A)

 Insert picture description here

% Read binary image into work 
BW = imread('text.png');
figure(2)
imshow(BW)

 Insert picture description here

% Burn binary images into grayscale images , Specifies the color used for the binary mask .
B = imoverlay(A,BW,'yellow');

% Show results 
figure(3)
imshow(B)

 Insert picture description here

Burn binary images to RGB Images

% take RGB Image read into workspace 
RGB = imread('peppers.png');
figure(1)
imshow(RGB)

 Insert picture description here

% Read binary images into the workspace 
BW = imread('text.png');
figure(2)
imshow(BW)

 Insert picture description here

% tailoring RGB Images , Make it the same size as the binary mask 
RGB_cropped = imcrop(RGB,[64,128,255,255]);

% Burn binary images as cropped RGB Images , Choose the color you want to use 
B = imoverlay(RGB_cropped,BW,'red');

% Show results 
figure(3)
imshow(B)

 Insert picture description here
Cutting effect :
 Insert picture description here

Input parameters

A : Input image
The input image , Specify as a two-dimensional grayscale image or two-dimensional RGB Images
data type :single | double | int16 | uint8 | uint16 | logical

BW: Mask image
Mask image , Specified two-dimensional binary matrix , Its size and image A The first two dimensions of are the same . For digital input , Any non-zero pixel is considered 1( really ).
data type : single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | logical

color: Color used for overlay
Color used for overlay , Designated as MATLAB Color specification . for example , If you want to specify red , You can use any of the following specifications :“ Red ”,“ r” or [1 0 0].

Output parameters

B: Output image
Output image , In two dimensions RGB Return in image form .
data type :uint8

原网站

版权声明
本文为[**inevitable**]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140533367479.html