当前位置:网站首页>Matlab superpixels function (2D super pixel over segmentation of image)
Matlab superpixels function (2D super pixel over segmentation of image)
2022-07-05 11:58:00 【**inevitable**】
List of articles
grammar
[L,NumLabels] = superpixels(A,N)
[L,NumLabels] = superpixels(A,N,Name,Value)
explain
[L,NumLabels] = superpixels(A,N)
% Calculate two-dimensional grayscale or RGB Images A Super pixels ( Expected number of super pixels ).
%N Specify the number of super pixels to create .
% This function returns L(double Label matrix of type ) and NumLabels( The actual number of hyperpixels calculated ).
[L,NumLabels] = superpixels(A,N,Name,Value)
% Use the name used to control various aspects of segmentation - Value pair group parameter calculation image A Super pixels .
superpixels The function uses simple linear iterative clustering (SLIC) Algorithm . This algorithm divides pixels into regions with similar values . In image processing operations ( Such as segmentation ) Using these regions in can reduce the complexity of these operations .
Example
Calculate input RGB Super pixel of image
% Read the image into the workspace
A = imread('kobi.png');
% Calculate the super pixels of the image
[L,N] = superpixels(A,500);
% Superimpose and display the boundary of super pixels on the original image
figure(1)
BW = boundarymask(L);
imshow(imoverlay(A,BW,'cyan'),'InitialMagnification',67)
% Set the color of each pixel in the output image to RGB Mean color
outputImage = zeros(size(A),'like',A);
idx = label2idx(L);
numRows = size(A,1);
numCols = size(A,2);
for labelVal = 1:N
redIdx = idx{labelVal};
greenIdx = idx{labelVal}+numRows*numCols;
blueIdx = idx{labelVal}+2*numRows*numCols;
outputImage(redIdx) = mean(A(redIdx));
outputImage(greenIdx) = mean(A(greenIdx));
outputImage(blueIdx) = mean(A(blueIdx));
end
figure(2)
imshow(outputImage,'InitialMagnification',67)
Input parameters
A : The image to be segmented
The image to be segmented , Specify as a two-dimensional grayscale image or a two-dimensional true color image . about int16 data ,A Must be a grayscale image . When parameters isInputLab yes true when , The input image must be of data type single or double.
A Data type of :single | double | int16 | uint8 | uint16
N: Expected number of super pixels
The number of super pixels required , Specify as a positive integer .
N Data type of : single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64
name - Value pair group parameter
Specify optional 、 Separated by commas Name,Value For group parameters .Name For parameter name ,Value Is the corresponding value .Name Must be in quotation marks . You can specify multiple names in any order - Value pair group parameter , Such as Name1,Value1,…,NameN,ValueN.
such as :
B = superpixels(A,100,'NumIterations', 20);
% The image A Divided into 100 Two super pixels , The number of iterations is 20 Time
common name Parameters :
(1)‘Compactness’
Super pixel shape , Specify as numeric scalar .SLIC The compactness parameter of the algorithm controls the shape of super pixels . The higher the value , The more regular the shape of super pixels , That is, the closer to the square . The lower the value , Super pixels will better fit the boundary , Make its shape irregular . The allowable range is (0 Inf). The value of compactness is usually [1,20] Within the scope of . The default value is 10.
Compactness Corresponding value (value) Data type of : single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64
(2)‘IsInputLab’
Input image data in Lab* Color space , Designated as true or false. The default is false.
'IsInputLab’ Corresponding value (value) Data type of : single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical
(3)‘Method’
Algorithm for calculating super pixels , Specify one of the following values .superpixels The function uses simple linear iterative clustering (SLIC) Two variants of the algorithm .
value | significance |
---|---|
‘slic0’ | superpixels Use after the first iteration SLIC0 The algorithm is optimized in an adaptive way ‘Compactness’. This is the default setting . |
‘slic’ | ‘Compactness’ Remain unchanged in the clustering process . |
'Method’ Corresponding value (value) Data type of : char | string
(4)‘NumIterations’
The algorithm is used in the clustering stage The number of iterations , Specify as a positive integer ( The default is 10). For most problems , There is no need to adjust this parameter .
'NumIterations’ Corresponding value (value) Data type of :single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64
Output parameters
L: Label matrix , Returns as an array of positive integers . value 1 Represents the first super-pixel region in the image ,2 Indicates the second area , And so on .
data type : double
NumLabels: Calculated The number of superpixels , Returns as a positive integer .
data type : double
边栏推荐
- Yolov5 target detection neural network -- calculation principle of loss function
- splunk配置163邮箱告警
- Network five whip
- HiEngine:可媲美本地的云原生内存数据库引擎
- [leetcode] wild card matching
- Uniapp + unicloud + Unipay realize wechat applet payment function
- 【pytorch 修改预训练模型:实测加载预训练模型与模型随机初始化差别不大】
- Proof of the thinking of Hanoi Tower problem
- COMSOL -- 3D casual painting -- sweeping
- 【L1、L2、smooth L1三类损失函数】
猜你喜欢
[yolov3 loss function]
yolov5目標檢測神經網絡——損失函數計算原理
[cloud native | kubernetes] actual battle of ingress case (13)
【SingleShotMultiBoxDetector(SSD,单步多框目标检测)】
Uniapp + unicloud + Unipay realize wechat applet payment function
HiEngine:可媲美本地的云原生内存数据库引擎
Pytorch MLP
[calculation of loss in yolov3]
Sentinel sentinel mechanism of master automatic election in redis master-slave
XML parsing
随机推荐
ABAP table lookup program
中非 钻石副石怎么镶嵌,才能既安全又好看?
汉诺塔问题思路的证明
[yolov5.yaml parsing]
Redis集群的重定向
网络五连鞭
Project summary notes series wstax kt session2 code analysis
Programmers are involved and maintain industry competitiveness
pytorch-权重衰退(weight decay)和丢弃法(dropout)
【 YOLOv3中Loss部分计算】
Reading notes of growth hacker
查看多台机器所有进程
yolov5目標檢測神經網絡——損失函數計算原理
互联网公司实习岗位选择与简易版职业发展规划
The most comprehensive new database in the whole network, multidimensional table platform inventory note, flowus, airtable, seatable, Vig table Vika, flying Book Multidimensional table, heipayun, Zhix
redis的持久化机制原理
Solve readobjectstart: expect {or N, but found n, error found in 1 byte of
Halcon 模板匹配实战代码(一)
Wireless WiFi learning 8-channel transmitting remote control module
Codeforces Round #804 (Div. 2)