第一范文网 - 专业文章范例文档资料分享平台

DSP实验 (2)

来源:用户分享 时间:2020-06-22 本文由江畔旧时月 分享 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

代码(debuge—Halt停止运行)。单步运行或运行结束后选择View-Memory和View-Registers-CPU Registers/Peripheral Regs查看存储器和寄存器中的数据。如果最后的结果有错误,则应查找原因修改程序并重复步骤5 ~ 步骤8,直到结果正确为止。 四、实验结果

原程序运行结果:

软件仿真耗时,Cost:236.189285ms 硬件仿真耗时,Cost:198.438602ms 优化后程序运行结果:

软件仿真耗时,Cost:175.494308 ms

硬件仿真耗时,Cost:139.315048ms 最后优化的处理结果(图片) 原图像:

处理后的图像:

五、简要回答思考题

1、分析待优化函数主要耗时部分在哪里?

答:主要是在for循环部分耗时严重,合理优化for中的算法的运算部分,可以大大减少运算时间。 2、你是如何优化的?

答:修改for循环中算法部分,对原C语言程序进行C语言的优化。

六、优化程序 C语言优化程序:

/********************************************************************函数:convert_YUVtoH

功能:将yuv格式的图像数据转换到HSV中H空间 /************************************************************************/

void convert_YUVtoH (unsigned char * restrict p_Y, unsigned char * restrict p_U,unsigned char * restrict p_V, unsigned char * restrict p_H) {

float temp,hue_c;

unsigned char R , G , B,max ,min; unsigned char *p_u_temp,*p_v_temp; unsigned char *p_malloc1, *p_malloc2; unsigned char *p_temp1, *p_temp2;

int i,j ;

p_malloc1=(unsigned char *)malloc(width*height*sizeof(unsigned char)); p_malloc2=(unsigned char *)malloc(width*height*sizeof(unsigned char)); p_u_temp=p_malloc1; p_v_temp=p_malloc2;

/**-- zhuan huan cheng yuv444 format --- **/

for(i=0; i

{

p_temp1=p_U+width/2*(i/2); p_temp2=p_V+width/2* (i/2); for(j=0;j

*p_u_temp=*p_temp1; *(p_u_temp+1)=*p_temp1; *p_v_temp=*p_temp2;

*(p_v_temp+1)=*p_temp2;

p_temp1+=1; p_temp2+=1; p_u_temp+=2; p_v_temp+=2; } }

p_u_temp=p_malloc1; p_v_temp=p_malloc2;

#pragma MUST_ITERATE(101376, ,2) for(i=0;i

{

temp= (*p_Y)+((360*((* p_v_temp)-128))>>8); R=(temp>255)?255:temp;

temp= (*p_Y)-((88*((* p_u_temp)-128))>>8)-((183*((* p_v_temp)-128))>>8); G=(temp>255)?255:temp;

temp= (*p_Y)+((455*((* p_u_temp)-128))>>8);

B=(temp>255)?255:temp;

max=max_f(R,G,B); min=min_f(R,G,B);

if (R==max) hue_c = ((float)_abs(G-B))/(max-min); else if (G==max) hue_c = 2 + ((float)(B-R))/(max-min); else hue_c = 4 + ((float)(R-G))/(max-min) ; hue_c = hue_c* 60 ; if (hue_c< 0)

{hue_c = hue_c + 360 ; }

*p_H=(unsigned char) (hue_c*255/360); }

p_Y+=1;

p_u_temp+=1; p_v_temp+=1; p_H+=1;

free(p_malloc1); free(p_malloc2); }

搜索“diyifanwen.net”或“第一范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,第一范文网,提供最新幼儿教育DSP实验 (2)全文阅读和word下载服务。

DSP实验 (2).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/wenku/1095044.html(转载请注明文章来源)
热门推荐
Copyright © 2018-2022 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top