当前位置:网站首页>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 .
边栏推荐
- Several articles on norms
- Record: how to solve the problem of "the system cannot find the specified path" in the picture message uploaded by transferto() of multipartfile class [valid through personal test]
- 03 recognize the first view component
- [Dest0g3 520迎新赛] 拿到WP还整了很久的Dest0g3_heap
- Build MySQL environment under mac
- Queuing theory, game theory, analytic hierarchy process
- Common web page status return code crawler
- Share three stories about CMDB
- ROS learning-7 error in custom message or service reference header file
- Thesis reading - autovc: zero shot voice style transfer with only autoencoder loss
猜你喜欢
![Leetcode 926. Flip string to monotonically increasing [prefix and]](/img/ca/d23c1927bc32393cf023c748e4b449.png)
Leetcode 926. Flip string to monotonically increasing [prefix and]

Basic principle of bilateral filtering

How can intelligent safe power distribution devices reduce the occurrence of electrical fire accidents?
![[pytorch] kaggle large image dataset data analysis + visualization](/img/b0/7b8aff44d6bedd7ca2c705f13a8556.jpg)
[pytorch] kaggle large image dataset data analysis + visualization

4.11 introduction to firmware image package

Thesis reading - autovc: zero shot voice style transfer with only autoencoder loss

Deep learning the principle of armv8/armv9 cache

Understand speech denoising

拍拍贷母公司信也季报图解:营收24亿 净利5.3亿同比降10%
![[51nod.3210] binary Statistics (bit operation)](/img/37/aa4a549deebf994b0049d41d49ff12.jpg)
[51nod.3210] binary Statistics (bit operation)
随机推荐
Image table solid line and dashed line detection
The execution results of i+=2 and i++ i++ under synchronized are different
Linear, integer, nonlinear, dynamic programming
[Dest0g3 520迎新赛] 拿到WP还整了很久的Dest0g3_heap
ROS learning -5 how function packs with the same name work (workspace coverage)
[reading papers] comparison of deeplobv1-v3 series, brief review
[reading papers] deepface: closing the gap to human level performance in face verification. Deep learning starts with the face
js-dom
Gadgets: color based video and image cutting
Laptop touch pad operation
Mean Value Coordinates
Bluetooth module: use problem collection
Priority queue with dynamically changing priority
An image is word 16x16 words: transformers for image recognition at scale
redis
[reading point paper] deeplobv3+ encoder decoder with Atlas separable revolution
[reading point paper] deeplobv3 rethinking atlas revolution for semantic image segmentation ASPP
[reading papers] visual convolution zfnet
The precision of C language printf output floating point numbers
Leetcode 93 recovery IP address