フィルターのクリア

Count the number of items that exceed a threshold

1 回表示 (過去 30 日間)
Alber
Alber 2020 年 5 月 26 日
コメント済み: Alber 2020 年 5 月 26 日
Hello, I want to create a variable called 'proportion' which is defined as the number of pixels that exceed the threshold, of the blue color. This new variable depends on the pixels of the initial and final image. My code is as follows:
function [cond,SIR] = canWeEncode(frameBuffer,alpha,threshold)
imgInicial = frameBuffer(:,:,:,1);
imgFinal = frameBuffer(:,:,:,end);
imgdiff = imgFinal - imgInicial;
I = mean(imgdiff.^2,'all');
proportion = ; % Problem in question
S = 4*(alpha^2)*proportion;
SIR = 10*log10(S/I);
cond = SIR >= threshold;
end
The conclusion is that 'proportion' has to count the number of pixels of the final and initial images that exceed the 'threshold' (located at 0 dB) in the blue color.
I have made an approach that I think may be the solution, but I'm not sure:
condition_A = imgInicial(:,:,3)>=threshold;
condition_B = imgFinal(:,:,3)>=threshold;
proportion = numel(condition_A)+numel(condition_B);
  2 件のコメント
Johannes Hougaard
Johannes Hougaard 2020 年 5 月 26 日
I think you just need to substitute numel with sum as the number of elements in you logical remains the same regardless of the value of the logical.
condition_A = imgInicial(:,:,3)>=threshold;
condition_B = imgFinal(:,:,3)>=threshold;
proportion = numel(condition_A)+numel(condition_B); %This is constant regardless of the values in condition_A and condition_B
proportion = sum(condition_A)+sum(condition_B);
Alber
Alber 2020 年 5 月 26 日
Yes, I think it makes more sense. Thank you

サインインしてコメントする。

回答 (0 件)

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by