#include <math.h>
# include<stdio.h>
# include<system.h>
# include<string.h>
# include<stdlib.h>
# include<unistd.h>
#include "unistd.h"
#include <malloc.h>
//#include "altera_avalon_pio_regs.h"
#include "alt_types.h"
#include "sys/alt_irq.h"
#include "sys/alt_timestamp.h"
#include "altera_avalon_timer.h"
#include <stdlib.h>
#include <float.h>
#include <stdio.h>
#include <system.h>
#include "altera_avalon_pio_regs.h"
#include "altera_avalon_uart_regs.h"
#include "altera_avalon_uart.h"
#include "alt_types.h"
#include "sys/alt_irq.h"
#include "sys/alt_timestamp.h"
#include "altera_avalon_timer.h"
#define RS232_BASE 0xc000020
#define width 256
#define length 256
#define size 65536
#define r 11
#define threshold 5000
int Ix[length][width],Ixb[length][width];
int Iy[length][width],Iyb[length][width];
int Ix2[length][width],Ix2b[length][width];
int Iy2[length][width],Iy2b[length][width];
int Ixx[length][width],Ixxb[length][width];
int Iyy[length][width],Iyyb[length][width];
int Ixy[length][width],Ixyb[length][width];
float Ixy2[length][width],Ixy2b[length][width];
float Ixx2[length][width],Ixx2b[length][width];
float Iyy2[length][width],Iyy2b[length][width];
float Ixxyy[length][width],Ixxyyb[length][width];
float Ixxyy2[length][width],Ixxyy2b[length][width];
float Ixxyysqr[length][width],Ixxyysqrb[length][width];
float B[length][width],Bb[length][width];
float A[length][width],Ab[length][width];
float cim[length][width],cimb[length][width];
float Ixy22[length][width],Ixy22b[length][width];
int indcount=0,count1=0,count2=0,counts1=0,counts2=0,count3=0,count4=0;
int r1[332],c1[332],r2[332],c2[332];
int a=50,b=343,c=2537;
float tps1,tps2,tps3,tps4,tps5,tps6;
alt_u32 freq,cycle0,cycle1,cycle2,cycle3,cycle4,cycle5,cycle6;
int i=0,j=0,k1,k2,i1=0,e1=0,e2=0,i2=0,j2=0,f,h,n1,m1,diff2=0,sumdiff2=0,diff=0,sumdiff=0,ss=-1,zz=-1;
int imshow;
/**************************************/
/* Introduir des fonctions */
/*____________________________________*/
void delay()
{int i=1000;
while (i>0)
{
i--;
}
}
int main()
{ FILE* fp;
fp=fopen("/dev/rs232","r");
printf("salam (^_^)\n");
unsigned char donns_ins[4],fc[4];
float im1g[length][width], im2g[length][width];
int i=0,j=0,ad=0;
for(i=0;i<256;i++)
{
for(j=0;j<256;j++)
{
fread(donns_ins,1,4,fp);memcpy(&im1g[i][j],donns_ins,4);//printf("im1g=%f\t",im1g[i][j]);
fread(donns_ins,1,4,fp);memcpy(&im2g[i][j],donns_ins,4);//printf("im1g=%f\t",im2g[i][j]);
}
printf("im1g=%f\n",im1g[i][j]);
}
////// Part of Data Aquiring ///////////////////////////////////////////////////////////
////////////////////////////////////////////////////////
// Shape the 3 matrices RGB1
alt_timestamp_start(); // Start Timer
freq=alt_timestamp_freq();
//printf (" Freq par sec : %d \n\r",freq);
cycle1= alt_timestamp();
// E:\LATI 2015\matlab tests\correlation_matching
////////////////////////////////////////////////////////////
/////////// PART OF Images PROCESSING /////////////////////////////////
//Step1 : Computing the gradiants (Ix,Iy) for the 2 images
for(i=1;i<(length-1);i++)
{
for(j=1;j<(width-1);j++)
{
Ix[i][j]=im1g[i-1][j-1]-im1g[i-1][j+1]
+im1g[i][j-1]-im1g[i][j+1]
+im1g[i+1][j-1]-im1g[i+1][j+1]; //// 5 +
Ixb[i][j]=im2g[i-1][j-1]-im2g[i-1][j+1]
+im2g[i][j-1]-im2g[i][j+1]
+im2g[i+1][j-1]-im2g[i+1][j+1]; //// 5 +
Iy[i][j]=im1g[i-1][j-1]-im1g[i+1][j-1]
+im1g[i-1][j]-im1g[i+1][j]
+im1g[i-1][j+1]-im1g[i+1][j+1]; //// 5 +
Iyb[i][j]=im2g[i-1][j-1]-im2g[i+1][j-1]
+im2g[i-1][j]-im2g[i+1][j]
+im2g[i-1][j+1]-im2g[i+1][j+1]; //// 5 +
}
}
//printf( " Gradiants Ix,Iy are computed correctly \n");
cycle2= alt_timestamp();
//printf (" Needed cycle number to aquire image 2 is %d \n",cycle2-cycle1);
tps2= ((cycle2-cycle1)/(float) freq);
printf (" time to compute Gradiants Ix,Iy is %f \n",tps2);
///////////////////////////////////////////////////////////////////////
//Step2 : Computing the square of gradiants (Ix,Iy) for the 2 images
for(i=1;i<(length-1);i++)
{
for(j=1;j<(width-1);j++)
{
Ix2[i][j]=Ix[i][j]*Ix[i][j]; //// 1 *
Ix2b[i][j]=Ixb[i][j]*Ixb[i][j]; //// 1 *
Iy2[i][j]=Iy[i][j]*Iy[i][j]; //// 1 *
Iy2b[i][j]=Iyb[i][j]*Iyb[i][j]; //// 1 *
}
}
/////////////////////////////////////////////////////////////////////////
printf( " Gradiants Ix2,Iy2 are computed correctly \n");
//printf( " Gradiants Ix,Iy are computed correctly \n");
cycle3= alt_timestamp();
//printf (" Needed cycle number to aquire image 2 is %d \n",cycle2-cycle1);
tps3= ((cycle3-cycle2)/(float) freq);
printf (" time to compute Gradiants Ix2,Iy2 is %f \n",tps3);
////////////////////////////////////////////////////////////////////////
//Step3 : Smoothing the square of gradiants (Ix,Iy) with Guaussian filter
for(i=1;i<(length-1);i++)
{
for(j=1;j<(width-1);j++)
{
Ixx2[i][j]=a*(Ix2[i-1][j-1]+Ix2[i-1][j+1]+Ix2[i+1][j+1]+Ix2[i+1][j-1])
+b*(Ix2[i-1][j]+Ix2[i][j-1]+Ix2[i+1][j]+Ix2[i][j+1])+c*Ix2[i][j]; //// 3* and 8+
Ixx2b[i][j]=a*(Ix2b[i-1][j-1]+Ix2b[i-1][j+1]+Ix2b[i+1][j+1]+Ix2b[i+1][j-1])
+b*(Ix2b[i-1][j]+Ix2b[i][j-1]+Ix2b[i+1][j]+Ix2b[i][j+1])+c*Ix2b[i][j]; //// 3* and 8+
Iyy2[i][j]=a*(Iy2[i-1][j-1]+Iy2[i-1][j+1]+Iy2[i+1][j+1]+Iy2[i+1][j-1])
+b*(Iy2[i-1][j]+Iy2[i][j-1]+Iy2[i+1][j]+Iy2[i][j+1])+c*Iy2[i][j]; //// 3* and 8+
Iyy2b[i][j]=a*(Iy2b[i-1][j-1]+Iy2b[i-1][j+1]+Iy2b[i+1][j+1]+Iy2b[i+1][j-1])
+b*(Iy2b[i-1][j]+Iy2b[i][j-1]+Iy2b[i+1][j]+Iy2b[i][j+1])+c*Iy2b[i][j]; //// 3* and 8+
}
}
for(i=1;i<(length-1);i++){
for(j=1;j<(width-1);j++){
Ixx2[i][j]=Ixx2[i][j]/4096;
Ixx2b[i][j]=Ixx2b[i][j]/4096;
Iyy2[i][j]=Iyy2[i][j]/4096;
Iyy2b[i][j]=Iyy2b[i][j]/4096;
}
}
cycle4= alt_timestamp();
//printf (" Needed cycle number to aquire image 2 is %d \n",cycle2-cycle1);
tps4= ((cycle4-cycle3)/(float) freq);
printf (" time to compute filter Gradiants Ix2,Iy2 is %f \n",tps4);
//////////////////////////////////////////////////////////////////////////////////
printf( " Gradiants Ix2,Iy2 are filered with Guassian filter correctly \n");
//////////////////////////////////////////////////////////////////////////////////
//Step4 : Computing the Denominator of Harris Response
for(i=1;i<(length-1);i++)
{
for(j=1;j<(width-1);j++)
{
B[i][j]=Ixx2[i][j]+Iyy2[i][j]; //// 1 *
Bb[i][j]=Ixx2b[i][j]+Iyy2b[i][j]; //// 1 *
}
}
///////////////////////////////////////////////////////////////////////////////////
//Step5 : Computing the product of the squared smoothed gradiants
for(i=1;i<(length-1);i++)
{
for(j=1;j<(width-1);j++)
{
Ixxyysqr[i][j]=Ixx2[i][j]*Iyy2[i][j]; //// 1 *
Ixxyysqrb[i][j]=Ixx2b[i][j]*Iyy2b[i][j]; //// 1 *
}
}
//Step6 : Computing the product of the gradiants Ix*Iy
for(i=1;i<(length-1);i++)
{
for(j=1;j<(width-1);j++)
{
Ixy[i][j]=Ix[i][j]*Iy[i][j]; //// 1 *
Ixyb[i][j]=Ixb[i][j]*Iyb[i][j]; //// 1 *
}
}
////////////////////////////////////////////////////////////////////////////////////
printf( " Gradiants Ixy are computed correctly \n");
////////////////////////////////////////////////////////////////////////////////////
//Step7 : Smoothing the produc
尽是远方
- 粉丝: 23
- 资源: 1万+
会员权益专享
最新资源
- 备赛2023蓝桥杯,国信长天单片机竞赛平台开发软件安装教程
- 看板代码.sql
- google-chrome-stable_current_amd64.deb
- 时尚镂空美女女性PPT模板.pot
- SAP GUI for windows 7.60 免费下载 - 08 (含 patch level 15)
- SAP GUI for windows 7.70 免费下载 - 02 (含 patch level 10)
- GTK+-Runtime-3.4.2-(TARNYKO).exe
- SAP GUI for windows 7.60 免费下载 - 07 (含 patch level 9-1)
- SAP GUI for windows 7.60 免费下载 - 06 (含 patch level 9)
- BattleInfo.json
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈


