当前位置:网站首页>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
边栏推荐
- Is investment and finance suitable for girls? What financial products can girls buy?
- redis集群中hash tag 使用
- The solution of outputting 64 bits from printf format%lld of cross platform (32bit and 64bit)
- [yolov3 loss function]
- Linux Installation and deployment lamp (apache+mysql+php)
- 【L1、L2、smooth L1三类损失函数】
- Use and install RkNN toolkit Lite2 on itop-3568 development board NPU
- Yolov5 target detection neural network -- calculation principle of loss function
- 报错ModuleNotFoundError: No module named ‘cv2.aruco‘
- 871. Minimum Number of Refueling Stops
猜你喜欢
Pytorch weight decay and dropout
自动化测试生命周期
多表操作-自关联查询
liunx禁ping 详解traceroute的不同用法
Wireless WiFi learning 8-channel transmitting remote control module
【云原生 | Kubernetes篇】Ingress案例实战(十三)
【TFLite, ONNX, CoreML, TensorRT Export】
Linux安装部署LAMP(Apache+MySQL+PHP)
Check the debug port information in rancher and do idea remote JVM debug
简单解决redis cluster中从节点读取不了数据(error) MOVED
随机推荐
XML parsing
如何让你的产品越贵越好卖
手机 CPU 架构类型了解
[configuration method of win11 multi-user simultaneous login remote desktop]
Pytorch linear regression
2022年国内云管平台厂商哪家好?为什么?
[yolov3 loss function]
全网最全的新型数据库、多维表格平台盘点 Notion、FlowUs、Airtable、SeaTable、维格表 Vika、飞书多维表格、黑帕云、织信 Informat、语雀
【上采样方式-OpenCV插值】
报错ModuleNotFoundError: No module named ‘cv2.aruco‘
12.(地图数据篇)cesium城市建筑物贴图
Project summary notes series wstax kt session2 code analysis
调查显示传统数据安全工具在60%情况下无法抵御勒索软件攻击
pytorch-softmax回归
redis集群中hash tag 使用
Prevent browser backward operation
1个插件搞定网页中的广告
Open3d mesh (surface) coloring
Intern position selection and simplified career development planning in Internet companies
Acid transaction theory