Detect before Track by particle filter.

4 次查看(过去 30 天)
i am trying to find out bhattacharyya distance for likelihood calculations. i wrote the following code and getting a wrong answer. please go through the code and help me out.
=================
rgbimageR = imread('r32.jpg');
rgbimage = imread('r36.jpg');
%imshow(rgbimage);
figure;
%Split into RGB Channels
RedR = rgbimageR(:,:,1);
GreenG = rgbimageR(:,:,2);
BlueB = rgbimageR(:,:,3);
Red = rgbimage(:,:,1);
Green = rgbimage(:,:,2);
Blue = rgbimage(:,:,3);
figure ;
imshow(RedR);
figure;
%imhist(RedR,7);
[countsR,binLocationsR] = imhist(RedR,5);
stem(binLocationsR,countsR);
[rowsR,colsR]=size(RedR);
figure;
[countsG,binLocationsG] = imhist(GreenG,5);
stem(binLocationsG,countsG);
[rowsG,colsG]=size(GreenG);
figure;
[countsB,binLocationsB] = imhist(BlueB,5);
stem(binLocationsB,countsB);
[rowsB,colsB]=size(BlueB);
figure;
%imhist(Red,7);
[counts,binLocations] = imhist(Red,5);
stem(binLocations,counts);
[rows,cols]=size(Red);
%btacoffi=0; %p=zeros(rows,1);
btacoffiR = zeros(5,1);
btacoffiG = zeros(5,1);
btacoffiB = zeros(5,1);
%co =1;
for ro = 1:5 ;
btacoffiR(ro) = btacoffiR(ro) + sqrt((countsR(ro))*(counts(ro)));
btacoffiG(ro) = btacoffiG(ro) + sqrt((countsG(ro))*(counts(ro)));
btacoffiB(ro) = btacoffiB(ro) + sqrt((countsB(ro))*(counts(ro)));
%btacoffi = sqrt((countsR(ro,co))*(counts(ro,co)));
%btacoffi = btacoffi+btacoffi;
end
%btadis = sqrt(1-btacoffi);
btadisR=0;
btadisG=0;
btadisB=0;
for i=1:5
btadisR=btadisR + sqrt(1-btacoffiR(i));
btadisG=btadisG + sqrt(1-btacoffiG(i));
btadisB=btadisB + sqrt(1-btacoffiB(i));
end
btadis = btadisR + btadisG + btadisB ;
===================

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Image Processing and Computer Vision 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by