求 matlab 图像拼接程序
clear;
I=imread('xingshi32.bmp');
if(isgray(I)==0)
disp('请输入灰度图像,本程序用来处理 128 *128 的灰度图像!');
else
if (size(I)~=[128,128])
disp('图像的大小不合程序要求!');
else
H.color=[1 1 1]; %设置白的画布
figure(H);imshow(I);
title('原图像');
zeroImage=repmat(uint8(0),[128 128]);
figure(H); %为分裂合并后显示的图设置画布
meansImageHandle=imshow(zeroImage);
title('块均值图像');
%%%%%设置分裂后图像的大小由于本图采用了 128 像素的图
blockSize=[128 64 32 16 8 4 2];
%%设置一个 S 稀疏矩阵用于四叉树分解后存诸数据
S=uint8(128);
S(128,128)=0;
threshold=input('请输入分裂的阈值(0--1):');%阈值
threshold=round(255*threshold);
M=128;dim=128;
%%%%%%%%%%%%%%%%% 分裂主程序%%%%%%%%%%%
while (dim>1)
[M,N] = size(I);
Sind = find(S == dim);
numBlocks = length(Sind);
if (numBlocks == 0)
%已完成
break;
end
rows = (0:dim-1)';
cols = 0:M:(dim-1)*M;
rows = rows(:,ones(1,dim));
cols = cols(ones(dim,1),:);
ind = rows + cols;
ind = ind(:);