当前位置:网站首页>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
边栏推荐
- 13. (map data) conversion between Baidu coordinate (bd09), national survey of China coordinate (Mars coordinate, gcj02), and WGS84 coordinate system
- 《增长黑客》阅读笔记
- 1.php的laravel创建项目
- abap查表程序
- 程序员内卷和保持行业竞争力
- [pytorch modifies the pre training model: there is little difference between the measured loading pre training model and the random initialization of the model]
- [calculation of loss in yolov3]
- Halcon 模板匹配实战代码(一)
- How to protect user privacy without password authentication?
- Is investment and finance suitable for girls? What financial products can girls buy?
猜你喜欢
Network five whip
Thoughts and suggestions on the construction of intelligent management and control system platform for safe production in petrochemical enterprises
【PyTorch预训练模型修改、增删特定层】
Error modulenotfounderror: no module named 'cv2 aruco‘
多表操作-子查询
13. (map data) conversion between Baidu coordinate (bd09), national survey of China coordinate (Mars coordinate, gcj02), and WGS84 coordinate system
【主流Nivida显卡深度学习/强化学习/AI算力汇总】
Sentinel sentinel mechanism of master automatic election in redis master-slave
[crawler] bugs encountered by wasm
Redis集群的重定向
随机推荐
Simply solve the problem that the node in the redis cluster cannot read data (error) moved
Yolov 5 Target Detection Neural Network - Loss Function Calculation Principle
Project summary notes series wstax kt session2 code analysis
SET XACT_ ABORT ON
[cloud native | kubernetes] actual battle of ingress case (13)
POJ 3176 cow bowling (DP | memory search)
《看完就懂系列》15个方法教你玩转字符串
全网最全的新型数据库、多维表格平台盘点 Notion、FlowUs、Airtable、SeaTable、维格表 Vika、飞书多维表格、黑帕云、织信 Informat、语雀
Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in
mmclassification 训练自定义数据
中非 钻石副石怎么镶嵌,才能既安全又好看?
Principle of redis cluster mode
Codeforces Round #804 (Div. 2)
Codeforces Round #804 (Div. 2)
[upsampling method opencv interpolation]
Linux安装部署LAMP(Apache+MySQL+PHP)
pytorch-权重衰退(weight decay)和丢弃法(dropout)
11.(地图数据篇)OSM数据如何下载使用
C # implements WinForm DataGridView control to support overlay data binding
Multi table operation - sub query