SLIC超像素 MATLAB经典程序 直接可用

  • u9_274376
    了解作者
  • 821.6KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-04-08 09:20
    上传日期
在MATLAB下直接可运行,已调试通过,不是epfl网页里面要调用C++的程序。适合学习MATLAB的朋友。。。
code of superpixel.rar
  • code of superpixel
  • 4.png
    804.7KB
  • renumberregions.m
    2.4KB
  • rgb2lab.m
    1.1KB
  • regionadjacency.m
    4.5KB
  • finddisconnected.m
    2.6KB
  • maskimage.m
    1.1KB
  • slic.m
    16.5KB
  • makeregionsdistinct.m
    2.1KB
  • main_slic.m
    152B
  • drawregionboundaries.m
    2.3KB
  • circularstruct.m
    675B
  • mcleanupregions.m
    4.3KB
内容介绍
% SLIC Simple Linear Iterative Clustering SuperPixels % % Implementation of Achanta, Shaji, Smith, Lucchi, Fua and Susstrunk's % SLIC Superpixels % % Usage: [l, Am, Sp, d] = slic(im, k, m, seRadius, colopt, mw) % % Arguments: im - Image to be segmented. % k - Number of desired superpixels. Note that this is nominal % the actual number of superpixels generated will generally % be a bit larger, espiecially if parameter m is small. % 所需 superpixels 的数量。请注意, 这是名义上生成的数量,实际数量一般会更大一点, 尤其是当参数 m 小的时候。 % m - Weighting factor between colour and spatial % differences. Values from about 5 to 40 are useful. Use a % large value to enforce superpixels with more regular and % smoother shapes. Try a value of 10 to start with. % 颜色和空间差异之间的加权因子。在CIELAB空间,范围在[1,40].从大约5到40是有用的。 使用大值来强制 superpixels 的形状更加整齐和平滑。请尝试使用值10开始。 % seRadius - Regions morphologically smaller than this are merged with % adjacent regions. Try a value of 1 or 1.5. Use 0 to % disable.在形态上小于此的区域与相邻区域合并。尝试值1或1.5。使用0禁用。 % colopt - String 'mean' or 'median' indicating how the cluster % colour centre should be computed. Defaults to 'mean'。字符串 "平均值" 或 "中间值", 指示如何计算簇颜色中心。默认为 "平均值" % mw - Optional median filtering window size. Image compression可选中值过滤窗口大小。 图像压缩会导致图像中的 a*b* 组件中出现明显的工件。 % 中值滤波可以减少这种情况。mw可以是一个单一的值, 在这种情况下, 同样的中值滤波适用于每一个 ** 和 b * 组件。 % 另外, 它可以是一个2向量, 其中兆瓦 (1) 指定要应用于 L * 和兆瓦 (2) 的中值过滤窗口是要应用于 * 和 b * 的中值过滤窗口。 % can result in noticeable artifacts in the a*b* components % of the image. Median filtering can reduce this. mw can be % a single value in which case the same median filtering is % applied to each L* a* and b* components. Alternatively it % can be a 2-vector where mw(1) specifies the median % filtering window to be applied to L* and mw(2) is the % median filtering window to be applied to a* and b*. % % Returns: l - Labeled image of superpixels. Labels range from 1 to k. % Am - Adjacency matrix of segments. Am(i, j) indicates whether % segments labeled i and j are connected/adjacent % Sp - Superpixel attribute structure array with fields: % L - Mean L* value % a - Mean a* value % b - Mean b* value % r - Mean row value % c - Mean column value % stdL - Standard deviation of L* 标准偏差 L * % stda - Standard deviation of a* 标准偏差 a * % stdb - Standard deviation of b* 标准偏差 b * % N - Number of pixels % edges - List of edge numbers that bound each % superpixel. This field is allocated分配, but not set, % by SLIC. Use SPEDGES(spedges) for this. % d - Distance image giving the distance each pixel is from its % associated superpixel centre. % % It is suggested that use of this function is followed by SPDBSCAN to perform a % DBSCAN clustering of superpixels. This results in a simple and fast % segmentation of an image. % % Minor variations from the original algorithm as defined in Achanta et al's % paper: % % - SuperPixel centres are initialised on a hexagonal grid rather than a square % one. This results in a segmentation that will be nominally 6-connected % which hopefully facilitates any subsequent post-processing that seeks to % merge superpixels. % - Initial cluster positions are not shifted to point of lowest gradient % within a 3x3 neighbourhood because this will be rendered irrelevant the % first time cluster centres are updated. % % Reference: R. Achanta, A. Shaji, K. Smith, A. Lucchi, P. Fua and % S. Susstrunk. "SLIC Superpixels Compared to State-of-the-Art Superpixel % Methods" PAMI. Vol 34 No 11. November 2012. pp 2274-2281. % % See also: SPDBSCAN, MCLEANUPREGIONS, REGIONADJACENCY, DRAWREGIONBOUNDARIES, RGB2LAB % Copyright (c) 2013 Peter Kovesi % Centre for Exploration Targeting % School of Earth and Environment % The University of Western Australia % peter.kovesi at uwa edu au % % Permission is hereby granted, free of charge, to any person obtaining a copy % of this software and associated documentation files (the "Software"), to deal % in the Software without restriction, subject to the following conditions: % % The above copyright notice and this permission notice shall be included in % all copies or substantial portions of the Software. % % The Software is provided "as is", without warranty of any kind. % Feb 2013 % July 2013 Super pixel attributes returned as a structure array % Note that most of the computation time is not in the clustering, but rather % in the region cleanup process. function [l, Am, Sp, d] = slic(im, k, m, seRadius, colopt, mw, nItr, eim, We) %% if ~exist('colopt','var') || isempty(colopt), colopt = 'mean'; end %设置默认值,~exist('colopt','var')是检测colopt变量是否存在 if ~exist('mw','var') || isempty(mw), mw = 0; end if ~exist('nItr','var') || isempty(nItr), nItr = 10; end if exist('eim', 'var'), USEDIST = 0; else, USEDIST = 1; end MEANCENTRE = 1; MEDIANCENTRE = 2; if strcmp(colopt, 'mean')%比较函数 centre = MEANCENTRE; elseif strcmp(colopt, 'median') centre = MEDIANCENTRE; else error('Invalid colour centre computation option'); end [rows, cols, chan] = size(im); if chan ~= 3 error('Image must be colour'); end %% % Convert image to L*a*b* colourspace. This gives us a colourspace that is % nominally perceptually uniform. This allows us to use the euclidean % distance between colour coordinates to measure differences between % colours. Note the image becomes double after conversion. We may want to % go to signed shorts to save memory. im = rgb2lab(im); %执行完这句,图像变成双精度的了 % Apply median filtering to colour components if mw has been supplied % and/or non-zero if mw if length(mw) == 1 mw(2) = mw(1); % Use same filtering for L and chrominance 对L和色度使用相同的滤波 end for n = 1:3 im(:,:,n) = medfilt2(im(:,:,n), [mw(1) mw(1)]);%medfilt2消除噪声, 中值滤波器 end end % Nominal spacing between grid elements assuming hexagonal grid % 六角网格间的标称间距 S = sqrt(rows*cols / (k * sqrt(3)/2));%??? % Get nodes per row allowing a half column margin at one end that alternates % from row to row 获取每列的节点, 允许在一端从行到行交替的半列边距 nodeCols = round(cols/S - 0.5); % Given an integer number of nodes per row recompute S 给定整数的每列节点数重新计算 S S = cols/(nodeCols + 0.5); % Get number of rows of nodes allowing 0.5 row margin top and bottom 获取允许0.5 行边距顶部和底端的节点行数 nodeRows = round(rows/(sqrt(3)/2*S));%行节点数 vSpacing = rows/nodeRows; % Recompute k 重新计算k k = nodeRows * nodeCols; % Allocate memory and initialise clusters, labels and distances.分配内存和初始化中心、标签和距离。 C = zeros(6,k); % Cluster centre data 1:3 is mean Lab value,初始化聚类中心
评论
    相关推荐
    • matlabc++混合编程
      该压缩文件主要是描述怎样写MATLABc++混合编程,c++程序怎样调用MATLAB函数,以及工程的配置.
    • matlab c c++混合编程
      基于matlab与c和c++混合编程的电子书
    • cvyamlParser:使用新的 Matlab C++ 数据 API 将 OpenCV 数据类型转换为 Matlab 的简单
      使用新的Matlab C ++数据API,用于将OpenCV数据类型转换为Matlab的简单yaml解析器。 mexfile readcvYaml 可用于通过 YAML 文件将数据从 OpenCV 高效传输到 Matlab。 解析器能够在运行时推断正确的数据类型,并以相应...
    • c++builder 调用MATLAB引擎
      c++builder来做界面调用MATLAB引擎来计算
    • mingw matlab C++编译器
      mingw matlab C++编译器
    • siftDemo C++ MATLAB
      LOWE C++matlab混合编程实现的sift演示程序,,,可直接运行,包括图像
    • MatlabC++
      MatlabC++应用非常广泛,有很多种转划方式,作者通过学习,发现使用matcom方法很简洁,也容易上手,供大家参考,相互学习。
    • matlab c++ 联合编程示例
      自己写的matlabC++联合编程的示例,在blog中有篇与之对应,感兴趣的下
    • matlab调用c++
      里面有matlab调用c++的程序,其中包括个人心得和在matlab中具体实现的过程,加详细注释!该程序实现两个矩阵的相加运算,通过这个程序你基本可以掌握如何调用,希望搞matlab的朋友相互切磋。
    • SIM800C_MQTT.rar
      使用SIM800C模块,使用MQTT协议,连接中国移动onenet平台,能实现数据的订阅、发布、存储等