Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

image segmentation using graph cut with seed points

I'm working in medical image segmentation and I want to combine fuzzy connectedness algorithm with the graph cut, the idea is to segment the image with fuzzy connectedness the background and the foreground will be used as sink and source for the graph cut algorithm, this is my code to obtain the seeds coordinates for the graph cut segmentation

FC=afc(S,K); %// Absolute FC
u=FC>thresh;
v=FC<thresh;

s=regionprops(u, 'PixelIdxList'); %// listes de pixels de l´objet
t=regionprops(v, 'PixelIdxList'); %// listes de pixels de l´arrière plan
[a,b]=size(s);
[w,c,z]= size(t)

for i=1:a
    for j=1:b
        [y,x] = ind2sub(size(u), s(i,j).PixelIdxList);
    end
end
for k=1:w
    for d=1:c
        [y1,x1] = ind2sub(size(v), t(k,d).PixelIdxList);
    end
end

For the graph cut, I used an algorithm from the File Exchange

For example, I can define

Cs=-log([y x])
Ct=-log([y1 x1])

but the problem is how to combine the information from the cost functions like this part of the code source

u = double((Cs-Ct) >= 0);
ps = min(Cs, Ct);
pt = ps

it will exceed the matrix size

like image 445
Born New Avatar asked Mar 19 '16 07:03

Born New


People also ask

What is graph cut segmentation?

Graph cut is a semiautomatic segmentation technique that you can use to segment an image into foreground and background elements. Graph cut segmentation does not require good initialization. You draw lines on the image, called scribbles, to identify what you want in the foreground and what you want in the background.

Is it possible to combine fuzzy connectedness and graph cut segmentation?

I'm working in medical image segmentation and I want to combine fuzzy connectedness algorithm with the graph cut, the idea is to segment the image with fuzzy connectedness the background and the foreground will be used as sink and source for the graph cut algorithm, this is my code to obtain the seeds coordinates for the graph cut segmentation

How does segmentation work in image processing?

The technique creates a graph of the image where each pixel is a node connected by weighted edges. The higher the probability that pixels are related the higher the weight. The algorithm cuts along weak edges, achieving the segmentation of objects in the image.

What is the graph cut technique?

The Graph Cut technique applies graph theory to image processing to achieve fast segmentation. The technique creates a graph of the image where each pixel is a node connected by weighted edges. The higher the probability that pixels are related the higher the weight.


1 Answers

I am not familiar with the graph-cut implementation from FEX you linked to,
but I'll show an example using GCMex matlab wrapper (proper disclosure: I implemented this wrapper).

Assuming you have an image of size size(S) with n pixels and K a sparse matrix of size n-by-n with K(ii,jj) representing how well ii and jj pixels are connected (for neighboring ii and jj).
Moreover, you have a mask u of foreground pixels and a mask v of background pixels to be treated as hard constraints.

First, construct the data term using u and v:

Dc = 1000*[u(:), v(:)]; %// assign very large cost for picking FG pixel to label zero and vice versa

As you can see the data-term Dc, is n-by-2 array with the cost of assigning label l (either 0 or one) to pixel ii is stored in Dc(ii,l+1). Therefore, for pixels in the foreground (u(ii) is 1) assigning label l=0 (i.e. background) the cost you pay is 1000. The same goes for pixels in the background (v(ii) is 1) assigning them to foreground (i.e., l=1) is cost 1000. Therefore, the data term Dc gives very high cost to seed pixels (either foreground or background) getting the wrong label.

Construct a graph-cut object

gch = GraphCut('open'), Dc, [0 1; 1 0], K );
[gch L] = GraphCut('expand',gch);
gch = GraphCut('close',gch);
L = reshape(L, size(u)); 
figure; imshow(L,[]); title('the resulting mask');

Note that in rder to use GCMex you need to follw the installation instructions and compile it for it to work.

like image 135
Shai Avatar answered Oct 16 '22 08:10

Shai