• 大小: 5KB
    文件类型: .m
    金币: 1
    下载: 0 次
    发布日期: 2021-05-06
  • 语言: Matlab
  • 标签: 小波变换  

资源简介

用matlab实现了小波变换对图像的分割

资源截图

代码片段和文件信息

close all;
clc;
clear all;
%%wavelet transform used to segment an image
 [FileName1PathName1] = uigetfile(‘*.jpg;*.tif;*.bmp;*.png‘‘请输入训练图像‘);%读入训练样本
 Im = fullfile(PathName1FileName1);
 Image= imread(Im);               %训练的原始图像,即网络的输入信号P
 subplot(231)imshow(Image);title(‘Original Image‘);
Image=Image(::1);
 Image=double(Image)
[MN]=size(Image);
w = 8*ones(1M/8);
h= 8*ones(1N/8);
B = mat2cell(Imagewh);
e=zeros(M/8N/8);
for i=1:M/8
    for j=1:N/8
        [cs]=wavedec2(B{ij}2‘db3‘); 
        ca1=appcoef2(cs‘db3‘1);
        ch1=detcoef2(‘h‘cs1);
        cv1=detcoef2(‘v‘cs1);
        cd1=detcoef2(‘d‘cs1);
        ca2=appcoef(cs‘db3‘2);
        ch2=detcoef2(‘h‘cs2);
        cv2=detcoef2(‘v‘cs2);
        cd2=detcoef2(‘d‘cs2);
        e_h1=sum(sum(ch1.^2));
        e_v1=sum(sum(cv1.^2));
        e_d1=sum(sum(cd1.^2));
        e_a2=sum(sum(ca2.^2));
        e_h2=sum(sum(ch2.^2));
        e_v2=sum(sum(cv2.^2));
        e_d2=sum(sum(cd2.^2));                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      

评论

共有 条评论