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

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개)

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

u r right sit,not 4x4 block.
  1. i want to divide all the frames in a video into 4 equal halves.
  2. Then i need to perform canny, for all the the halves and need to find the index of the half which contain maximum edge pixels (step 2 for all the frames)
  3. Then i want to calculate likelihood ratio (1st frames max count and 2nd frames max count, likewise 1st and 3rd frames max count. then 2nd and 3rd, 2nd and 4th so on).
lr formula = "video shot characterization"papers likelihood ratio method formula,please see it sir.
for p = 1 : num_of_frames
cc = frames(:,:,p); %fetch frame #p somehow
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
[maxcount(p), maxquarter(p)] = max(count);
end
now you have the maximum counts for each frame in maxcount and the index of the quarter in maxquarter, with each of them being vectors with one element per frame.
I could not tell from your description what you need to do with the information about which quarter the maximum count was in.
I do not know how to calculate the likelihood ratios that you are asking for.
Sir,here i have attached formula for likelihood ratio, m =mean, sigma=variance('o' contains all the frames maxquarter, i need to calculate likelihood ratio for maxquarters of all frames) please help me sir.
mean of what ?
sigma usually represents standard deviation, not variance. But either way, variance of what ?
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
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.

댓글을 달려면 로그인하십시오.

질문:

2015년 8월 24일

댓글:

2015년 8월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by