0
Tải bản đầy đủ (.pdf) (83 trang)

Tạo mô hình hình dạng:

Một phần của tài liệu PHÂN ĐOẠN HÌNH ẢNH Y TẾ SỬ DỤNG BỘ LỌC PHẦN TỬ (PARTICLE FILTERING) CÓ CODE MATLAB (Trang 64 -64 )

Để tạo ra các hình dạng mới v, các mô hình phân phối điểm thực tế được xây dựng bằng cách áp dụng mô hình PCA, trên V ( ,V1 ,VN), các vector đặc trưng e1, ,eeˆ với

 

ˆ min ,

e s

end N và không bao gồm các mô hình với phương sai nhỏ eeˆ

Bất kỳ hình dạng v trong không gian con mở rộng ra bởi các tập hợp đã tạo có thể được đại diện bởi:

v v Eb (4.3) Trong đó, vlà hình dạng bên trong không gian con, E là cơ sở của không gian riêng,

b biểu thị các thông số của mô hình biến dạng, mỗi phần tử của b kiểm soát một hình thức thay đổi hình dạng, chế độ đầu tiên chịu trách nhiệm về các biến đổi cao nhất, thứ tự giảm dần.

Hình 4.5: Tạo mô hình hình dạng 4.3. Những đặc tính Haar-like: 4.3.1. Cơ bản về đặc tính Haar-like Hình 4.6: Những đặc tính Haar-like Hình ảnh gốc Hình ảnh tách rời Những đặc tính Haar-like Những đặc tính Haar-like Những đặc tính Haar-like Những đặc tính Haar-like Để tính toán các tính năng một cách nhanh chóng

4.3.2. Đặc tính Haar-like: hai hình chữ nhật

4.3.3. Hình ảnh tách rời

Hình ảnh tách rời được tạo từ hình ảnh gốc như sau:

, ( , ) ( , ) x x y y ii x y i x y     

(4.4) Và s x y( , )s x y( ,  1) i x y( , ) (4.5) ii x y( , )ii x( 1, )ys x y( , ) (4.6)

Hình 4.7: Tính toán tổng các hình chữ nhật bất kì với hình ảnh tách rời

Sự khác nhau giữa tổng các điểm ảnh trong hai khu vực hình chữ nhật

Khu vực này có cùng kích thước và hình dạng, và liền kề theo chiều ngang hoặc theo chiều dọc.

Hình ảnh tách rời

4.4. Phân loại tập hợp ngẫu nhiên 4.4.1. Các bước thực hiện 4.4.1. Các bước thực hiện

Xây dựng tập hợp

Tạo các phần tử trên một tập hợp khác nhau của dữ liệu đã tạo

Tại mỗi nút phần tử, phân chia các dữ liệu dựa trên những tính năng tập hợp khác nhau. Đánh giá từng phần tử trong tập hợp dữ liệu

Kết quả tổng hợp trên tất cả các phần tử 1 2 3 12 13 14 30 31 32 P P P P P P P P P                                    

Hình 4.8: Xây dựng tập hợp ngẫu nhiên và bản đồ xác suất

Dự đoán

4.4.2. Hàm chi phí 13 13 1, , 8, , , , ,x y 1 2 , xb b t t r s s xR (4.7) ( ) 1 i ( ) n i p shape x p f x n  

(4.8)

4.4.3. Khai triển tích phân

Khai triển tích phân (DE: Differential Evolution) là một nhánh của thuật toán GA cổ điển. Nó hoạt động bằng cách thiết lập các giải pháp từng phần.

Nó sử dụng cách vận hành tìm kiếm tự nhiên: - Các thay đổi

- Những chỗ giao nhau - Sự chọn lọc

Nó phụ thuộc vào các vấn đề mà chúng ta cần phải giải quyết.

Hình 4.9: Tính toán DE

2 hệ số chuyển đổi 2 hệ số mở rộng

4.5. Thực thi trên Matlab

Các bước thực hiện trên Matlab:

Bước 1: Thiết lập môi trường ban đầu

Thiết lập đường dẫn Matlab và đọc các dữ liệu đầu vào.

Bước 2: Xây dựng các hàm cần thiết

Bước 3: Tạo các mô hình hình dạng

Bước này tạo các mô hình hình dạng trên các dữ liệu đầu vào đã liên kết (30 mẫu đầu tiên). Kết quả là hình dạng trung bình và ma trận của các thành phần chính và vector của các giá trị riêng liên quan với các thành phần.

Bước 4: Xuất các mẫu đã tạo cho phân loại điểm ảnh

Bước này xuất các mẫu đã tạo tốt và không tốt cho các thuật toán tập hợp ngẫu nhiên bằng cách đánh giá các tính năng Haar-like trên ranh giới mỗi điểm ảnh, và một tập hợp điểm ảnh ngẫu nhiên không có ranh giới. Nó sẽ tạo ra những mẫu đầu ra.

Bước 5: Tạo tập hợp ngẫu nhiên

Bước này chuẩn bị các thông số cho các hàm sẽ dùng, và tính toán tập hợp vào biến B, B là các cấu trúc bên trong MATLAB định nghĩa tập hợp ngẫu nhiên

Bước 6: Tạo một bản đồ xác suất

Bước này được sử dụng để tính toán bản đồ xác suất cho những hình ảnh thử nghiệm. (20 hình ảnh cuối cùng trong tập dữ liệu đầu vào). Các bản đồ xác suất kết quả được lưu trữ trong các ô PM.

Bước 7: Thực thi thuật toán Differential Evolution

4.6. Kết quả thực hiện

Sau khi thực hiện các bước trên, ta có kết quả phân đoạn xương bàn tay như sau:

(a) Hình thứ 1 (b) Hình thứ 2 (c) Hình thứ 3 (d) Hình thứ 4 (e) Hình thứ 5 (f) Hình thứ 6 (g) Hình thứ 7 (h) Hình thứ 8 (i) Hình thứ 9 (j) Hình thứ 10 (k) Hình thứ 11 (l) Hình thứ 12 (m) Hình thứ 13 (n) Hình thứ 14

Kết quả phân đoạn dựa theo bản đồ xác suất: (a) Hình thứ 1 (b) Hình thứ 2 (c) Hình thứ 3 (d) Hình thứ 4 (e) Hình thứ 5 (f) Hình thứ 6 (g) Hình thứ 7 (h) Hình thứ 8 (i) Hình thứ 9

Hình 4.11: Kết quả phân đoạn dựa theo bản đồ xác suất

Nhận xét: Sự phân đoạn xương bàn tay sử dụng thuật toán bộ lọc phần tử kết hợp mô hình PCA cho ra các kết quả rất chính xác, có sai số nhỏ với đầu vào là các hình ảnh xương bàn tay khác nhau, điều này chứng tỏ sự hiệu quả của thuật toán phân đoạn này.

Chương 5

KẾT LUẬN VÀ HƯỚNG PHÁT TRIỂN ĐỀ TÀI

5.1. Kết luận

Đề tài đã hoàn thành trong thời gian quy định và từ những yêu cầu đề ra, em đã hoàn thành được các yêu cầu sau:

 Tìm hiểu được lý thuyết về bộ lọc phần tử và khái niệm phân đoạn ảnh.

 Tìm hiểu một số ứng dụng của bộ lọc phần tử trong phân đoạn hình ảnh y tế.

 Thực hiện được ứng dụng của bộ lọc phần tử trong phân đoạn xương bàn tay. Những hạn chế chưa làm được:

 Chưa thể ứng dụng rộng rãi phương pháp cho các phân đoạn hình ảnh y tế khác nhau.

 Chưa thể áp dụng phương pháp trên phần cứng.

5.2. Hướng phát triển đề tài

Để tiếp tục nghiên cứu đề tài này, em nhận thấy có các hướng phát triển sau:

 Áp dụng phân đoạn ảnh dùng bộ lọc phần tử trong video.

 Cải thiện thuật toán và nghiên cứu các kỹ thuật phân đoạn hình ảnh y tế khác.

 Tìm hiểu về các ứng dụng khác của bộ lọc phần tử trong thông tin vô tuyến, xử lý tín hiệu trong viễn thông và thực hiện ứng dụng trên phần cứng.

TÀI LIỆU THAM KHẢO

[1] Petar M. Djuric, Jayesh H. Kotecha, Jianqui Zhang, Yufei Huang, Tadesse Ghirmai, Monica F. Bugallo, Joaquin Miguez, “Particle filtering”, IEEE Signal Processing Magazine, vol. 20, no. 5, September 2003.

[2] Hervé Abdi, Lynne J. Williams, “Principal component analysis”, John Wiley & Sons, Inc, August 2010.

[3] Lindsay I Smith, “A tutorial on Principal Components Analysis”, Cornell University, USA,February 2002.

[4] Wei Qu, Xiaolei Huang, Yuanyuan Jia, “Segmentation in noisy medical images using PCA model based Particle filtering”, SPIE Proceedings Vol. 6914,March 2008.

[5] Thomas Dietenbeck, Francois Varray, Jan Kybic, Olivier Basset, and Christian Cachard, “Neuromuscular fiber segmentation using particle filtering and discrete optimization”, SPIE Medical Imaging, Vol. 9034, February 2014.

[6] F. Lecellier, S. Jehan-Besson, J. Fadili, “Statistical region-based active contours for segmentation: An overview”, Elsevier Masson SAS, December 2013.

[7] Chunming Li, Rui Huang, Zhaohua Ding, J. Chris Gatenby, Dimitris N. Metaxas, “A level set method for image segmentation in the presence of intensity inhomogeneities with application to MRI”, IEEE Transactions on Image processing, Vol. 20, No. 7, July 2011. [8] Lukas Fischer, “Using shape Particle filters for robust medical image segmentation”, Technical Report, Vienna University of Technology, May 2009.

[9] Marleen de Bruijne, Mads Nielsen, “Image segmentation by shape Particle filtering”, Technical Report, IT University of Copenhagen, Denmark, Aug. 2004.

[10] Ahmad Pahlavan Tafti, Zoltán Bárdosi, Donatella Granata, Gabor Lugos, Sanjay Saxena,

“Particle filter segmentation”, Technical Report , Vienna, Austria, July 2012.

[11] Onur Ozdemir, Ruixin Niu, Pramod K. Varshney, “Tracking in Wireless Sensor Networks Using Particle Filtering: Physical Layer Considerations”, IEEE Transactions on signal processing, Vol. 57, No. 5, May 2009.

[12] Katrin Achutegui, Luca Martino, Javier Rodas, Carlos J. Escudero, Joaquín Míguez, “A Multi-Model Particle Filtering Algorithm for Indoor Tracking of Mobile Terminals Using RSS Data”, Technical Report , Russia, July 2009.

[13] Chris Kreucher , Mark Morel , Keith Kastella , Alfred O. Hero, “Particle Filtering for Multitarget Detection and Tracking”, The Proceedings of The Twenty Sixth Annual IEEE Aerospace Conference, March 2005.

[14] Fredrik Gustafsson, Fredrik Gunnarsson, Niclas Bergman, Urban Forssell, Jonas Jansson, Rickard Karlsson, Per-Johan Nordlund, “Particle Filters for Positioning, Navigation and Tracking”, IEEE Transactions on Signal Processing, Vol. 50, February 2002.

[15] D. Varas, F. Marques, “A region-based particle filter for generic object tracking and segmentation”, 19th IEEE International Conference on Image Processing, October 2012. [16] Nicolas Widynski, Max Mignotte, “A MultiScale Particle Filter Framework for Contour Detection”, IEEE Transactiosn on pattern analysis and machine intelligence, February 2014. [17] www.mathworks.com.

[18] www.ieeexplore.ieee.org. [19] www.wikipedia.org.

PHỤ LỤC

Code chương trình mô phỏng phân đoạn xương bàn tay sử dụng bộ lọc phần tử và mô hình PCA trên Matlab.

Các hàm cần thiết:

function features = getSamples( image, mask )

%GETPREDICTORS Summary of this function goes here % Detailed explanation goes here

integralImage = getIntegralImage( image );

borderIndexes = find( mask == 10 ); n = size( borderIndexes, 1 );

features = zeros( 5*n, 15 );

for i = 1:n

[ y, x ] = ind2sub( size( image ), borderIndexes(i) );

features( i, 1:14) = getHaarFeatures( integralImage, x, y ); features( i, 15 ) = 1;

end

% make the border pixels unselectable by the random neg. feat.

% selector

mask(1:4,:) = ones( 4, size(mask,2) );

mask(end-3:end, :) = ones( 4, size(mask,2) ); mask( :, 1:4 ) = ones( size(mask,1), 4 );

mask( :, end-3:end ) = ones( size(mask,1), 4 );

nonborderIndexes = find( mask == 0 );

% random indexes

for j = n+1:5*n

m = size( nonborderIndexes, 1 );

random = floor( rand(1) * (m-1) ) + 1;

index = nonborderIndexes( random );

nonborderIndexes = [ nonborderIndexes( 1:random-1 ); nonborderIndexes( random+1:end ) ];

[ y, x ] = ind2sub( size( image ), index );

features( j, 1:14) = getHaarFeatures( integralImage, x, y ); features( j, 15 ) = 0;

end

end

function PlotIt_Orig(img, landmarks, FVr_temp, S_struct )

meanShape = S_struct.meanShape; PC = S_struct.PC;

T = [ cos(FVr_temp(11)), -sin(FVr_temp(11)), FVr_temp(9) ; ...

sin(FVr_temp(11)), cos(FVr_temp(11)), FVr_temp(10) ; ...

0, 0, 1 ];

shape = genShape( meanShape, PC, [ FVr_temp(12), 0; 0 FVr_temp(13) ], FVr_temp(1:8), T );

imshow(img), hold on,

plot( shape(:,1), shape(:,2), 'y', 'LineWidth', 2 );

plot( landmarks(:,1), landmarks(:,2), 'b', 'LineWidth', 2 );

drawnow;

pause(1); %wait for one second to allow convenient viewing

return

function PlotIt(FVr_temp,iter,S_struct) probMap = S_struct.probMap;

meanShape = S_struct.meanShape; PC = S_struct.PC;

T = [ cos(FVr_temp(11)), -sin(FVr_temp(11)), FVr_temp(9) ; ...

sin(FVr_temp(11)), cos(FVr_temp(11)), FVr_temp(10) ; ...

0, 0, 1 ];

shape = genShape( meanShape, PC, [ FVr_temp(12), 0; 0 FVr_temp(13) ], FVr_temp(1:8), T );

imagesc(probMap), colormap(gray), hold on, plot( shape(:,1), shape(:,2),

'y', 'LineWidth', 3 );

drawnow;

pause(1); %wait for one second to allow convenient viewing

return

function PlotIt(FVr_temp,iter,S_struct) probMap = S_struct.probMap;

meanShape = S_struct.meanShape; PC = S_struct.PC;

T = [ cos(FVr_temp(11)), -sin(FVr_temp(11)), FVr_temp(9) ; ...

sin(FVr_temp(11)), cos(FVr_temp(11)), FVr_temp(10) ; ...

0, 0, 1 ];

shape = genShape( meanShape, PC, [ FVr_temp(12), 0; 0 FVr_temp(13) ], FVr_temp(1:8), T );

imagesc(probMap), colormap(gray), hold on,

plot( shape(:,1), shape(:,2), 'y', 'LineWidth', 3 );

plot( shape(52:end,1), shape(52:end,2), 'b+', 'LineWidth', 3 );

plot( shape(41:51,1), shape(41:51,2), 'r+', 'LineWidth', 3 );

drawnow;

pause(1); %wait for one second to allow convenient viewing

return

function PlotIt_Pts(FVr_temp,iter,S_struct,color) probMap = S_struct.probMap;

meanShape = S_struct.meanShape; PC = S_struct.PC;

T = [ cos(FVr_temp(11)), -sin(FVr_temp(11)), FVr_temp(9) ; ...

sin(FVr_temp(11)), cos(FVr_temp(11)), FVr_temp(10) ; ...

0, 0, 1 ];

shape = genShape( meanShape, PC, [ FVr_temp(12), 0; 0 FVr_temp(13) ], FVr_temp(1:8), T );

hold on, plot( shape(:,1), shape(:,2), color, 'LineWidth', 3 );

function [FVr_bestmem,S_bestval,I_nfeval] = deopt(fname,S_struct)

%---This is just for notational convenience and to keep the code uncluttered.--- I_NP = S_struct.I_NP; F_weight = S_struct.F_weight; F_CR = S_struct.F_CR; I_D = S_struct.I_D; FVr_minbound = S_struct.FVr_minbound; FVr_maxbound = S_struct.FVr_maxbound; I_bnd_constr = S_struct.I_bnd_constr; I_itermax = S_struct.I_itermax; F_VTR = S_struct.F_VTR; I_strategy = S_struct.I_strategy; I_refresh = S_struct.I_refresh; I_plotting = S_struct.I_plotting;

%---Check input variables---

if (I_NP < 5)

I_NP=5;

fprintf(1,' I_NP increased to minimal value 5\n');

end

if ((F_CR < 0) | (F_CR > 1))

F_CR=0.5;

fprintf(1,'F_CR should be from interval [0,1]; set to default value

0.5\n');

end

if (I_itermax <= 0)

I_itermax = 200;

fprintf(1,'I_itermax should be > 0; set to default value 200\n');

end

I_refresh = floor(I_refresh);

%---Initialize population and some arrays---

FM_pop = zeros(I_NP,I_D); %initialize FM_pop to gain speed

%----with random values between the min and max values of the---

%----parameters---

for k=1:I_NP FM_pop(k,:) = FVr_minbound + rand(1,I_D).*(FVr_maxbound - FVr_minbound); end FM_popold = zeros(size(FM_pop)); % toggle population FVr_bestmem = zeros(1,I_D);% best population member ever FVr_bestmemit = zeros(1,I_D);% best population member in iteration I_nfeval = 0; % number of function evaluations %---Evaluate the best member after initialization---

I_best_index = 1; % start with first population member S_val(1) = feval(fname,FM_pop(I_best_index,:),S_struct); S_bestval = S_val(1); % best objective function value so far I_nfeval = I_nfeval + 1; for k=2:I_NP % check the remaining members S_val(k) = feval(fname,FM_pop(k,:),S_struct); I_nfeval = I_nfeval + 1; if (left_win(S_val(k),S_bestval) == 1) I_best_index = k; % save its location S_bestval = S_val(k); end

end FVr_bestmemit = FM_pop(I_best_index,:); % best member of current iteration S_bestvalit = S_bestval; % best value of current iteration FVr_bestmem = FVr_bestmemit; % best member ever %---DE-Minimization---

%---FM_popold is the population which has to compete. It is---

%---static through one iteration. FM_pop is the newly---

%---emerging population.---

FM_pm1 = zeros(I_NP,I_D); % initialize population matrix 1

FM_pm2 = zeros(I_NP,I_D); % initialize population matrix 2

FM_pm3 = zeros(I_NP,I_D); % initialize population matrix 3

FM_pm4 = zeros(I_NP,I_D); % initialize population matrix 4

FM_pm5 = zeros(I_NP,I_D); % initialize population matrix 5

FM_bm = zeros(I_NP,I_D); % initialize FVr_bestmember matrix

FM_ui = zeros(I_NP,I_D); % intermediate population of perturbed

vectors

FM_mui = zeros(I_NP,I_D); % mask for intermediate population

FM_mpo = zeros(I_NP,I_D); % mask for old population

FVr_rot = (0:1:I_NP-1); % rotating index array (size I_NP)

FVr_rotd = (0:1:I_D-1); % rotating index array (size I_D)

FVr_rt = zeros(I_NP); % another rotating index array

FVr_rtd = zeros(I_D); % rotating index array for

exponential crossover

FVr_a1 = zeros(I_NP); % index array

FVr_a2 = zeros(I_NP); % index array

FVr_a3 = zeros(I_NP); % index array

FVr_a4 = zeros(I_NP); % index array

FVr_ind = zeros(4);

FM_meanv = ones(I_NP,I_D); I_iter = 1;

while ((I_iter < I_itermax) & (S_bestval.FVr_oa(1) > F_VTR))

FM_popold = FM_pop; % save the old population

S_struct.FM_pop = FM_pop;

S_struct.FVr_bestmem = FVr_bestmem;

FVr_ind = randperm(4); % index pointer array

FVr_a1 = randperm(I_NP); % shuffle locations of

vectors

FVr_rt = rem(FVr_rot+FVr_ind(1),I_NP); % rotate indices by ind(1)

positions

FVr_a2 = FVr_a1(FVr_rt+1); % rotate vector locations

FVr_rt = rem(FVr_rot+FVr_ind(2),I_NP); FVr_a3 = FVr_a2(FVr_rt+1); FVr_rt = rem(FVr_rot+FVr_ind(3),I_NP); FVr_a4 = FVr_a3(FVr_rt+1); FVr_rt = rem(FVr_rot+FVr_ind(4),I_NP); FVr_a5 = FVr_a4(FVr_rt+1);

FM_pm1 = FM_popold(FVr_a1,:); % shuffled population 1

FM_pm2 = FM_popold(FVr_a2,:); % shuffled population 2

FM_pm3 = FM_popold(FVr_a3,:); % shuffled population 3

FM_pm4 = FM_popold(FVr_a4,:); % shuffled population 4

FM_pm5 = FM_popold(FVr_a5,:); % shuffled population 5

for k=1:I_NP % population filled with the

best member

FM_bm(k,:) = FVr_bestmemit; % of the last iteration

end

FM_mui = rand(I_NP,I_D) < F_CR; % all random numbers < F_CR are 1, 0

otherwise

%----Insert this if you want exponential crossover.---

%FM_mui = sort(FM_mui'); % transpose, collect 1's in each column

%for k = 1:I_NP

% n = floor(rand*I_D);

% if (n > 0)

% FVr_rtd = rem(FVr_rotd+n,I_D);

% FM_mui(:,k) = FM_mui(FVr_rtd+1,k); %rotate column k by n

% end

%end

%FM_mui = FM_mui'; % transpose back

%----End: exponential crossover---

FM_mpo = FM_mui < 0.5; % inverse mask to FM_mui

if (I_strategy == 1) % DE/rand/1

FM_ui = FM_pm3 + F_weight*(FM_pm1 - FM_pm2); % differential variation

FM_ui = FM_popold.*FM_mpo + FM_ui.*FM_mui; % crossover

FM_origin = FM_pm3;

FM_ui = FM_popold + F_weight*(FM_bm-FM_popold) + F_weight*(FM_pm1 - FM_pm2);

FM_ui = FM_popold.*FM_mpo + FM_ui.*FM_mui; FM_origin = FM_popold;

elseif (I_strategy == 3) % DE/best/1 with jitter

FM_ui = FM_bm + (FM_pm1 - FM_pm2).*((1- 0.9999)*rand(I_NP,I_D)+F_weight); FM_ui = FM_popold.*FM_mpo + FM_ui.*FM_mui; FM_origin = FM_bm;

elseif (I_strategy == 4) % DE/rand/1 with per- vector-dither f1 = ((1-F_weight)*rand(I_NP,1)+F_weight); for k=1:I_D FM_pm5(:,k)=f1; end

Một phần của tài liệu PHÂN ĐOẠN HÌNH ẢNH Y TẾ SỬ DỤNG BỘ LỌC PHẦN TỬ (PARTICLE FILTERING) CÓ CODE MATLAB (Trang 64 -64 )

×