当前位置:网站首页>Use of OpenCV 11 kmeans clustering
Use of OpenCV 11 kmeans clustering
2022-06-13 02:29:00 【An unforgettable squirrel】
Program running logic
Before clustering , use first
Blur(src, src, new Size(15, 15));
The mean filter is applied to the graph
For clustering , The following steps are carried out
1、var columnVector = src.Reshape(cn: 3, rows: src.Rows * src.Cols);
Turn the graph into 3 Single column matrix of channels
2、columnVector.ConvertTo(samples, MatType.CV_32FC3);
Convert a matrix to a floating point matrix
3、 call kmean function , And look at the different parameters k:2,4,5,8 The effect of
Cv2.Kmeans(
data: samples,
k: clustersCount,
bestLabels: bestLabels,
criteria:
new TermCriteria(type: CriteriaType.Eps | CriteriaType.MaxIter, maxCount: 10, epsilon: 1.0),
attempts: 3,
flags: KMeansFlags.PpCenters,
centers: centers);
4、 Read generation matrix bestLabel, And rewrite the matrix of the same type as the original drawing
var clusteredImage = new Mat(src.Rows, src.Cols, src.Type());
for (var size = 0; size < src.Cols * src.Rows; size++)
{
var clusterIndex = bestLabels.At<int>(0, size);
var newPixel = new Vec3b
{
Item0 = (byte)(centers.At<float>(clusterIndex, 0)), // B
Item1 = (byte)(centers.At<float>(clusterIndex, 1)), // G
Item2 = (byte)(centers.At<float>(clusterIndex, 2)) // R
};
clusteredImage.Set(size / src.Cols, size % src.Cols, newPixel);
}5、 graphic display .
边栏推荐
- Configuring virtual private network FRR for Huawei equipment
- A real-time target detection model Yolo
- Huawei equipment is configured with dual reflectors to optimize the backbone layer of the virtual private network
- Several articles on norms
- 04路由跳转并携带参数
- 在IDEA使用C3P0连接池连接SQL数据库后却不能显示数据库内容
- Solution of depth learning for 3D anisotropic images
- [learning notes] xr872 GUI littlevgl 8.0 migration (file system)
- Area of basic exercise circle ※
- CCF 201409-1: adjacent number pairs (100 points + problem solving ideas)
猜你喜欢

Understand speech denoising
![[reading point paper] deeplobv3+ encoder decoder with Atlas separable revolution](/img/24/decef903cd618bf7bb7fea635ee62e.jpg)
[reading point paper] deeplobv3+ encoder decoder with Atlas separable revolution

Paper reading - jukebox: a generic model for music

Superficial understanding of conditional random fields

Fast Color Segementation

Introduction to arm Cortex-M learning

Armv8-m learning notes - getting started

Barrykay electronics rushes to the scientific innovation board: it is planned to raise 360million yuan. Mr. and Mrs. Wang Binhua are the major shareholders

Gadgets: color based video and image cutting

(novice to) detailed tutorial on machine / in-depth learning with colab from scratch
随机推荐
Jump model between mirrors
About the fact that I gave up the course of "Guyue private room course ROS manipulator development from introduction to actual combat" halfway
04路由跳转并携带参数
Open source video recolor code
Cumulative tax law: calculate how much tax you have paid in a year
哈夫曼树及其应用
Impossible d'afficher le contenu de la base de données après que l'idée a utilisé le pool de connexion c3p0 pour se connecter à la base de données SQL
Understanding and thinking about multi-core consistency
Leetcode 93 recovery IP address
4.11 introduction to firmware image package
How to do Internet for small enterprises
05 tabBar导航栏功能
[reading papers] visual convolution zfnet
What are the differences in cache/tlb?
Leetcode 473. Match to square [violence + pruning]
[pytorch] kaggle image classification competition arcface + bounding box code learning
Laptop touch pad operation
05 tabbar navigation bar function
Stm32f4 DMA Da sine wave generator keil5 Hal library cubemx
Basic principle of bilateral filtering