내 세그먼트 작업에 그래프 컷 메서드를 적용하려고합니다. Graph_Cut_Demo에 몇 가지 예제 코드가 있습니다. 코드의Matlab을 사용한 그래프 잘라 내기
부분은 사용 된 방법은 그래프 초기화 데이터 기간 DC를 얻을 클러스터링 K-수단 보인다
img = im2double(imread([ImageDir 'cat.jpg']));
[ny,nx,nc] = size(img);
d = reshape(img, ny*nx, nc);
k = 2; % number of clusters
[l0 c] = kmeans(d, k);
l0 = reshape(l0, ny, nx);
% For each class, the data term Dc measures the distance of
% each pixel value to the class prototype. For simplicity, standard
% Euclidean distance is used. Mahalanobis distance (weighted by class
% covariances) might improve the results in some cases. Note that the
% image intensity values are in the [0,1] interval, which provides
% normalization.
Dc = zeros(ny, nx, k);
for i = 1:k
dif = d - repmat(c(i,:), ny*nx,1);
Dc(:,:,i) = reshape(sum(dif.^2,2), ny, nx);
end
아래 도시된다. 그러나, 나는 그들이이 데이터 용어를 어떻게 계산하는지 이해하지 못한다. 그들이 의견 네에서
dif = d - repmat(c(i,:), ny*nx,1);
를 사용하는 이유는 데이터 용어를 Dc
측정 클래스 프로토 타입에 각 픽셀 값의 거리를 말했다. 수업 프로토 타입은 무엇이며 왜 k-means 라벨로 결정할 수 있습니까?
% calculate the data cost per cluster center
Dc = zeros([sz(1:2) k],'single');
for ci=1:k
% use covariance matrix per cluster
icv = inv(cov(d(l0==ci,:)));
dif = d- repmat(c(ci,:), [size(d,1) 1]);
% data cost is minus log likelihood of the pixel to belong to each
% cluster according to its RGB value
Dc(:,:,ci) = reshape(sum((dif*icv).*dif./2,2),sz(1:2));
end
을 사용했다. 왜 그들은 공분산 행렬을 계산하고 어떻게 마이너스 로그 가능도를 사용하여 데이터 항을 형성 했습니까? 이러한 구현에 사용할 수있는 모든 논문 또는 설명?
고마워요.