DSP实验报告
一、 图像的锐化处理(高通滤波处理)
1、 实验原理
处理模板如下:
0M1400 0.25 0对应数学表达式:
g(x,y)14f(x,y)f(x1,y)f(x,y1)f(x1,y)f(x,y1)
2、 C程序及运行结果
程序:
Acute_RGB_Image(int *buffer) {
int x,y;
for (y=0;y if(buffer[ImageWidth*y+x]>255) buffer[ImageWidth*y+x]=255; else if (buffer[ImageWidth*y+x]<0) buffer[ImageWidth*y+x]=0; } } 运行结果: 锐化前 锐化后 分析:从上面两幅图可以看出锐化后的图像轮廓变得明显,且噪声变得强烈。 3、 汇编程序及运行结果 程序: ImageAcuteSub(ImageWidth,ImageHeight,buffer_red); ImageAcuteSub(ImageWidth,ImageHeight,buffer_green); ImageAcuteSub(ImageWidth,ImageHeight,buffer_blue); .mmregs .def _ImageAcuteSub .text _ImageAcuteSub: mov t0,brc1 ;IMAGE WIDTH mov t1,brc0 ;IMAGE HEIGHT rptb y_loop rptb x_loop mov *ar0(#1),ac1;f(x+1,y) add *ar0(#-1),ac1 ;f(x-1,y) add *ar0(#-250),ac1 ;f(x,y-1) add *ar0(#250),ac1 ;f(x,y+1) sfts ac1,#-2 mov *ar0<<#1,ac0;2f(x,y) sub ac1,ac0 bcc branch1,ac0<0 sub #255,ac0,ac1 bcc branch2,ac1>0 mov ac0,*ar0+ b x_loop branch1: mov #0,*ar0+ b x_loop branch2: mov #255,*ar0+ x_loop: nop y_loop: nop RET 运行结果: 锐化前 锐化后 分析:可以看出汇编的结果和C程序的结果是一致的。 二、 图像的边缘检测 1、 实验原理 x方向和y方向的梯度分别为: 11101111101f000 fx y 33101111总梯度幅度 ffxfy|fx|1,y1)f(x1,y)f(x1,y1)f(x1,y1)f(x1,y)f(x1,y1)3f(x1f(x1,y1)f(x,y1)f(x1,y1)f(x1,y1)f(x,y1)f(x1,y1)|fy|131g(x,y)0iffTelse 实验中的阈值设为120。 2、 C程序及运行结果 程序: Edge_Grey_Image() { int x,y; int delta_x,delta_y; for (y=0;y delta_y=abs(buffer_grey[ImageWidth*(y-1)+x-1]+buffer_grey[ImageWidth*(y-1)+x]+buffer_grey[ImageWidth*(y-1)+x+1]-buffer_grey[ImageWidth*(y+1)+x-1]-buffer_grey[ImageWidth*(y+1)+x]-buffer_grey[ImageWidth*(y+1)+x+1])/3; if((delta_x+delta_y)>=Threshhold) buffer_org[ImageWidth*y+x]=255; else buffer_org[ImageWidth*y+x]=0; } } 运行结果: 边缘处理前 边缘处理后 分析:从上面两幅图可以看出,原图像的边缘经过处理后可以很好的用白线来 勾勒出,没有边缘的地方都用黑色表示,可以很清楚的从处理后的图片看出斑马的形状。 3、 汇编程序及运行结果 程序: ImageEdgeSub(ImageWidth,ImageHeight,buffer_org); .mmregs .def _ImageEdgeSub .bss TEMP,1 .text _ImageEdgeSub: mov t0,BRC1 mov t1,BRC0 mov xar0,ac3 mov #256<<#11,ac2 mov ac2,xar1 RPTB Y_LOOP RPTB X_LOOP mov *ar0+,*ar1+;将ar0的内容复制到ar1里面 X_LOOP: nop Y_LOOP: nop mov t0,brc1 ;IMAGE WIDTH mov t1,brc0 ;IMAGE HEIGHT mov ac2,xar1 mov ac3,xar0 rptb y_loop rptb x_loop mov *ar1+,ac0 mov *ar1(#-149),ac0;f(x+1,y-1) add *ar1(#1),ac0 ;f(x+1,y) add *ar1(#151),ac0 ;f(x+1,y+1) sub *ar1(#-151),ac0;f(x-1,y-1) sub *ar1(#-1),ac0 ;f(x-1,y) sub *ar1(#149),ac0;f(x-1,y+1) abs ac0 mov *ar1(#-151),ac1 ;f(x-1,y-1) add *ar1(#-150),ac1 ;f(x,y-1) add *ar1(#-149),ac1 ;f(x+1,y-1) sub *ar1(#149),ac1 ;f(x-1,y+1) sub *ar1(#150),ac1 ;f(x,y+1) sub *ar1(#151),ac1 ;f(x+1,y+1) abs ac1 add ac1,ac0 call DIVION sub #120,ac0,ac0 bcc branch1,ac0>0 mov #0,*ar0+ b x_loop branch1: mov #255,*ar0+ x_loop: nop y_loop: nop RET DIVION: amov #080000h,XAR7 mov #3,*ar7 mov #16,t0 mov ac0,ac1 branch2: subc *ar7,ac1,ac2 mov ac2,ac1 sub #1,t0 bcc branch2,t0>0 mov ac1,t1 mov t1,ac0 RET 运行结果: 边缘处理前 边缘处理后 分析:可以看出汇编的结果和C程序的结果是一致的。 因篇幅问题不能全部显示,请点此查看更多更全内容
Copyright © 2019- sarr.cn 版权所有 赣ICP备2024042794号-1
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务