当前位置:网站首页>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
边栏推荐
- Idea set the number of open file windows
- Check the debug port information in rancher and do idea remote JVM debug
- 全网最全的新型数据库、多维表格平台盘点 Notion、FlowUs、Airtable、SeaTable、维格表 Vika、飞书多维表格、黑帕云、织信 Informat、语雀
- COMSOL -- establishment of geometric model -- establishment of two-dimensional graphics
- Redis集群(主从)脑裂及解决方案
- POJ 3176 cow bowling (DP | memory search)
- Error modulenotfounderror: no module named 'cv2 aruco‘
- 石油化工企业安全生产智能化管控系统平台建设思考和建议
- 【ijkplayer】when i compile file “compile-ffmpeg.sh“ ,it show error “No such file or directory“.
- splunk配置163邮箱告警
猜你喜欢
Hiengine: comparable to the local cloud native memory database engine
Uniapp + unicloud + Unipay realize wechat applet payment function
多表操作-自关联查询
Mmclassification training custom data
互联网公司实习岗位选择与简易版职业发展规划
Wireless WiFi learning 8-channel transmitting remote control module
Thoughts and suggestions on the construction of intelligent management and control system platform for safe production in petrochemical enterprises
如何让你的产品越贵越好卖
【云原生 | Kubernetes篇】Ingress案例实战(十三)
Intern position selection and simplified career development planning in Internet companies
随机推荐
简单解决redis cluster中从节点读取不了数据(error) MOVED
Codeworks 5 questions per day (1700 average) - day 5
11.(地图数据篇)OSM数据如何下载使用
COMSOL -- establishment of geometric model -- establishment of two-dimensional graphics
pytorch-softmax回归
【pytorch 修改预训练模型:实测加载预训练模型与模型随机初始化差别不大】
redis 集群模式原理
How can China Africa diamond accessory stones be inlaid to be safe and beautiful?
投资理财适合女生吗?女生可以买哪些理财产品?
COMSOL -- 3D casual painting -- sweeping
liunx禁ping 详解traceroute的不同用法
ABAP table lookup program
How to get a token from tokenstream based on Lucene 3.5.0
Solve the grpc connection problem. Dial succeeds with transientfailure
报错ModuleNotFoundError: No module named ‘cv2.aruco‘
Implementation of array hash function in PHP
[mainstream nivida graphics card deep learning / reinforcement learning /ai computing power summary]
ACID事务理论
[pytorch modifies the pre training model: there is little difference between the measured loading pre training model and the random initialization of the model]
互联网公司实习岗位选择与简易版职业发展规划