poster
2019-12-10, 20:48
我发现很难在MATLAB中 (http://en.wikipedia.org/wiki/MATLAB)表示两个公式。假设有两个相同大小的RGB图像A和B ,其中m , n代表行和列,第三维d = 3。如果A是原始图像而B是变形版本,则Formula1基本计算像素的变化率。 Formula2计算像素的平均变化率。
1. Formula1= { sum(C(m,n,d)) / (m * n)} * 100
where `C(m,n) = 0`, if `A(m,n) = B(m,n)` `=1`, if `A(m,n) != B(m,n)` 汇总所有行和列,包括第三维。
我已经尝试过这样的事情:
Formula1 = sum(sum(abs(double(A)-double(B))./(m*n), 1), 2); 但这不会产生任何错误。但是,这不是表示它的正确方法,因为没有包含if条件。问题区域是如何通过检查A == B和A != B来合并条件。
2. Formula2 ={ 1/ (m*n)} * sum { norm (A - B) / 255} * 100再次,这里也是所有维度的总和。我不知道如何形成矩阵范数。
Formula3 is ={ 1/ (m*n)} * sum {(A - B) / 255} * 100我像这样尝试过
C = double(sum(AB,3)); r =重塑(100 *(C / 255)/(m * n),[1 3])
但是有一个错误,说尺寸应该相同并且重塑不起作用。
回答:
对于Formula1 :
function r = Formula1(A,B) [m,n,d] = size(A); %# A and B must have the same dimension C = A ~= B; %# C has a 1 in every pixel that's different r = double(sum(C(:)))/(m*n); r = r/d; %# normalize by number of color planes ~=运算符检查不等式。 (:)将矩阵向量化,从而使我们能够计算所有维度上的总和。
对于Formula2 :
function r = Formula2(A,B) [m,n,d] = size(A); C = double(sum(AB, 3)); %# sum over the color planes C = C/d; %# normalize by number of color planes K = norm(C); %# or norm(C,1), norm(C,inf) etc. r = 100*(K/255)/(m*n); 在这里, sum(AB, 3)在彩色平面上求和,留下具有原始图像尺寸的2D矩阵。有几种矩阵规范,您可以在NORM (http://www.mathworks.com/help/techdoc/ref/norm.html)的文档中进行 (http://www.mathworks.com/help/techdoc/ref/norm.html)选择。
更多&回答... (https://stackoverflow.com/questions/3788543)
1. Formula1= { sum(C(m,n,d)) / (m * n)} * 100
where `C(m,n) = 0`, if `A(m,n) = B(m,n)` `=1`, if `A(m,n) != B(m,n)` 汇总所有行和列,包括第三维。
我已经尝试过这样的事情:
Formula1 = sum(sum(abs(double(A)-double(B))./(m*n), 1), 2); 但这不会产生任何错误。但是,这不是表示它的正确方法,因为没有包含if条件。问题区域是如何通过检查A == B和A != B来合并条件。
2. Formula2 ={ 1/ (m*n)} * sum { norm (A - B) / 255} * 100再次,这里也是所有维度的总和。我不知道如何形成矩阵范数。
Formula3 is ={ 1/ (m*n)} * sum {(A - B) / 255} * 100我像这样尝试过
C = double(sum(AB,3)); r =重塑(100 *(C / 255)/(m * n),[1 3])
但是有一个错误,说尺寸应该相同并且重塑不起作用。
回答:
对于Formula1 :
function r = Formula1(A,B) [m,n,d] = size(A); %# A and B must have the same dimension C = A ~= B; %# C has a 1 in every pixel that's different r = double(sum(C(:)))/(m*n); r = r/d; %# normalize by number of color planes ~=运算符检查不等式。 (:)将矩阵向量化,从而使我们能够计算所有维度上的总和。
对于Formula2 :
function r = Formula2(A,B) [m,n,d] = size(A); C = double(sum(AB, 3)); %# sum over the color planes C = C/d; %# normalize by number of color planes K = norm(C); %# or norm(C,1), norm(C,inf) etc. r = 100*(K/255)/(m*n); 在这里, sum(AB, 3)在彩色平面上求和,留下具有原始图像尺寸的2D矩阵。有几种矩阵规范,您可以在NORM (http://www.mathworks.com/help/techdoc/ref/norm.html)的文档中进行 (http://www.mathworks.com/help/techdoc/ref/norm.html)选择。
更多&回答... (https://stackoverflow.com/questions/3788543)