In every paper i read about encryption they like to show the correlation coefficients of their encrypted image by showing 3 values:
Horizontal correlation coefficient .
vertical correlation coefficient.
diagonal correlation coefficient .
and they show these 3 values for encrypted image and also for plain image(lena).
My question is how to do this in matlab ? and if there is no matlab function for it , what are the equation they are using to get those 3 values ?
Table 2
Correlation coefficients of two adjacent pixels in two images
example:
Plain-image Ciphered image
Horizontal 0.92401 0.01589
Vertical 0.95612 0.06538
Diagonal 0.92659 0.03231
Any lead would be helpful , thanks
If I understood it correctly, you would like to perform a correlation analyis for pairs of pixels within a certain given image.
In principle I would go for the cov function: in your specific case, cov will retrieve a [2*2] symmetric matrix. The diagonal elements will represent your horizontal and vertical correlation coefficients, whereas the lower (upper) triangular elements will stay for the diagonal correlation coefficient.
I hope this will help you.
Related
I want to create a matrix that is: (1) a normally distributed complex matrix (2) will have a Gaussian envelope on the diagonal (A gaussian of some width sigma peaked at the diagonal terms and decays on the off diagonal terms).
The first part is quite simple using the randn command:
N=1000;
S = randn(N)+1i*randn(N);
However, I'm quite lost on how to apply the Gaussian envelope. Help would be much appreciated.
EDIT: I basically want to give the diagonal a shape of a Gaussian (it's real valued). Say the Gaussian's peak value is 1, then I want 1 on the diagonal and dropping values of the Gaussian on the off-diagonal ones.
I have two gridded matrix having latitude,longitude and time(180x360x12). I have calculated correlation coefficient between both matrices using following: http://in.mathworks.com/matlabcentral/answers/15884-correlation-for-multi-dimensional-arrays
now I want to find p-value (0.05) for each grid cell. than I want to set correlation values in matrix in three part: one will show positively significant (<0.05), second will show positively insignificant (>0.05) and third will show negatively significant (<0.05) correlation. Can anyone help me in this regard ?
If you use the scipy pearsonr function to calculate your correlations then this will give you the p values as well.
If cor are the correlations and p are the p-values then retrieving the significant values is then as simple as:
significant_correlations = corr[p<0.05]
I have a certain problem while implementing multivariate Gaussian distribution for anomaly detection.
I have referred the formula from Andrew Ng notes
http://www.holehouse.org/mlclass/15_Anomaly_Detection.html
below is the problem I face
Suppose I have a data set with 2 features and m number of training set i.e n=2 and wants to determine my multivariate Gaussian probability p(x;mu;sigma) which should be a [m*1] matrix because it produces estimated Gaussian value by feature correlation.
The problem I face is I am unable to use the formula to produce the matrix [m*1].
I am using Octave as IDE to develop the algorithm.
Below is a snapshot showcasing my problem
Considering the multiplication of the Red boundary equation because the LHS of the red boundary is just a real number
PLEASE HELP ME UNDERSTAND WHERE AM I GOING WRONG
Thanks
I think you got the dimensions wrong.
Let's assume you have a 2-dimensional (n=2) data of m instances. We can store this data as a n-by-m matrix in MATLAB (columns are data instances, rows represent features/dimensions). In this case we have:
X the data matrix of size nxm, each instance x = X(:,i) is a vector of size nx1 (column vector in our convention).
mu is the mean vector (mu = mean(X,2)). This is also a column vector of same size as an instance nx1.
sigma is the covariance matrix (sigma = cov(X.')). It has size nxn (it describes how each dimensions co-vary with each other dimension).
So the part that you highlighted in red involves expressions of the following sizes:
= ([nx1] - [nx1])' * [nxn] * ([nx1] - [nx1])
= [1xn] * [nxn] * [nx1]
= 1x1
I've got a set of training face images (40 images). Each image size is 28*34. From there, I'm able to get eigenVector, Score, Latent using princomp function in Matlab.
I've got 952 latents (eigenvalues in covariance matrix) which are in descending form : 4.2785 to 0 . Eigenvalues are zeros from k=40 onwards.
May i know what does the the eigenvalues indicate ? (say bigger value means more significant to variance?) how could I identify the best k value (Principal component)?
Thank you so much for your help !
Since you only have 40 input faces you cannot expect to have more than 40 principal components. Therefore the eigenvalue becomes zero for K=40 onwards.
To visualize your results, take the 40 leading eigen vectors, reshape them back to 28-by-34 and imagesc them. What have you got?
EigenValue of an eigenvector represents how important you eigenvector is.
Higher the Eigenvalue more important the eigentvector is
for 40 images the eigenvectors can not be more than 40
You can reconstruct the faces with the eigencvectors to visualize how it looks like
The eigenvector with highest eigenvalue is a principal component where most of the data lies
You can refer this link https://github.com/jayshah19949596/Computer-Vision/blob/master/EigenFaces/EigenFaces.ipynb ... This is a nice tutorial on EigenFaces
I try to calculate the correlation matrix of a set of histogram vectors. But the result is a truncated version of what I (think) I want. I have 200 histograms by 32 bins each. The result from
correlation_matrix = corrcoef(set_of_histograms)
is a 32 by 32 matrix.
I want to use this to calculate how my original histograms match up. (this by later using eigs and other stuff).
But which correlation method is right for this? I have tried "corrcoef" but there are "corr" and "cov" as well. Can't understand their differences by reading matlab help...
correlation_matrix = corrcoef(set_of_histograms')
(Note the ')
1) corrcoef treats every column as an observation, and calculates the correlations between each pair. I'm assuming your histograms matrix is 200x32; hence, in your case, every row is an observation. If you transpose your histograms matrix before running corrcoef, you should get the 200x200 result you're looking for:
[rho, p] = corrcoef( set_of_histograms' );
(' transposes the matrix)
2) cov returns the covariance matrix, not the correlation; while the covariance matrix is used in calculating the correlation, it is not the measure you're looking for.
3) As for corr and corrcoef, they have a few implementation differences between them. As long as you are only interested in Pearson's correlation, they are identical for your purposes. corr also has an option to calculate Spearman's or Kendall's correlations, which corrcoef does not have.