【醫學影象分割】 基於matlab GVF演算法醫學影象分割【含Matlab原始碼 1213期】
阿新 • • 發佈:2021-08-13
一、GVF Snake演算法簡介
分割的過程中, 影象的輪廓曲線要儘可能變得光滑。然而, Snake模型使輪廓線更加平滑的同時不能凹陷, 對初始位置的選取較為敏感, 極大的增加了模型的不確定性 。GVF Snake模型, 將梯度力擴充套件至整個影象中, 一方面加大了輪廓曲線的動態捕捉能力, 另一方面克服了Snake模型中輪廓線不能凹陷的缺陷 。GVF Snake模型其外力作用範圍較大,具有雙向驅動輪廓運動的特點。對於一幅影象,首先使用邊界檢測運算元獲取該幅影象I(x,y)的邊界f(x,y),w(x,y) =[u(x, y) , v(x, y) ] 為該模型的外力, 則GVF Snake模型的能量泛函可表示為
梯度向量流中梯度力場u、v函式關於時間t的偏微分方程可表示為
二、部分原始碼
clc; clear all; close all; rand('state', 0); warning off all; path([pwd '\\toolbox'], path); filename = 'chest'; % 待處理影象名稱 % 載入影象 [I, map] = rawread(sprintf('images\\%s.pgm', filename)); % 計算邊緣影象 f = 1 - I/255; % GVF處理 [u,v] = GVF(f, 0.1, 80); % 正規化處理 mag = sqrt(u.*u+v.*v); px = u./(mag+1e-10); py = v./(mag+1e-10); % 顯示結果 figure(1); subplot(1, 2, 1); imdisp(I); title('原影象', 'FontWeight', 'Bold'); subplot(1, 2, 2); imdisp(f); title('邊緣影象', 'FontWeight', 'Bold'); % 初始邊緣曲線 load(sprintf('.\\images\\%s.mat', filename)); [x,y] = snakeinterp(XSnake,YSnake,2,0.5); subplot(1, 2, 1); hold on; h = plot(x, y, 'r-'); % GVF迭代 load(sprintf('.\\images\\test_%s.mat', filename)); for i=1:25, [x,y] = snakedeform(x,y,alpha,beta,gamma,kappa,fx,fy,5); [x,y] = snakeinterp(x,y,dmax,dmin); set(h, 'XData', x, 'YData', y); title(['迭代過程,迭代次數為 = ' num2str(i*5)], 'FontWeight', 'Bold') pause(0.2); end title('GVF Snake邊緣提取標記', 'FontWeight', 'Bold') mag = sqrt(u.*u+v.*v); px = u./(mag+1e-10); py = v./(mag+1e-10); % 顯示結果 figure(1); subplot(1, 2, 1); imdisp(I); title('原影象', 'FontWeight', 'Bold'); subplot(1, 2, 2); imdisp(f); title('邊緣影象', 'FontWeight', 'Bold'); % 初始邊緣曲線 load(sprintf('.\\images\\%s.mat', filename)); [x,y] = snakeinterp(XSnake,YSnake,2,0.5); % XSnake % YSnake % GVF snake (active contour) toolbox % Version 1.0 17-June-1997 % Copyright (c) 1996-1997 by Chenyang Xu and Jerry L. Prince % % Image input/output % rawread - Read a Portable Bitmap file, or a raw file % rawwrite - Write a Portable Bitmap file, or a raw file % % Image Display % imdisp - Display an image % % Active Contour % snakeinit - Initialize the snake manually % snakedeform - Deform snake in the given external force field % snakedeform2 - Deform snake in the given external force field with % pressure force % snakedisp - Display a snake % snakeinterp - Interpolate the snake adaptively % snakeinterp1 - Interpolate the snake at a fixed resolution % (better implemented than snakeinterp) % % Gradient Vector Flow % GVF - Compute the gradient vector flow field % % Other % dt - Simple distance transform % gaussianBlur - Blurring an image using gaussian kernel % gaussianMask - Generate a discrete gaussian mask
三、執行結果
四、matlab版本及參考文獻
1 matlab版本
2014a
2 參考文獻
[1] 蔡利梅.MATLAB影象處理——理論、演算法與例項分析[M].清華大學出版社,2020.
[2]楊丹,趙海濱,龍哲.MATLAB影象處理例項詳解[M].清華大學出版社,2013.
[3]周品.MATLAB影象處理與圖形使用者介面設計[M].清華大學出版社,2013.
[4]劉成龍.精通MATLAB影象處理[M].清華大學出版社,2015.