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.
Revision 0:648f3a4b6ad8, committed 2018-04-19
- Comitter:
- hrajgadia
- Date:
- Thu Apr 19 19:40:09 2018 +0000
- Commit message:
- Edge Detection
Changed in this revision
| image.cpp | Show annotated file Show diff for this revision Revisions of this file |
| mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/image.cpp Thu Apr 19 19:40:09 2018 +0000
@@ -0,0 +1,62 @@
+/** 06_frdm_serial
+ * Serial demo program for the FRDM-KL25Z board
+ * Select UART0 for communication via OpenSDA's USB-UART converter
+ * Default spedd and format are: 9600 bps, 8-bit, no parity, 1 stop bit
+ */
+
+#include "mbed.h"
+
+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-2;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){
+ int conv=0;
+ 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];
+ conv += y[k][l]*c[i-1+k][j-1+l];
+ }
+ }
+ image[i-1][j-1]=abs(image[i-1][j-1]+abs(conv))/8;
+ }
+ }
+
+ return image;
+}
+
+int main()
+{
+int width = 32; int height = 32;
+int **image = (int**)malloc(sizeof(int*)*height);
+for( int i=0;i<height;i++)
+ {
+ image[i]=(int*)malloc(sizeof(int)*width);
+ }
+for(int j=0;j<64;j++){
+/*Write headers*/
+ int i;
+ for(i=0;i<1024;i++){
+ image[i/32][i%32]= pc.getc();
+ }
+
+
+ int **c1 = sobel(image,height,width);
+ for(i=0;i<=899;i++){
+ pc.putc(c1[i/30][i%30]);
+ wait(0.5);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Apr 19 19:40:09 2018 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/994bdf8177cb \ No newline at end of file