Hi sir, please find the attached code,and correct it,i need to find likelihood ratio for 'n 4x4 block', in 'n frames'.i dontno to explain clearly,if u see the code u can able to understand what i want.please look after it

1 次查看(过去 30 天)
for p=1:num of frames
i1 = cc(1:96,1:96);
i2 = cc(1:96,97:192);
i3 = cc(97:192,1:96);
i4 = cc(97:192,97:192);
y = {i1, i2, i3, i4};
for i=1:length(y)
ui = edge(y{i},'canny');
count(i) = length(find(ui(:)==1));
end
[~, o] = max(count);
% finding likelihood ratio
for o=1:length(o)
lr=(((var(mean(o))+var(mean(o+1))/2)+((mean(mean(o))-mean(mean(o+1))/2)^2)^2)/(var(mean(o))*var(mean(o+1)));
end
end

回答(1 个)

Walter Roberson
Walter Roberson 2015-8-24
You have no 4 x 4 blocks.
That code will count the number of canny == 1 results in each y, so count will be a vector the same length as the cell array y. [~, o] = max(count); will then find the index in count where the value is largest. o is going to be a scalar. Then for o=1:length(o) is going to be for o=1:1 (because length() of a scalar is 1) so inside the "for" loop, the "o" you calculated is going to be overwritten with the value 1.
Your "lr" formula does not look correct to me.
  7 个评论
kaavya subramani
kaavya subramani 2015-8-25
sir its for variance,it means max quarter of 1st and 2nd,1st and 3rd so on,then 2nd and 3rd,2nd and 4th and so on..likewise for 3rd and 4th frames,3rd and 5th frames ......instead of k-1,please consider k+1,by mistake i typed wrongly
kaavya subramani
kaavya subramani 2015-8-25
i1 = cc(1:96,1:96); i2 = cc(1:96,97:192); i3 = cc(97:192,1:96); i4 = cc(97:192,97:192); y = {i1, i2, i3, i4}; for i=1:length(y) ui = edge(y{i},'canny'); count(i) = length(find(ui(:)==1)); end [~, o] = max(count);%This 'o' contains the index of the block which contain maximum edge pixels. % finding likelihood ratio for o=1:length(o) lr=(((var(mean(o))+var(mean(o+1))/2)+((mean(mean(o))-mean(mean(o+1))/2)^2)^2)/(var(mean(o))*var(mean(o+1)));
end end I want to find like this for all frames.then need to perform likelihood ratio,for eg:if 1st frames maxcount block index'1',2nd frames maxcount block index is '3'.then find likelihood ratio for 1st frames '1' block matrix and 2nd frames '3' block matrix.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Computer Vision with Simulink 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by