资源简介
超像素图像分割是对图像进行分析和理解的关键步骤,在图像处理领域具有重要的研究和应用价值。本题目需要实现一种基于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
相关资源
- 超像素分割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
- Philips Slice Timing Options
- 3D-slicer.zip
- slickedit pro 2017 (v22) 全功能完整版本
- 联想Marker2.1.zip
- hp dx2818 升级 SLIC2_1
- SlickEdit 2018 V23 注册机
- A8N-VM 刷bios(含工程师版的AFUDOS-可刷
- SLIC超像素分割,可选图片,可选大小
- SlickEdit Pro 2018 v23 破解
- slickedit pro 2018 V23和谐
- slickedit v22 2017破解 mac window,MAC下亲测
- slickedit 2019 v24 全平台 keygen crack 亲测
- dell戴尔SLIC 2.4
- Dell_SLIC工厂模式工具SVCTAG
- SlickEdit_2019(v24)_keygen.zip
- slic 2.4及key
- SlickEdit 用MDK工具编译STM32的例程
- Xshell要继续使用此程序您必须应用最
- gams license file
- slickedit pro 2018 v23(亲测可用)
- SlickEdit pro 2016 v21 keygen
评论
共有 条评论