【图像分割】超像素SFFCM图像分割【含Matlab源码 1374期】

⛄一、获取代码方式

获取代码方式1:
完整代码已上传我的资源: 【图像分割】基于matlab超像素SFFCM图像分割【含Matlab源码 1374期】
点击上面蓝色字体,直接付费下载,即可。

获取代码方式2:
付费专栏图像处理(Matlab)

备注:
点击上面蓝色字体付费专栏图像处理(Matlab),扫描上面二维码,付费299.9元订阅海神之光博客付费专栏,凭支付凭证,私信博主,可免费获得5份本博客上传CSDN资源代码(有效期为订阅日起,三天内有效);
点击CSDN资源下载链接:5份本博客上传CSDN资源代码

⛄二、图像分割简介

理论知识参考:【基础教程】基于matlab图像处理图像分割【含Matlab源码 191期】

⛄三、部分源代码

clear all
close all
%%
cluster=2;
f_ori=imread(‘113044.jpg’);
% Note that you can repeat the program for several times to obtain the best
% segmentation result for image ‘12003.jpg’
%% generate superpixels
%SFFCM only needs a minimal structuring element for MMGR, we usually set SE=2 or SE=3 for
%MMGR.
SE=3;
L1=w_MMGR_WT(f_ori,SE);
L2=imdilate(L1,strel(‘square’,2));
[,,Num,centerLab]=Label_image(f_ori,L2);
%% fast FCM
Label=w_super_fcm(L2,centerLab,Num,cluster);
Lseg=Label_image(f_ori,Label);
figure,imshow(Lseg);
function varargout = colorspace(Conversion,varargin)
%Ó¦ÓÃ˵Ã÷£ºf2=colorspace(‘HSV<-RGB’,f);f2ΪÊä³ö£¬fΪÊäÈë,¡®HSV<-RGB¡¯±íʾ´ÓRGB²ÊÉ«¿Õ¼äת»»µ½HSV²ÊÉ«¿Õ¼ä
%COLORSPACE Convert a color image between color representations.
% B = COLORSPACE(S,A) converts the color representation of image A
% where S is a string specifying the conversion. S tells the
% source and destination color spaces, S = ‘dest<-src’, or
% alternatively, S = ‘src->dest’. Supported color spaces are
%
% ‘RGB’ R’G’B’ Red Green Blue (ITU-R BT.709 gamma-corrected)
% ‘YPbPr’ Luma (ITU-R BT.601) + Chroma
% ‘YCbCr’/‘YCC’ Luma + Chroma (“digitized” version of Y’PbPr)
% ‘YUV’ NTSC PAL Y’UV Luma + Chroma
% ‘YIQ’ NTSC Y’IQ Luma + Chroma
% ‘YDbDr’ SECAM Y’DbDr Luma + Chroma
% ‘JPEGYCbCr’ JPEG-Y’CbCr Luma + Chroma
% ‘HSV’/‘HSB’ Hue Saturation Value/Brightness
% ‘HSL’/‘HLS’/‘HSI’ Hue Saturation Luminance/Intensity
% ‘XYZ’ CIE XYZ
% ‘Lab’ CIE Lab* (CIELAB)
% ‘Luv’ CIE Luv* (CIELUV)
% ‘Lch’ CIE L*ch (CIELCH)
%
% All conversions assume 2 degree observer and D65 illuminant. Color
% space names are case insensitive. When R’G’B’ is the source or
% destination, it can be omitted. For example ‘yuv<-’ is short for
% ‘yuv<-rgb’.
%
% MATLAB uses two standard data formats for R’G’B’: double data with
% intensities in the range 0 to 1, and uint8 data with integer-valued
% intensities from 0 to 255. As MATLAB’s native datatype, double data is
% the natural choice, and the R’G’B’ format used by colorspace. However,
% for memory and computational performance, some functions also operate
% with uint8 R’G’B’. Given uint8 R’G’B’ color data, colorspace will
% first cast it to double R’G’B’ before processing.
%
% If A is an Mx3 array, like a colormap, B will also have size Mx3.
%
% [B1,B2,B3] = COLORSPACE(S,A) specifies separate output channels.
% COLORSPACE(S,A1,A2,A3) specifies separate input channels.
% Pascal Getreuer 2005-2006
%%% Input parsing %%%
if nargin < 2, error(‘Not enough input arguments.’); end
[SrcSpace,DestSpace] = parse(Conversion);
if nargin == 2
Image = varargin{1};
elseif nargin >= 3
Image = cat(3,varargin{:});
else
error(‘Invalid number of input arguments.’);
end
FlipDims = (size(Image,3) == 1);
if FlipDims, Image = permute(Image,[1,3,2]); end
if ~isa(Image,‘double’), Image = double(Image)/255; end
if size(Image,3) ~= 3, error(‘Invalid input size.’); end
SrcT = gettransform(SrcSpace);
DestT = gettransform(DestSpace);
if ~ischar(SrcT) & ~ischar(DestT)
% Both source and destination transforms are affine, so they
% can be composed into one affine operation
T = [DestT(:,1:3)*SrcT(:,1:3),DestT(:,1:3)*SrcT(:,4)+DestT(:,4)];
Temp = zeros(size(Image));
Temp(:,:,1) = T(1)*Image(:,:,1) + T(4)*Image(:,:,2) + T(7)*Image(:,:,3) + T(10);
Temp(:,:,2) = T(2)*Image(:,:,1) + T(5)*Image(:,:,2) + T(8)*Image(:,:,3) + T(11);
Temp(:,:,3) = T(3)*Image(:,:,1) + T(6)*Image(:,:,2) + T(9)*Image(:,:,3) + T(12);
Image = Temp;
elseif ~ischar(DestT)
Image = rgb(Image,SrcSpace);
Temp = zeros(size(Image));
Temp(:,:,1) = DestT(1)*Image(:,:,1) + DestT(4)*Image(:,:,2) + DestT(7)*Image(:,:,3) + DestT(10);
Temp(:,:,2) = DestT(2)*Image(:,:,1) + DestT(5)*Image(:,:,2) + DestT(8)*Image(:,:,3) + DestT(11);
Temp(:,:,3) = DestT(3)*Image(:,:,1) + DestT(6)*Image(:,:,2) + DestT(9)*Image(:,:,3) + DestT(12);
Image = Temp;
else
Image = feval(DestT,Image,SrcSpace);
end
%%% Output format %%%
if nargout > 1
varargout = {Image(:,:,1),Image(:,:,2),Image(:,:,3)};
else
if FlipDims, Image = permute(Image,[1,3,2]); end
varargout = {Image};
end
return;

function [SrcSpace,DestSpace] = parse(Str)
% Parse conversion argument
if isstr(Str)
Str = lower(strrep(strrep(Str,‘-’,‘’),’ ‘,’'));
k = find(Str == ‘>’);

if length(k) == 1 % Interpret the form ‘src->dest’
SrcSpace = Str(1:k-1);
DestSpace = Str(k+1:end);
else
k = find(Str == ‘<’);

  if length(k) == 1      % Interpret the form 'dest<-src'
     DestSpace = Str(1:k-1);
     SrcSpace = Str(k+1:end);
  else
     error(['Invalid conversion, ''',Str,'''.']);
  end   

end

SrcSpace = alias(SrcSpace);
DestSpace = alias(DestSpace);
else
SrcSpace = 1; % No source pre-transform
DestSpace = Conversion;
if any(size(Conversion) ~= 3), error(‘Transformation matrix must be 3x3.’); end
end
return;

function Space = alias(Space)
Space = strrep(Space,‘cie’,‘’);
if isempty(Space)
Space = ‘rgb’;
end
switch Space
case {‘ycbcr’,‘ycc’}
Space = ‘ycbcr’;
case {‘hsv’,‘hsb’}
Space = ‘hsv’;
case {‘hsl’,‘hsi’,‘hls’}
Space = ‘hsl’;
case {‘rgb’,‘yuv’,‘yiq’,‘ydbdr’,‘ycbcr’,‘jpegycbcr’,‘xyz’,‘lab’,‘luv’,‘lch’}
return;
end
return;

function T = gettransform(Space)
% Get a colorspace transform: either a matrix describing an affine transform,
% or a string referring to a conversion subroutine
switch Space
case ‘ypbpr’
T = [0.299,0.587,0.114,0;-0.1687367,-0.331264,0.5,0;0.5,-0.418688,-0.081312,0];
case ‘yuv’
% R’G’B’ to NTSC/PAL YUV
T = [0.299,0.587,0.114,0;-0.147,-0.289,0.436,0;0.615,-0.515,-0.100,0];
case ‘ydbdr’
% R’G’B’ to SECAM YDbDr
T = [0.299,0.587,0.114,0;-0.450,-0.883,1.333,0;-1.333,1.116,0.217,0];
case ‘yiq’
% R’G’B’ in [0,1] to NTSC YIQ in [0,1];[-0.595716,0.595716];[-0.522591,0.522591];
T = [0.299,0.587,0.114,0;0.595716,-0.274453,-0.321263,0;0.211456,-0.522591,0.311135,0];
case ‘ycbcr’
% R’G’B’ (range [0,1]) to ITU-R BRT.601 (CCIR 601) Y’CbCr
% Poynton, Equation 3, scaling of R’G’B to Y’PbPr conversion
T = [65.481,128.553,24.966,16;-37.797,-74.203,112.0,128;112.0,-93.786,-18.214,128];
case ‘jpegycbcr’
T = [0.299,0.587,0.114,0;-0.168736,-0.331264,0.5,0.5;0.5,-0.418688,-0.081312,0.5]*255;
case {‘rgb’,‘xyz’,‘hsv’,‘hsl’,‘lab’,‘luv’,‘lch’}
T = Space;
otherwise
error([‘Unknown color space, ‘’’,Space,‘’‘.’]);
end

⛄四、运行结果

在这里插入图片描述

⛄五、matlab版本及参考文献

1 matlab版本
2014a

2 参考文献
[1] 蔡利梅.MATLAB图像处理——理论、算法与实例分析[M].清华大学出版社,2020.
[2]杨丹,赵海滨,龙哲.MATLAB图像处理实例详解[M].清华大学出版社,2013.
[3]周品.MATLAB图像处理与图形用户界面设计[M].清华大学出版社,2013.
[4]刘成龙.精通MATLAB图像处理[M].清华大学出版社,2015.
[5]赵勇,方宗德,庞辉,王侃伟.基于量子粒子群优化算法的最小交叉熵多阈值图像分割[J].计算机应用研究. 2008,(04)

  • 6
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Matlab领域

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值