




版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、精選優(yōu)質(zhì)文檔-傾情為你奉上圖像篡改檢測(cè)Matlab源代碼說(shuō)明(1) 彩色圖像空間轉(zhuǎn)換代碼(RGB空間轉(zhuǎn)換為YUV空間)clc;clear all;close all;img = imread('3.jpg');%figure;imshow(img);title('原圖');img_5=img;img_ycbcr = rgb2ycbcr(img); % rgb->yuvfigure;subplot(121);imshow(img);title('原始圖像');subplot(122);imshow(img_ycbcr);title('
2、YUV空間圖');圖1 彩色圖像空間轉(zhuǎn)換(2)圖像分塊(分為16*16子塊)row,col,i=size(img_ycbcr);%對(duì)圖像進(jìn)行擴(kuò)展row_expand=ceil(row/16)*16; %行數(shù)上取整再乘16,及擴(kuò)展成16的倍數(shù)if mod(row,16)=0 %行數(shù)不是16的倍數(shù),用最后一行進(jìn)行擴(kuò)展 for i=row:row_expand img_ycbcr(i,:,:)=img_ycbcr(row,:,:); endendcol_expand=ceil(col/16)*16; %列數(shù)上取整if mod(col,16)=0 %列數(shù)不是16的倍數(shù),用最后一列進(jìn)行擴(kuò)展 fo
3、r j=col:col_expand img_ycbcr(:,j,:)=img_ycbcr(:,col,:); endend(3)對(duì)各個(gè)分量(Y,Cr,Cb)進(jìn)行離散余弦變換量化%對(duì)各分量進(jìn)行4:2:0采樣Y=img_ycbcr(:,:,1); %Y分量figure;subplot(231);imshow(Y);title('原Y分量');Cb=img_ycbcr(:,:,2); %Cb分量Cr=img_ycbcr(:,:,3); %Cr分量 Cb = zeros(row_expand/2,col_expand/2); Cr = zeros(row_expand/2,col_e
4、xpand/2);for i=1:row_expand/2 for j=1:2:col_expand/2-1 %奇數(shù) Cb(i,j)=double(img_ycbcr(i*2-1,j*2-1,2); Cr(i,j)=double(img_ycbcr(i*2-1,j*2+1,3); endendfor i=1:row_expand/2 %偶數(shù) for j=2:2:col_expand/2 Cb(i,j)=double(img_ycbcr(i*2-1,j*2-2,2); Cr(i,j)=double(img_ycbcr(i*2-1,j*2,3); endendsubplot(232);imshow
5、(uint8(Cb);title('原Cb分量'); %Cb分量subplot(233);imshow(uint8(Cr);title('原Cr分量'); %Cr分量Y_Table=16 11 10 16 24 40 51 61 12 12 14 19 26 58 60 55 14 13 16 24 40 57 69 56 14 17 22 29 51 87 80 62 18 22 37 56 68 109 103 77 24 35 55 64 81 104 113 92 49 64 78 87 103 121 120 101 72 92 95 98 112 1
6、00 103 99;%亮度量化表 CbCr_Table=17, 18, 24, 47, 99, 99, 99, 99; 18, 21, 26, 66, 99, 99, 99, 99; 24, 26, 56, 99, 99, 99, 99, 99; 47, 66, 99 ,99, 99, 99, 99, 99; 99, 99, 99, 99, 99, 99, 99, 99; 99, 99, 99, 99, 99, 99, 99, 99; 99, 99, 99, 99, 99, 99, 99, 99; 99, 99, 99, 99, 99, 99, 99, 99;%色差量化表Qua_Factor=
7、0.2;%量化因子%對(duì)Y分量進(jìn)行處理Qua_Matrix=Qua_Factor*Y_Table; %Y量化矩陣Y = blkproc(Y,8 8,'dct2(x)'); %DCT變換Y = blkproc(Y,8 8,'round(x./P1)',Qua_Matrix); %量化Y = blkproc(Y,8 8,'x.*P1',Qua_Matrix);%反量化Y= blkproc(Y,8 8,'idct2(x)');%反DCT變換subplot(234);imshow(uint8(Y);title('Y分量量化后'
8、;);%對(duì)Cb分量進(jìn)行處理Qua_Matrixcc=0.2*CbCr_Table; % Cb質(zhì)量因子選取為5,并不采用Qua_Factor的數(shù)值Cb = blkproc(Cb,8 8,'dct2(x)'); %DCT變換Cb = blkproc(Cb,8 8,'round(x./P1)',Qua_Matrixcc); %量化Cb = blkproc(Cb,8 8,'x.*P1',Qua_Matrixcc);%反量化Cb = blkproc(Cb,8 8,'idct2(x)');%反DCT變換subplot(235);imshow(
9、uint8(Cb);title('Cb分量量化后'); %對(duì)Cr分量進(jìn)行處理Qua_Matrixcc=0.2*CbCr_Table; %Cr質(zhì)量因子選取為5,并不采用Qua_Factor的數(shù)值Cr = blkproc(Cr,8 8,'dct2(x)'); %DCT變換Cr = blkproc(Cr,8 8,'round(x./P1)',Qua_Matrixcc); %量化Cr = blkproc(Cr,8 8,'x.*P1',Qua_Matrixcc);%反量化Cr = blkproc(Cr,8 8,'idct2(x)
10、39;);%反DCT變換subplot(236);imshow(uint8(Cr);title('Cr分量量化后');圖2 各個(gè)分量量化圖像(4)對(duì)各分量(Y,Cr,Cb)進(jìn)行二值化處理 %對(duì)Y分量處理%差分處理dh_Y = diff(Y,2);%水平差分dvt_Y = diff(Y); %縱向差分dv_Y= dvt_Y' %顯示功率譜密度f(wàn)s=1000;n=0:1/fs:1;nfft=1024;window=blackman(100);noverlap=20;range='half'pxx1,f=pwelch(dh_Y,window,noverlap,
11、nfft,fs,range);pxx2,f=pwelch(dvt_Y,window,noverlap,nfft,fs,range);plot_pxx1=10*log10(pxx1);plot_pxx2=10*log10(pxx2); figure,subplot(121);plot(f,plot_pxx1);title('水平功率譜密度');subplot(122);plot(f,plot_pxx2);title('垂直功率譜密度'); %計(jì)算功率譜密度dh1_Y= blkproc(dh_Y,8 8,'welch'); %水平方向差分圖像的區(qū)域功
12、率譜密度dv1_Y= blkproc(dv_Y,8 8,'welch'); %垂直方向差分圖像的區(qū)域功率譜密度b1_Y= blkproc(dh1_Y,513 1,'sum(x(:)');%水平方向差分圖像的區(qū)域功率譜密度總和b2_Y= blkproc(dv1_Y,513 1,'sum(x(:)');%垂直方向差分圖像的區(qū)域功率譜密度總和b_Y=b1_Y+b2_Y'%整幅圖像的區(qū)域功率譜密度總和 for i=1:size(b_Y,1) for j=1:size(b_Y,2) B_Y(i,j)=exp(log(sum(b_Y(i,j)+1)/
13、(sum(b_Y(i,j)+1);%整幅圖像塊效應(yīng)評(píng)價(jià) endend %二值化處理T=exp(1.5)*sum(sum(B_Y)/(row_expand/8)*(col_expand/8);%閾值c_Y=zeros(size(Y);for i=1:size(Y,1) for j=1:size(Y,2) if b_Y(ceil(i/8),ceil(j/8)>T c_Y(i,j)=1; end endendfigure;subplot(121);imshow(int8(b_Y); title('Y分量離散余弦系數(shù)圖');subplot(122);imshow(c_Y); ti
14、tle('Y分量二值圖像');圖3 Y分量離散余弦變換二值化圖像圖4 Cb分量離散余弦變換二值化圖像圖5 Cr分量離散余弦變換二值化圖像(5) 提取各個(gè)子圖特征function featureVec = GetBlockFeature(Block)featureVec=zeros(1,7); %特征數(shù)組,共設(shè)置7個(gè)特征R = Block(:,:, 1);G = Block(:,:, 2);B = Block(:,:, 3); %cl,c2, c3三個(gè)特征值featureVec(1)=mean2(R(:);featureVec(2)=mean2(G(:);featureVec(3
15、)=mean2(B(:); %c4.5.6.7四個(gè)特征值,Y通道公式Y(jié) = im2double(0.299 * R + 0.587 * G + 0.114 * B); %塊內(nèi)所有像素灰度之和totalGray = sum(Y(:); %c4sum_partI= sum(sum(Y(1 : 8,:);featureVec(4) = sum_partI / totalGray; %c5sum_partI = sum(sum(Y(:,1 : 8);featureVec(5) = sum_partI/ totalGray; %c6sumPart11 = 0.0;for r = 1 : 16 for c
16、 = r : 16 sumPart1 = sumPart11 + Y(r, c); endendfeatureVec(6)=sumPart1/totalGray; %c7sumPart11 = 0.0;for r = 1 : 16 for c = 1 : (16 - r + 1) sumPart1 = sumPart11 + Y(r, c); endendfeatureVec(7)= sumPart1 / totalGray;return;(6) 特征排序FeatureVecThresh =2.5,1.5,3.0,0.006,0.005,0.005,0.005;BlockDistThresh
17、= 10;BlockPairsNum = NumBlocks - 1 ;ShiftVectors = zeros(1,2);candidateSimilarPairs.indices = zeros(1,2);candidateSimilarPairs.frequence(1) = 0;features, indices = sortrows(Blocks.features);vi = 0;for i = 1 : NumBlocks - 1 ind1 = indices(i); ind2 = indices(i + 1); deltaCoord = Blocks.topLeft(ind1,:)
18、-Blocks.topLeft(ind2,:); deltaFeature = Blocks.features(ind1,:)-Blocks.features(ind2,:); pixelDist = norm(deltaCoord); %向景取模 if (pixelDist>BlockDistThresh) && (sum(abs(deltaFeature)<FeatureVecThresh) = 7) vi = vi + 1; candidateSimilarPairs.indices(vi, :)=ind1 ind2; ShiftVectors(vi,:) =
19、 Blocks.topLeft(ind1,:)-Blocks.topLeft(ind2,:); endend(7) 查找并刪除重復(fù)圖像塊SimilarPairs.indices=zeros(1,2);pairs.vector1=ShiftVectors(1,:); %第一行pairs.freq(1)=1;ind=1;for i=2:size(ShiftVectors,1); vec=ShiftVectors(i,:); isExist=false; for j=1:ind if norm(vec-pairs.vectorj)<2 pairs.freq(j)=pairs.freq(j)+1; isExist=true; break; end end if isExist ind=ind+1; pairs.vectorind=vec; pairs.freq(ind)=1; endendmax_freq, ma
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 四季之歌歌詞欣賞與英語(yǔ)表達(dá)教案
- 從一次失敗中得到的啟示話(huà)題作文(5篇)
- 沂源黨員考試試題及答案
- 儀表證考試試題及答案
- 醫(yī)院醫(yī)??荚囋囶}及答案
- 六一親子慶?;顒?dòng)方案
- 六一外賣(mài)活動(dòng)方案
- 醫(yī)學(xué)考試試題及答案參考
- 六一洗車(chē)公司活動(dòng)方案
- 六一活動(dòng)公司團(tuán)建活動(dòng)方案
- 網(wǎng)絡(luò)運(yùn)維計(jì)算機(jī)管理論文(論文)
- 面試評(píng)分表(學(xué)生會(huì))
- 小學(xué)語(yǔ)文教師選調(diào)進(jìn)城考試試題4套(附答案)
- 《高中政治選修3》17.聯(lián)合國(guó):最具普遍性國(guó)際組織
- GB/T 5288-2007龍門(mén)導(dǎo)軌磨床精度檢驗(yàn)
- GB/T 4990-2010熱電偶用補(bǔ)償導(dǎo)線(xiàn)合金絲
- GB/T 3778-2011橡膠用炭黑
- 檢驗(yàn)科梅毒快速檢測(cè)室內(nèi)質(zhì)控記錄本
- GB/T 1931-1991木材含水率測(cè)定方法
- GB/T 1094.2-2013電力變壓器第2部分:液浸式變壓器的溫升
- 運(yùn)動(dòng)改造大腦 課件
評(píng)論
0/150
提交評(píng)論