Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to extract object in an image after boundary detection ?

Status
Not open for further replies.

shymariyas24

Newbie level 1
Joined
Oct 21, 2014
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
21
I've used 'level set based segmentation' method to detect lung boundary in an X-ray image. The boundary is detected, but couldn't segment or extract lung portion from that input X-ray image. Can anyone please help me ? Here the boundary is obtained as a contour . That's y I couldn't correlate it with the input image. Is there any method to convert contour to image form or to extract lung portion from the input X-ray image ? My code is added below..


Code dot - [expand]
1
2
3
4
5
6
7
8
9
10
11
clc clear all; close all; im = imread('coins.png'); figure(1),imshow(im);
 
dimension=ndims(im); if dimension==3 im = rgb2gray(im); end Img1 = im; Img=double(Img1); [nrow, ncol]=size(Img); BW = roipoly(Img); figure(8),imshow(BW); title('Polygon'); u=8*(0.5-BW); figure(9);imshow(He, [0, 255]);hold on; [c,h] = contour(u,[0 0],'r'); [Ix,Iy]=gradient(Img); f=Ix.^2+Iy.^2; g=1./(1+f); lambda=5; delt=3; iteration=200; for n=1:iteration u=levelset(u, g, lambda, delt); if mod(n,25)==0 pause(1); figure(10),imshow(He, [0, 255]); hold on; [c,h] = contour(u,[0 0],'r'); iterNum=[num2str(n), ' iterations']; title(iterNum); hold off; end end
 
function u = levelset(u0, g, lambda, delt) u=u0; [vx,vy]=gradient(g); epsilon=1.5; mu=0.2/5; alf=5;
 
for k=1:1 u=weightvalue(u); [ux,uy]=gradient(u); normDu=sqrt(ux.^2 + uy.^2 + 1e-10); Nx=ux./normDu; Ny=uy./normDu; diracU=Dirac(u,epsilon); K=curvature_central(Nx,Ny); weightedLengthTerm=lambda*diracU.*(vx.*Nx + vy.*Ny + g.*K); penalizingTerm=mu*(4*del2(u)-K); weightedAreaTerm=alf.*diracU.*g; u=u+delt*(weightedLengthTerm + weightedAreaTerm + penalizingTerm); % update the level set function end % the following functions are called by the main function function f = Dirac(x, sigma) f=(1/(2.*sigma))*(1+cos(pi*x/sigma)); b = (x<=sigma) & (x>=-sigma); f = f.*b;
 
function K = curvature_central(nx,ny) [nxx,junk]=gradient(nx); [junk,nyy]=gradient(ny); K=nxx+nyy;
 
function g = weightvalue(f) % Make a function satisfy Neumann boundary condition [nrow,ncol] = size(f); g = f; g([1 nrow],[1 ncol]) = g([3 nrow-2],[3 ncol-2]); g([1 nrow],2:end-1) = g([3 nrow-2],2:end-1); g(2:end-1,[1 ncol]) = g(2:end-1,[3 ncol-2]);

 
Last edited by a moderator:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top