资源简介
超像素图像分割是对图像进行分析和理解的关键步骤,在图像处理领域具有重要的研究和应用价值。本题目需要实现一种基于SLIC超像素图像分割的算法。首先利用SLIC对图像进行超像素分割处理,把原图像分割成大小相似、形状规则的超像素,以超像素中心点的五维特征值作为原始数据点进行聚类,确定多体素数目和分割边界。SLIC具有以下优势:1)生成的超像素如同细胞一般紧凑整齐,邻域特征比较容易表达;2)不仅可以分割彩色图,也可以兼容分割灰度图;3)需要设置的参数非常少,默认情况下只需要设置一个预分割的超像素的数量。相比其他的超像素分割方法,SLIC在运行速度、生成超像素的紧凑度、轮廓保持方面都比较理想。

代码片段和文件信息
#include “slic.h“
/*
* Constructor. Nothing is done here.
*/
Slic::Slic() {
}
/*
* Destructor. Clear any present data.
*/
Slic::~Slic() {
clear_data();
}
/*
* Clear the data as saved by the algorithm.
*
* Input : -
* Output: -
*/
void Slic::clear_data() {
clusters.clear();
distances.clear();
centers.clear();
center_counts.clear();
}
/*
* Initialize the cluster centers and initial values of the pixel-wise cluster
* assignment and distance values.
*
* Input : The image (IplImage*).
* Output: -
*/
void Slic::init_data(IplImage *image) {
/* Initialize the cluster and distance matrices. */
for (int i = 0; i < image->width; i++) {
vector cr;
vector dr;
for (int j = 0; j < image->height; j++) {
cr.push_back(-1);
dr.push_back(FLT_MAX);
}
clusters.push_back(cr);
distances.push_back(dr);
}
/* Initialize the centers and counters. */
for (int i = step; i < image->width - step/2; i += step) {
for (int j = step; j < image->height - step/2; j += step) {
vector center;
/* Find the local minimum (gradient-wise). */
CvPoint nc = find_local_minimum(image cvPoint(ij));
CvScalar colour = cvGet2D(image nc.y nc.x);
/* Generate the center vector. */
center.push_back(colour.val[0]);
center.push_back(colour.val[1]);
center.push_back(colour.val[2]);
center.push_back(nc.x);
center.push_back(nc.y);
/* Append to vector of centers. */
centers.push_back(center);
center_counts.push_back(0);
}
}
}
/*
* Compute the distance between a cluster center and an individual pixel.
*
* Input : The cluster index (int) the pixel (CvPoint) and the Lab values of
* the pixel (CvScalar).
* Output: The distance (double).
*/
double Slic::compute_dist(int ci CvPoint pixel CvScalar colour) {
double dc = sqrt(pow(centers[ci][0] - colour.val[0] 2) + pow(centers[ci][1]
- colour.val[1] 2) + pow(centers[ci][2] - colour.val[2] 2));
double ds = sqrt(pow(centers[ci][3] - pixel.x 2) + pow(centers[ci][4] - pixel.y 2));
return sqrt(pow(dc / nc 2) + pow(ds / ns 2));
//double w = 1.0 / (pow(ns / nc 2));
//return sqrt(dc) + sqrt(ds * w);
}
/*
* Find a local gradient minimum of a pixel in a 3x3 neighbourhood. This
* method is called upon initialization of the cluster centers.
*
* Input : The image (IplImage*) and the pixel center (CvPoint).
* Output: The local gradient minimum (CvPoint).
*/
CvPoint Slic::find_local_minimum(IplImage *image CvPoint center) {
double min_grad = FLT_MAX;
CvPoint loc_min = cvPoint(center.x center.y);
for (int i = center.x-1; i < center.x+2; i++) {
for (int j = center.y-1; j < center.y+2; j++) {
CvScalar c1 = cvGet2D
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1314594 2018-11-07 09:36 SLIC-Superpixels-master\2012-SLIC_superpixels compared to state-of-the-art superpixel methods-TPAMI-Achanta12.pdf
....... 164271 2013-05-13 04:32 SLIC-Superpixels-master\dog.png
....... 57263 2013-05-13 04:32 SLIC-Superpixels-master\dog_segmentation.png
....... 611 2013-05-13 04:32 SLIC-Superpixels-master\README.md
....... 12759 2013-05-13 04:32 SLIC-Superpixels-master\slic.cpp
....... 2515 2013-05-13 04:32 SLIC-Superpixels-master\slic.h
....... 1217 2013-05-13 04:32 SLIC-Superpixels-master\test_slic.cpp
目录 0 2018-11-07 12:15 SLIC-Superpixels-master
----------- --------- ---------- ----- ----
1553230 8
相关资源
- Lenovo Z460 SLIC2.1 LENOVO-29CN38WW(V2.15)
- VMware65_SLP_DeLLSLIC2.1
- <<<em>eem>m><
- 详细图解联想Y430\\Y530笔记本SLIC表2.
- acer slic2.1
- 联想笔记本SLIC表2.1
- DELL SLIC2.5.zip
- 最新slickedit 2020 pro v25 全平台开发工具
- 神舟电脑A560 Q3I21 SLIC 2.1超频版BIOS
- INTEL S2600CP双路主板 加入NVME+DELL SLIC
- VMware-11.1.2-2780323_BIOS添加联想SLIC,可
- 3Dslicer软件操作指导
- 技嘉B75MD3V.F13添加SLIC2.4,已验证。
- Acer as4750g 2.13bios 已集成slic2.1
- SLicerRT 源码
- gem5学习笔记.pdf
- Turbo slicer
- 家悦E2410-BIOS(SLIC21)52KT55AUS
- Slic3r-master.rar
- Thinkpad SL400刷BIOS slic2.1包
- B75M-D3V-F11支持NVME固态硬盘,添加SLI
- 超像素分割SLIC(简单线性迭代聚类)
- ASUS P8H77-V 华硕 BIOS 修改 slic2.1 & nvme
- Terrain Slicing Dynamic Loading Kit V4.4.0.uni
- 地形分割、动态加载 Terrain Slicing Dy
- GA-Z77-D3H ver1.1 (slic2.1) BIOS nvme
- phoenix BIOS刷新所有软件包括各品牌S
- SlickEdit Pro 2016 V21 WIN与LINUX x64 破解
- slickedit-pro2017
- HPPRO3330 开启SLIC
评论
共有 条评论