(1) 生成多元高斯隨機變量的matlab函數:mvnrnd
(2) 添加高斯白噪聲的matlab函數:awgn
(3) 圖像加Salt & Pepper noise, Gaussian noise, Poisson noise怎么加?matlab函數imnoise能實現這個功能,見我的電腦other\matlab 2007a\work\function\imnoise_YaleB,注意點:imnoise函數有說明,The mean and variance parameters for 'gaussian', 'localvar', and 'speckle' noise types are always specified as if the image were of class double in the range [0, 1]. 當然也可以用uint8,有顯示結果可知,如果直接用double型的0到255之間的數值是有問題的。
(4) 北航圖像課件:課件\課件7、8、9章(2012-6-12)\解壓后文件\第八章小波變換課件-5.ppt的P5,就是通過randn函數加入高斯噪音
(5) 文章:Sparsity preserving projections with applications to face recognition,該文5.1.1節有一句:Gaussian white noise with standard deviation 0.1。我的問題是高斯白噪聲的均值是多少呢,是零嗎?你們是不是用matlab函數 randn(0,0.1) 這樣實現的?搜索gmail, 關鍵詞"喬老師",20100703回復: 高斯白噪聲的均值為零,具體怎么加應該有很多方法,例如你說的用randn。
(6) CVPR 2020 Self-training with Noisy Student improves ImageNet classification: To noise the student, we use RandAugment data augmentation [18], dropout [75] and stochastic depth [37] during its training.
二:
2.1 圖像顯示imshow,imagesc
下面代碼摘錄至蔡登老師主頁http://www.zjucadcg.cn/dengcai/Data/Yale/images.html
The face image can be displayed in matlab with the following command lines:
%===========================================
faceW = 32;
faceH = 32;
numPerLine = 11;
ShowLine = 2;
Y = zeros(faceH*ShowLine,faceW*numPerLine);
for i=0:ShowLine-1
for j=0:numPerLine-1
Y(i*faceH+1:(i+1)*faceH,j*faceW+1:(j+1)*faceW) = reshape(fea(i*numPerLine+j+1,:),[faceH,faceW]);
end
end
imagesc(Y);colormap(gray);
%===========================================
2.2照片的處理(Matlab命令)
(1)A=imread('1.JPG');%見我的matlab教材P33
% imshow(rgb2gray(A));%將彩色圖片轉成黑白的
B = imresize(A,[250 250]);
imwrite(B,'2.JPG');
(2) imshow的問題:利用Ran He給我的FRGC/dataset10, 命令:load ImgData;imshow(reshape(data(:,20),64,64))。問題:產生不了人臉。
原因:是double型,要變成整型。
解決方案1:imshow(reshape(data(:,20),64,64),[])。
解決方案2:imshow(uint8(reshape(data(:,20),64,64)))。
注意點:不要將data都變成整型,因為后續處理還是要用double型的。
This is under the help of Zhenhua Chai。
20130410問Ran He, FRGC/dataset10,每個原始圖片是64*64,變成32*32,imresize函數要不要做特別設置,他講他都用默認的設置
圖像imshow出來后,可以通過impixelinfo命令來看具體的像素數值
imshow畫彩色圖片:見本機cifar-10-matlab\cifar-10-batches-mat
三:eigs和eig
eigs:Largest eigenvalues and eigenvectors of matrix. 只能求最大的六個特征值及對應的特征向量
eig: Eigenvalues and eigenvectors. 能求所有特征值和特征向量
問題:求解WPrime相對DPrime最大的幾個特征值對應的特征向量
仿照Deng Cai的LDA版本“version 3.0 --Dec/2011”的line 230-235和line 244-246
[eigvector, eigvalue] = eig(WPrime,DPrime);
eigvalue = diag(eigvalue);
[junk, index] = sort(-eigvalue);
eigvalue = eigvalue(index);
eigvector = eigvector(:,index);
for i = 1:size(eigvector,2)
eigvector(:,i) = eigvector(:,i)./norm(eigvector(:,i));
end
注意點:1、eigvalue = diag(eigvalue);這句不能省,因為eigvalue本身是對角矩陣。2、eigvector要歸一化
四:plot函數
電腦目錄:\Spectral Regression\kernel\show_time\Isolet.m 直接運行有問題,解決方案:畫出的圖點擊Edit -> Axes properties (注意不是選中Figure properties)-> More properties->Xlim下面 XTick,將1.5,2.5和3.5刪除就可以了
五:雜七雜八
class: 類型
a=12345.6789 % 給變量 a 賦數值標量
class(a) % 對變量 a 的類別進行判斷
例:A = [0/0 0/0];
方法:b = randperm(120); b = b(1:50); b = (b-1)*4;%the start position of each class
b = b+randi(4,1,50); % randi is recommended by Libing Wang
如何編程實現隨機正交矩陣?見哈希論文ITQ編程實現,先生成隨機矩陣,再SVD分解,取U矩陣即可