Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of 06_frdm_serial by
Diff: main.cpp
- Revision:
- 1:f72c50b1b93d
- Parent:
- 0:e4d31a61ad72
--- a/main.cpp Mon Nov 23 12:18:36 2015 +0000
+++ b/main.cpp Thu Apr 19 11:55:29 2018 +0000
@@ -8,11 +8,48 @@
Serial pc(USBTX,USBRX); //UART0 via OpenSDA
+
+
+int ** sobel(int **c,int h,int w)
+{
+ int **image = (int**)malloc(sizeof(int*)*(h-2));
+ for( int i=0;i<h;i++)
+ {
+ image[i]=(int*)malloc(sizeof(int)*(w-2));
+ }
+
+ int x[3][3]={{1,0,-1},{2,0,-2},{1,0,-1}};
+ int y[3][3]={{1,2,1},{0,0,0},{-1,-2,-1}};
+
+ for (int i=1;i<h-1;++i){
+ for (int j=1; j<w-1; ++j){
+ for(int k=0;k<3;++k){
+ for(int l=0;l<3;++l){
+ image[i-1][j-1] += x[k][l]*c[i-1+k][j-1+l];
+ }
+ image[i-1][j-1]=abs(image[i-1][j-1])/8;
+ }
+ }
+ }
+ return image;
+}
+
int main()
{
- pc.printf("\r\nWelcome to FRDM-KL25Z board!\r\n");
- while(1) {
- char c = pc.getc(); //Read one character
- pc.printf("received char: %c = %d\r\n",c,c);
+int width = 64; int height = 64;
+int **image = (int**)malloc(sizeof(int*)*height);
+ for( int i=0;i<height;i++)
+ {
+ image[i]=(int*)malloc(sizeof(int)*width);
}
+
+/*Write headers*/
+int i;
+for(i=0;i<4096;i++){
+ image[i/64][i%64]= pc.getc();
+ }
+
+int **c1= sobel(c,height,width);
+
}
+
\ No newline at end of file
