✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。
🍎个人主页:Matlab科研工作室
🍊个人信条:格物致知。
更多Matlab仿真内容点击👇
【图像分割】基于神经气体网络 (NGN)实现图像分割附matlab代码
% Image Segmentation and Quantization by Neural Gas Network (NGN)
% Define number of segments and iterations and get the output.
% Org is image. You can use your image.
% ParVal.N is Number of Segments
% ParVal.MaxIt is Number of runs
%----------------------------------------------------------------------
clc;
clear;
close all;
%% Load Image
Org=imread('124084.jpg');
X = rgb2gray(Org);
X=double(X);
img=X;
X=X(:)';
%% Neural Gas Network (NGN) Parameters
ParVal.N = 6; % Number of Segments
ParVal.MaxIt = 50; % Number of runs
ParVal.tmax = 100000;
ParVal.epsilon_initial = 0.3;
ParVal.epsilon_final = 0.02;
ParVal.lambda_initial = 2;
ParVal.lambda_final = 0.1;
ParVal.T_initial = 5;
ParVal.T_final = 10;
%% Training Neural Gas Network
NGNnetwok = GasNN(X, ParVal);
%% Vector to image and plot
Weight=sum(round(rescale(NGNnetwok.w,1,ParVal.N)));
Weight=round(rescale(Weight,1,ParVal.N));
indexed=reshape(Weight(1,:),size(img));
segmented = label2rgb(indexed);
% Plot Res
figure('units','normalized','outerposition',[0 0 1 1])
subplot(2,2,1)
imshow(Org,[]); title('Original');
subplot(2,2,2)
imshow(img,[]); title('Grey');
subplot(2,2,3)
imshow(segmented);
title(['Segmented in [' num2str(ParVal.N) '] Segments']);
subplot(2,2,4)
imshow(indexed,[]);
title(['Quantized in [' num2str(ParVal.N) '] Thresholds']);
[1]迪娜·加尔肯. 基于MATLAB的图像分割算法研究及实现[J]. 科学技术创新, 2021(26):3.
❤️部分理论引用网络文献,若有侵权联系博主删除
❤️ 关注我领取海量matlab电子书和数学建模资料