确定强度值的概率

确定强度值的概率

本文介绍了Matlab-确定强度值的概率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您如何确定强度值出现在Matlab中的图像中的概率,或者有其他确定方法?数学方程是

How do you determine the probability that an intensity value appears in an image in Matlab or is there some other way to determine it? The mathematical equation is

Pr = Nk / M*N

其中Pr是概率,Nk是Kth强度出现在图像中的次数. M * N表示MxN图像.

Where Pr is the probability, Nk is number of times that a Kth intensity appears in the image. M*N represents the MxN image.

推荐答案

假设强度值都是整数,则可以按

Assuming your intensity values are all integers, you can do what you want as

Pr=nnz(img(:)==value)/numel(img);      %# here img is your image, value is the intensity

上面的代码执行的操作是检查img的哪个元素等于value并返回布尔向量,如果为true,则为1;如果为false,则为0. nnz是一个返回非零元素数量的函数(在这种情况下,条件为true的实例).然后将其除以numel(img),其中函数numel给出图像中的元素数量.

What the above code does is it checks which element of img equals value and returns a Boolean vector that is 1 if true and 0 if false. nnz is a function that returns the number of non-zero elements (in this case, instances where the condition is true). This is then divided by numel(img), where the function numel gives the number of elements in the image.

但是,如果您的值不是整数,那么您将必须在一定的公差限制tol内以等价方式实施

However, if your values are not integers, then you will have to implement the equality check within a certain tolerance limit, tol, as

Pr=nnz(img(:)<=value+tol & img(:)>=value-tol)/numel(img);

这篇关于Matlab-确定强度值的概率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 15:59