【图像分割】基于四叉树图像分割matlab源码

 

 

%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)

【图像分割】基于四叉树图像分割matlab源码_第1张图片

【图像分割】基于四叉树图像分割matlab源码_第2张图片

完整代码添加QQ1575304183

往期回顾>>>>>>

【图像识别】基于cnn卷积神经网络之验证码识别matlab源码

【图像识别】基于svm植物叶子疾病检测和分类

【图像识别】路面裂缝识别含GUI源码

【图像识别】基于RGB和BP神经网络的人民币识别系统含GUI界面

【图像识别】条形码识别系统

【图像识别】基于不变矩的数字验证码识别含GUI界面

【图像识别】基于贝叶斯分类器之目标识别matlab源码

【图像识别】身份证号码识别matlab源码

【图像分割】基于四叉树图像分割matlab源码

【图像聚类】基于FCM和改进的FCM脑部CT图像聚类处理

【图像增强】PSO寻优ACE的图像增强matlab源码

【图像增强】基于区域相似变换函数和蜻蜓算法的灰度图像增强

【图像增强】基于局部对比度增强的CLAHE算法 --直方图增强
【图像处理】图像重建之ASTRA算法matlab源码

【图像处理】基于CCF算法的图像质量评价

【图像加密】基于混沌系统的图像加密解密matlab源码含GUI

【图像处理】基于DWT+DCT+PBFO改进图像水印隐藏提取matlab源码含GUI

【图像配准】基于sift算法的图像配准matlab源码

【图像分割】基于随机游走算法的图像分割matlab源码

【图像滤波】图像二维双边高斯滤波

【图像去噪】基于自适应形态学的图像去噪

【图像重建】图像重建之ASTRA算法

你可能感兴趣的:(matlab,图像处理,四叉树)