首页 > 解决方案 > Matlab中图像的提取

问题描述

我是 Matlab 的新手,尝试嵌入水印,我成功了。现在,在提取中,我无法正确取回它。

    function [ eximage ] = watermark_extract( Y,Y_ex )
    host=double(Y);
    ln = size(host,1);         %the length of the image 
    hqln = ln/4;               %the length of half of the middle quarter
    % mqNo = (hqln/4)^2;       %Number of middle quarter 8 x 8 squares
    LU = ln/2-hqln+1;          %the location of the left and upper side of the middle quarter
    RL = ln/2+hqln;            %the location of the right and lower side of the middle quarter
    ex=double(Y_ex);
    ln_ex = size(ex,1);         %the length of the embedded image 
    hqln_ex = ln_ex/4;               %the length of half of the middle quarter
    % mqNo = (hqln/4)^2;       %Number of middle quarter 8 x 8 squares
    LU_ex = ln_ex/2-hqln+1;          %the location of the left and upper side of the middle quarter
    RL_ex = ln_ex/2+hqln;
    counter = 0;
    for s = LU:8:RL
      for t= LU:8:RL
          ho=host(s:s+7,t:t+7);
          host1= blkproc(ho,[8,8],@dct2);%at location 5,2 dct 2 is applied to get the dct coefficients of     host image
          h(counter*4+1) = host1(5,2);  
     end
   end
   wm=[]; 
   w=1; wm=ex; 
   for i = LU_ex:8:RL
     for j= LU_ex:8:RL
         d = ex(i:i+7,j:j+7); %
         ex1 = blkproc(d,[8,8],@dct2); %at location 5,2 dct 2 is applied to get the dct coefficients of embedded or watermarked image
         e(counter*4+1) = ex1(5,2);
     end
    end
    alpha=0.02; 
    for rw=1:32 
     for co=1:32 
         if  ne(ex1(5,2),host1(5,2))
                  wm(rw,co)=0;
         else
                  wm(rw,co)=1;
         end            
     end
    end
    eximage=blkproc(wm,[8 8],@idct2);% inverse of dct top get back the image
  end

我在主机图像中心的 5,2 位置嵌入了一个水印,并应用了 32x32 二进制图像。我在这里想念什么?

标签: matlabimage-processing

解决方案


推荐阅读