当前位置:网站首页>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
边栏推荐
- redis 集群模式原理
- Linux Installation and deployment lamp (apache+mysql+php)
- Halcon template matching actual code (I)
- [yolov3 loss function]
- Pytorch linear regression
- redis主从中的Master自动选举之Sentinel哨兵机制
- [configuration method of win11 multi-user simultaneous login remote desktop]
- 【 YOLOv3中Loss部分计算】
- How to get a token from tokenstream based on Lucene 3.5.0
- 多表操作-子查询
猜你喜欢
![[cloud native | kubernetes] actual battle of ingress case (13)](/img/1a/9404f6dcedd15827fa45f8f6f4c093.png)
[cloud native | kubernetes] actual battle of ingress case (13)

11. (map data section) how to download and use OSM data
![[pytorch pre training model modification, addition and deletion of specific layers]](/img/cb/aa0b1116ec9b98e3ee5725aa58f4fe.png)
[pytorch pre training model modification, addition and deletion of specific layers]

多表操作-子查询

11.(地图数据篇)OSM数据如何下载使用

Redirection of redis cluster

Yolov 5 Target Detection Neural Network - Loss Function Calculation Principle

Simply solve the problem that the node in the redis cluster cannot read data (error) moved

Idea set the number of open file windows

How to make your products as expensive as possible
随机推荐
XML parsing
Hiengine: comparable to the local cloud native memory database engine
[cloud native | kubernetes] actual battle of ingress case (13)
redis主从中的Master自动选举之Sentinel哨兵机制
Redis集群的重定向
redis主从模式
《增长黑客》阅读笔记
网络五连鞭
Web API configuration custom route
Empêcher le navigateur de reculer
Video networkState 属性
【主流Nivida显卡深度学习/强化学习/AI算力汇总】
pytorch-softmax回归
无线WIFI学习型8路发射遥控模块
Proof of the thinking of Hanoi Tower problem
【云原生 | Kubernetes篇】Ingress案例实战(十三)
查看多台机器所有进程
JS for循环 循环次数异常
[upsampling method opencv interpolation]
[untitled]