找回密码
 注册
关于网站域名变更的通知
查看: 363|回复: 3
打印 上一主题 下一主题

基于matlab四叉树图像分割

[复制链接]
  • TA的每日心情

    2019-11-19 15:32
  • 签到天数: 1 天

    [LV.1]初来乍到

    跳转到指定楼层
    1#
    发表于 2021-5-14 15:07 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

    EDA365欢迎您登录!

    您需要 登录 才可以下载或查看,没有帐号?注册

    x

    7 z+ n' [1 {9 u% u) H一、源代码+ y8 a4 L/ B2 e
    • %Reversible Data hiding using Quad tree decomposition and histogrma
    • %shifting
    • %using quad tree to increase the hiding capacity
    • clc;
    • clear all;
    • close all;
    • z=1;
    • %--------------------reading the image------------------------
    • b=imread('goldhill.jpg');
    • I=rgb2gray(b);
    • figure(1);
    • imshow(I);
    • title('original image');
    • [m,n]=size(I);
    • figure(2);
    • imhist(I);
    • title('histogram of original image');
    • %--------------------quadtree decomposition---------------------
    • mindim=4;
    • S = qtdecomp(I,@Split,mindim,@Predicate);
    • %-------------------showing the block representation------------
    • blocks = repmat(uint8(0),size(S));
    • for dim = [512 256 128 64 32 16 8 4 2 1];
    •   numblocks = length(find(S==dim));
    •   if (numblocks > 0)
    •     values = repmat(uint8(1),[dim dim numblocks]);
    •     values(2:dim,2:dim,:) = 0;
    •     blocks = qtsetblk(blocks,S,dim,values);
    •   end
    • end
    • blocks(end,1:end) = 1;
    • blocks(1:end,end) = 1;
    • figure(3);
    • imshow(blocks,[]);
    • title('decomposed image blocks');
    • %-------------------showing fullimage-----------------------------------
    • vals1 = repmat(uint8(0),size(S));
    • for dim = [512 256 128 64 32 16 8 4 2 1]
    •     [vals,r,c]=qtgetblk(I,S,dim);
    •     numblocks = length(find(S==dim));
    •    if (numblocks > 0)
    •     values = repmat(uint8(1),[dim dim numblocks]);
    •     values(2:dim,2:dim,:) = vals(2:dim,2:dim,1:numblocks) ;
    •     vals1 = qtsetblk(vals1,S,dim,values);
    •   end
    • end
    • figure(4);
    • imshow(vals1,[]);
    • title('decomposed image');
    • %----------------inputting the message/data to be hide---------------------
    • hide_data=input('Enter the data to be hide'); %for manual input
    • %cell_data=textread('myfile.txt', '%s', 'whitespace', ''); %reading data from text file
    • %hide_data=char(cell_data);
    • bin_data=convert_binary(hide_data);  %calling function to convert data to binary
    • binary_data=bin_data';
    • size_binary=size(binary_data,1)*size(binary_data,2);
    • bin=1;
    • a=1;
    • % %-------------------embedding data in the image blocks---------------------
    •    vals5 = repmat(uint8(0),size(S));
    •    pd=1;
    •    q=1;
    •    ind=1;
    •    rec_data(size_binary)=0;
    •    for h=1:size_binary
    •        rec_data(h)=0;
    •    end
    • for dim = [512 256 128 64 32 16 8 4 2 1]
    •     [vals2,r,c]=qtgetblk(I,S,dim);
    •     numblocks = length(find(S==dim));
    •     if (numblocks > 0)
    •       values = repmat(uint8(1),[dim dim numblocks]);
    •       values1 = repmat(uint8(1),[dim dim numblocks]);
    •       full_hideimage = repmat(uint8(1),[dim dim numblocks]);
    •       values(1:dim,1:dim,:) = vals2(1:dim,1:dim,1:numblocks) ;
    •       %full_hideimage(1:dim,1:dim,:)=vals2(1:dim,1:dim,1:numblocks);
    •       for i=1:size(values,3)
    •                     get_block=values(:,:,i);
    •                     newblock=values(:,:,i);
    •                     hide_image=values(:,:,i);
    •                     recover_block=values(:,:,i);
    •                     original=get_block;
    •                     l_block=length(get_block);
    •                     count(255)=0;
    •                     for h=1:255
    •                        count(h)=0;
    •                     end
    •                    for k=1:255
    •                       for l=1:l_block
    •                            for j=1:l_block
    •                                  if get_block(l,j)==k
    •                                     count(k)=count(k)+1;
    •                                 end
    •                            end
    •                       end
    •                    end
    •                     [C,max_point]=max(count);
    •                     [C1,min_point]=min(count);
    •                    for l=1:l_block
    •                        for j=1:l_block
    •                             if (get_block(l,j)>min_point)&&(get_block(l,j)<max_point)
    •                                 newblock(l,j)=get_block(l,j)+1;
    •                            elseif get_block(l,j)==(max_point+1)
    •                                 newblock(l,j)=get_block(l,j)+1;
    •                             else
    •                                 newblock(l,j)=get_block(l,j);
    •                             end
    •                        end
    •                    end
    •                 for l=1:l_block
    •                     for j=1:l_block
    •                         if (newblock(l,j)==max_point)
    •                               if  (bin<=size_binary)
    •                                    dat=binary_data(bin);
    •                                     if dat==dec2bin(1)
    •                                            hide_image(l,j)=newblock(l,j)+ 1;
    •                                     else
    •                                            hide_image(l,j)=newblock(l,j);
    •                                     end
    •                               else
    •                                 hide_image(l,j)=newblock(l,j);
    •                               end
    •                               bin=bin+1;
    •                         else
    •                         hide_image(l,j)=newblock(l,j);
    •                         end
    •                     end
    •                 end
    •                 full_hideimage(:,:,i)=hide_image;
    •       end
    •       %------------showing data hided image---------------
    •     values(1:dim,1:dim,1:numblocks)=full_hideimage(1:dim,1:dim,1:numblocks);
    •     vals5 = qtsetblk(vals5,S,dim,values);
    •     end
    • end
    • figure(5);
    • imshow(vals5,[]);
    • title('data hided image');' _( r% q" m& q1 Z+ u4 u
                         
    0 T, u1 e& F. ^# l7 S: e/ w( y7 F" k# j0 z
    二、运行结果
    4 J) y% [" ~9 ]  G3 E# J) L* D2 N# h8 A; C
    2 T5 E9 e' ^& x/ ~0 K5 J6 B

    # ^: N  j7 v+ T- c. n% j
    3 s# ?/ ?, |1 C! ~6 y$ p
    ! W0 G! G% \7 c
    3 }. o, w5 o9 C/ X

    该用户从未签到

    2#
    发表于 2021-5-14 16:25 | 只看该作者
    基于matlab四叉树图像分割
  • TA的每日心情
    慵懒
    2020-6-13 15:46
  • 签到天数: 1 天

    [LV.1]初来乍到

    3#
    发表于 2021-5-14 16:26 | 只看该作者
    基于matlab四叉树图像分割

    该用户从未签到

    4#
    发表于 2021-5-14 16:27 | 只看该作者
    基于matlab四叉树图像分割
    您需要登录后才可以回帖 登录 | 注册

    本版积分规则

    关闭

    推荐内容上一条 /1 下一条

    EDA365公众号

    关于我们|手机版|EDA365电子论坛网 ( 粤ICP备18020198号-1 )

    GMT+8, 2025-6-19 06:52 , Processed in 0.093750 second(s), 26 queries , Gzip On.

    深圳市墨知创新科技有限公司

    地址:深圳市南山区科技生态园2栋A座805 电话:19926409050

    快速回复 返回顶部 返回列表