数字图像处理滤波的问题,要详细过程

数字图像处理滤波的问题,要详细过程,第1张

%原图像

I = [1 2 1 4 3 ;

1 10 2 3 4 ;

5 2 6 8 8;

5 5 7 0 8;

5 6 7 8 9];

x=double(I);

x1=x;

for i=2:4

for j=2:4

c=x(i-1:i+1,j-1:j+1); %取出3x3邻域

c=[ c(1,:) c(2,:) c(3,:)]; %整理成一行

m=median(c); %mm是中值

x1(i,j)=m; %中值赋给中心元素

end

end

x1

%为了计算边缘像素,将原图像扩展为6x6填充0

I = [0 0 0 0 0 0 0;

0 1 2 1 4 3 0;

0 1 10 2 3 4 0;

0 5 2 6 8 8 0;

0 5 5 7 0 8 0;

0 5 6 7 8 9 0;

0 0 0 0 0 0 0 ];

x=double(I);

%加权均值滤波3x3模板

a = [ 1 1 1;1 2 1; 1 1 1]/10;

for i=2:5

for j=2:5

c=x(i-1:i+1,j-1:j+1)a; %与模板相乘

x2(i,j)=sum(sum(c))/9; %计算均值并赋值给像素(i,j)

end

end

x2 = x2(2:5,2:5)

clear;

close all;

I = imread('eighttif');

J = imnoise(I,'salt & pepper',002);

K = medfilt2(J);

imshow(J);title('噪声干扰图像')

figure, imshow(K);title('medfilt2滤波图像')

X=J;a=2;b=2;

k=floor(ab/2)+1;

[M,N]=size(X);

uint8 Y=zeros(M,N);

funBox=zeros(a,b);

temp=zeros(ab);

for i=1:M-a

for j=1:N-b

funBox=X(i:i+a,j:j+b);

temp=funBox(:);

tempSort=sort(temp);

Y(i,j)=tempSort(k);

end;

end;

figure, imshow(Y);title('自编程序滤波图像')

clear;

close all;

c=imread('123png'); %把彩色转化成灰度,256级

figure,imshow(c),title('原始图象'); %显示原始图象

g=imnoise(c,'gaussian',01,0002); %加入高斯噪声

figure,imshow(g),title('加入高斯噪声之后的图象'); %显示加入高斯噪声之后的图象

%实验步骤二:用系统预定义滤波器进行均值滤波

n=1;

A=fspecial('average',n);%生成系统预定义的3X3滤波器

Y=filter2(A,g)/255; %用生成的滤波器进行滤波,并归一化

figure,imshow(Y),title('系统函数滤波图像'); %显示滤波后的图象

a(1:n,1:n)=1; %a即n×n模板,元素全是1

p=size(g); %输入图像是p×q的,且p>n,q>n

x1=double(g);

x2=x1;

%A(a:b,c:d)表示A矩阵的第a到b行,第c到d列的所有元素

for i=1:p(1)-n+1

for j=1:p(2)-n+1

c=x1(i:i+(n-1),j:j+(n-1))a; %取出x1中从(i,j)开始的n行n列元素与模板相乘

s=sum(sum(c)); %求c矩阵(即模板)中各元素之和

x2(i+(n-1)/2,j+(n-1)/2)=s/(nn); %将模板各元素的均值赋给模板中心位置的元素

end

end

%未被赋值的元素取原值

d=uint8(x2);

%实验步骤三:用自己的编写的函数进行均值滤波

%调用自编函数进行均值滤波,n为模板大小

figure,imshow(d),title('自编程序滤波图像'); %显示滤波后的图象

Introduction

Image enhancement is the process of making an image more interpretable for a particular application The techniques are often used instead of classification techniques for feature extraction

Display vs File Enhancement

Image enhancement may be performed:

• temporarily, upon the image that is displayed in the Viewer

• permanently, upon the image data in the data file

Enhancing a displayed image is much faster than enhancing an image on disk

Spatial Modeling Enhancements(基于组件应用建模)

• Graphical models(实习中有练习)

Correcting Data

Each generation of sensors shows improved data acquisition and image quality over previous generations However, some anomalies still exist that are inherent to certain sensors and can be corrected by applying mathematical formulas derived from the distortions In addition, the natural distortion that results from the curvature and rotation of the Earth in relation to the sensor platform produces distortions in the image data, which can also be corrected

Generally, there are two types of data correction: radiometric and geometric

这些辐射改正和几何改正(非10章之精校正)通常由卫星接收站完成。

Radiometric Enhancement(辐射增强)

Radiometric enhancement deals with the individual values of the pixels It differs from spatial enhancement (discussed in “Spatial Enhancement”), which takes into account the values of neighboring pixels

Radiometric enhancements that are applied to one band may not be appropriate for other bands

简明地说:辐射增强用不涉及像元邻域性的统一变换关系来改变某个波段的 pixel value,。

Histograms concept(我加的小标题)

横坐标:pixel value(0-255);

纵坐标:某像元值出现的Frequency

直方图是图像最基本的统计数据,它体现图的“调子”(明暗色调反差)。

Contrast Stretching

When radiometric enhancements are performed on the display device, the transformation of data file values into brightness values is illustrated by the graph of a lookup table

Histograms和graph of a lookup table是分析辐射增强最有用的两种图。

Linear and Nonlinear

The terms linear and nonlinear, when describing types of spectral enhancement, refer to the function that is applied to the data to perform the enhancement A piecewise linear stretch uses a polyline function to increase contrast to varying degrees over different ranges of the data, as in Figure 6-3

Linear Contrast Stretch

Figure 4-5 就是用一种线性变换来进行反差拉伸。

注意149页底部有ERDAS提示:A two standard deviation linear contrast stretch is automatically applied to images displayed in the Viewer

Histogram Equalization(直方图均衡化)

A nonlinear stretch that redistributes pixel values so that there is approximately the same number of pixels with each value within a range The result approximates a flat histogram

See figure 6-7

(补充:方法来源:累积直方图曲线作为变换关系。)

The resulting histogram is not exactly flat 因为实际制作Histogram Equalization软件,是用差分代替微分(——教材中的Bin)

又:评论:最增强反差的方法,但并不等于效果最好。

Histogram Matching(直方图匹配)

Histogram matching is the process of determining a lookup table that converts the histogram of one image to resemble the histogram of another Histogram matching is useful for matching data of the same or adjacent scenes that were scanned on separate days, or are slightly different because of sun angle or atmospheric effects This is especially useful for mosaicking or change detection(后者指比较同区域两图以发现变化)

To achieve good results with histogram matching, the two input images should have similar characteristics:

• The general shape of the histogram curves should be similar

• Relative dark and light features in the image should be the same

• For some applications, the spatial resolution should be the same

• The relative distributions of land covers should be about the same

(补充:方法来源:用二者的累积直方图曲线两次变换)

Brightness Inversion

The brightness inversion functions produce images that have the opposite contrast of the original image

Spatial Enhancement(空间增强)

While radiometric enhancements operate on each pixel individually, spatial enhancement modifies pixel values based on the values of surrounding pixels

Spatial enhancement deals largely with spatial frequency, which is the difference between the highest and lowest values of a contiguous set of pixels

See Figure 6-11

Convolution Filtering (卷积过滤)

The process of averaging small sets of pixels across an image It is used to change the spatial frequency characteristics of an image

A convolution kernel(卷积模板) is a matrix that is used to average the value of each pixel with the values of surrounding pixels in a particular way The numbers (often called coefficients) in the matrix serve to weight this average toward particular pixels

Convolution filtering is one method of spatial filtering

See Figure 6-12

convolution相当于上学期GIS课中讲过的Moving windows 活动窗口法之移动平均法。

下面讲三种类型的Kernel:

Low-Frequency or low-pass Kernels

(讲义上放在后的第三种Kernels,这里提到前面先讲 )

This kernel simply averages the values of the pixels, causing them to be more homogeneous The resulting image looks either more smooth or more blurred, decreases spatial frequency

(补充:两种常用的 Low-Frequency Kernels——均值滤波和中值滤波,前者即滑动平均,后者取模板覆盖的像元值大小排列的中间像元的值。利用中值滤波可滤掉某些像元值异常的点。)

Zero-Sum Kernels

Zero-sum kernels are kernels in which the sum of all coefficients in the kernel equals zero

This generally causes the output values to be:

• zero in areas where all input values are equal (no edges)

• low in areas of low spatial frequency

• extreme in areas of high spatial frequency

Therefore, a zero-sum kernel is an edge detector

The resulting image often consists of only edges and zeros

几种常用的 Zero-Sum Kernels例:

罗伯特算子: 索伯尔算子 拉普拉斯算子

Zero-sum kernels can be biased to detect edges in a particular direction

其它方向的探测,如:

High-Frequency or high-pass Kernels

It has the effect of increasing spatial frequency and serves as edge enhancers Unlike edge detectors, they highlight edges and do not necessarily eliminate other features

When this kernel is used on a set of pixels, the relative low value gets lower, the relative high value becomes higher

See example of text (page 160-161)

补充: How to derove high-pass Kernels ——某种算子与原图叠加

1、原图“减”拉普拉斯算子

拉普拉斯算子:(左-自)-(自-右)+(上-自)-(自-下)

即:

原图减拉普拉斯算子:

2、原图 + 原图减滑动平均

两原图减滑动平均:

Crisp

The Crisp filter sharpens the overall scene luminance without distorting the interband variance content of the image This is a useful enhancement if the image is blurred

在后面讲解主成分变换(Principal Component or PC)方法后回头来理解此段。

Wavelet Resolution Merge

low spatial resolution to be sharpened using a co-registered panchromatic image of relatively higher resolution A primary intended target dataset is Landsat 7 ETM+ Increasing the spatial resolution of multispectral imagery in this fashion is, in fact, the rationale behind the Landsat 7 sensor design

Aside from traditional Pan-Multispectral image sharpening, this algorithm can be used to merge any two images, for example, radar with SPOT Pan Fusing information from several sensors into one composite image can take place on four levels; signal, pixel, feature, and symbolic This algorithm works at the pixel level

Wavelet Theory

Wavelet-based image reduction is similar to Fourier transform analysis In the Fourier transform, long continuous (sine and cosine) waves are used as the basis The wavelet transform uses short, discrete “wavelets” instead of a long wave Thus the new transform is much more local The wavelet can be parameterized as a finite size moving window

(165和168页只要知道可通过小波变换可进行不同分辨率图像的融合就行)

Algorithm Theory

Spectral Enhancement(多光谱变换)

The techniques require more than one band of data

处理思路(英文讲义上未解释):

辐射增强和空间增强对一个波段或其局部进行变换,多光谱变换则对多波段图像的整体进行变换。具体方法与GIS课中所讲空间统计分析类似。

假定有n个变量、m个样点数据,则可组成一个n行、m列的数据矩阵:

具有各自地理位置的 样点1 样点2 …… 样点j …… 样点m

空间变量 X1

X2

Xi

Xn x11 x12 …… x1j …… x1m

x21 x22 …… x2j …… x2m

xi1 xi2 …… xij …… xim

xn1 xn2 …… xnj …… xnm

同样,我们这里将每一波段视为一维变量,将多波段图像视为多维空间,采用多维空间线性变换的方法,形成新的多维变量,即新的多波段图像。假定图像有m波段,每波段K列L行,共n个像元(n = KL)则m波段图像组成m维向量矩阵:

不少人对多光谱变换概念模糊就是因为将此矩阵与图像本身矩阵相混淆,多光谱空间概念对下章讲分类提取也很重要。

Spectral Enhancement 就是利用一个变换矩阵A,将原图像(矩阵X)变换为一个新的多维变量或多波段图象(矩阵Y)。即:Y = AX,或

下面讲述几种多光谱变换的方法

Principal Components Analysis (PCA,主成分分析)

This is often used as a method of data compression It allows redundant data to be compacted into fewer bands—that is, the dimensionality of the data is reduced The bands of PCA data are noncorrelated and independent, and are often more interpretable than the source data补充:有关统计概念

n

Variance = [ ∑(xip-mxi) 2 ] /n-1(第i波段第p像元)

P=1

方差是信息丰富程度的一种度量。

n

Covariance = [ ∑(xip-mxi) (xjp-mxj) ]/n-1

P=1

协方差能体现变量间相似性或重复性,是信息冗余程度的一种度量。

为此,协方差矩阵与直方图一样,成为图像处理中的一个基本分析数据和工具。

COV =

式中,V ij为第 I 波段与第 j 波段之间的协方差。

例:TM图像fj2的协方差矩阵为

1 2 3 4 5 6 7

1 87431 50610 84522 18195 96021 35029 80202

2 50610 32399 53773 23158 74913 22151 54773

3 84522 53773 93785 30101 127842 36951 95805

4 18195 23158 30101 183716 191943 20116 65046

5 96021 74913 127842 191943 389152 62380 198104

6 35029 22151 36951 20116 62380 27646 43380

7 80202 54773 95805 65046 198104 43380 127426

问题:哪波段信息量最大(小)?哪两波段间信息冗余最大(小)?

主成分分析旨在寻求一个矩阵变换Y = AX,使所得新图像Y的协方差矩阵为:

式中,V11 > V 22 >…… > V mn,即新图像Y的各波段间的协方差为零,集中了图像大多数方差的前几个波段,分别称为PC1(第一主成分)、PC2、PC3…

线性代数表明,以m个特征向量组成的mm方阵,作为变换矩阵A,即可达到上述目的,且变换中新旧图像Y和X的方差总量不变。

以上就是关于数字图像处理滤波的问题,要详细过程全部的内容,包括:数字图像处理滤波的问题,要详细过程、用MATLAB分别写中直滤波和均值滤波程序,要求不用函数!老师布置的作业,明天交 谢谢、均值滤波器在labwindows/CVI中的应用等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/zz/9509737.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-29
下一篇2023-04-29

发表评论

登录后才能评论

评论列表(0条)

    保存