Commit 6a67e573 authored by Ralf Stemmer's avatar Ralf Stemmer

First public release

parent 1bb97575
*~
*.o
sobeltest
build
mb
static int image_width = 12;
static int image_height = 12;
static int image[12][12]={
{59,18,60,8,60,26,60,22,60,60,57,21},
{32,60,60,60,60,60,9,30,60,17,60,0},
{54,11,60,60,60,37,47,60,52,60,34,60},
{60,60,60,22,55,48,4,14,50,3,60,60},
{45,38,60,60,60,60,60,33,31,60,60,60},
{44,2,60,28,15,60,60,60,24,60,12,60},
{40,60,60,60,49,60,60,53,60,60,60,60},
{7,60,31,60,60,60,13,60,39,60,60,60},
{60,20,60,42,47,6,19,60,0,60,10,60},
{60,35,60,60,60,27,56,1,36,60,19,60},
{60,5,41,60,60,46,45,60,51,23,58,60},
{30,60,60,60,60,60,43,16,44,29,60,25}
};
static int image_width = 24;
static int image_height = 24;
static int image[24][24]={
{157,119,157,157,45,44,157,157,157,157,87,157,0,116,114,140,0,140,90,157,130,66,154,157},
{140,157,135,89,137,111,157,65,156,33,146,157,18,96,84,157,157,0,157,157,155,110,157,157},
{16,157,0,156,138,50,107,157,130,157,111,157,157,115,108,18,80,101,123,99,157,80,157,43},
{72,132,157,157,157,157,157,157,1,120,36,93,59,24,157,157,120,60,154,98,0,157,157,157},
{157,144,157,157,157,94,84,19,149,45,157,157,157,157,157,130,157,157,4,157,56,130,122,157},
{157,116,157,155,147,157,32,157,157,157,157,48,80,78,157,76,99,157,75,157,157,125,157,103},
{157,157,157,41,157,68,10,157,101,117,35,131,122,157,65,157,88,88,107,0,157,79,157,157},
{109,106,157,103,91,157,78,117,157,118,0,134,92,157,131,136,157,157,152,17,157,103,104,157},
{157,157,46,157,22,96,14,157,19,157,157,2,98,49,157,157,139,6,157,58,113,100,23,157},
{157,157,95,0,157,36,121,95,157,76,157,153,157,157,138,100,157,31,157,145,0,157,157,13},
{34,157,157,155,157,104,157,81,157,51,157,74,63,157,157,8,157,40,100,157,157,157,157,149},
{157,157,157,157,157,135,157,65,157,157,92,66,157,157,148,121,98,0,48,157,38,157,157,157},
{157,126,157,157,157,139,0,157,42,142,3,157,157,72,157,157,74,143,37,113,157,157,111,102},
{43,157,54,22,53,157,157,99,157,157,146,67,157,157,157,12,97,157,157,8,157,157,157,157},
{157,11,95,157,9,62,157,76,157,157,157,128,92,157,157,0,157,157,28,157,157,157,157,117},
{157,119,126,30,151,58,108,120,66,157,157,157,157,157,157,157,152,97,0,157,157,2,71,157},
{157,157,124,157,157,157,157,15,157,126,157,157,152,5,29,157,157,157,46,157,157,157,157,0},
{157,157,157,86,47,157,157,157,110,21,39,68,77,157,153,120,157,157,127,157,157,55,157,157},
{157,157,113,134,95,157,157,157,101,0,44,83,157,129,57,27,128,108,157,133,157,105,69,157},
{20,157,157,157,157,157,73,42,73,157,157,147,157,134,68,101,157,157,145,7,0,103,157,26},
{157,150,157,157,144,157,82,157,114,157,157,104,64,157,157,157,141,85,157,157,157,157,157,111},
{100,157,157,123,157,57,157,146,157,157,52,142,70,0,106,157,123,157,137,157,112,157,157,114},
{106,142,157,79,157,61,157,157,25,157,157,19,142,50,57,157,157,157,157,157,157,157,157,157},
{29,157,157,157,157,157,93,77,157,157,57,157,157,157,140,24,157,157,103,157,145,157,157,157}
};
This source diff could not be displayed because it is too large. You can view the blob instead.
static int image_width = 48;
static int image_height = 48;
static int image[48][48]={
{193,60,233,219,233,201,145,233,233,233,233,193,221,17,0,98,233,233,233,29,223,107,155,160,233,50,50,153,151,233,233,216,233,189,233,233,72,233,209,233,101,71,163,233,167,108,171,135},
{233,167,233,23,233,233,190,164,221,205,233,233,149,233,233,233,92,233,185,233,233,73,233,233,203,233,183,233,79,230,233,233,201,233,166,224,230,233,193,41,233,233,107,0,205,161,233,233},
{233,184,233,233,232,91,75,233,233,233,91,233,206,233,179,233,68,233,143,233,212,170,202,233,233,164,16,233,233,233,110,104,34,233,56,173,157,43,233,80,233,233,128,233,218,233,233,233},
{221,233,131,233,233,233,233,204,233,91,159,233,95,233,174,216,102,170,233,0,0,219,0,233,233,182,186,120,233,233,99,233,113,233,11,26,86,233,14,197,192,104,233,232,7,186,233,233},
{233,232,145,177,233,184,199,233,233,176,160,233,104,233,190,233,16,233,233,233,233,210,233,146,98,233,233,91,233,233,233,132,233,172,134,233,141,195,233,233,233,233,0,140,146,233,233,199},
{194,126,229,0,233,62,226,233,42,233,135,231,233,210,233,233,233,233,233,209,233,191,159,26,233,90,233,233,233,233,230,233,233,233,233,233,232,233,233,233,181,233,233,233,233,233,233,233},
{117,131,221,233,233,233,194,0,112,233,135,233,233,159,131,206,144,233,233,233,113,201,160,233,233,233,232,212,233,0,102,233,233,30,31,233,233,233,233,233,0,233,162,233,233,88,25,136},
{233,233,233,233,9,233,233,233,233,233,111,69,233,140,119,233,113,189,164,233,207,233,192,157,233,233,233,233,72,162,86,233,179,146,233,233,141,146,220,233,182,95,233,87,221,177,133,100},
{141,193,233,169,189,185,233,233,42,233,233,0,71,233,233,201,178,233,199,217,233,220,233,167,233,66,202,153,233,94,226,233,72,178,98,233,126,233,233,37,159,122,175,233,233,233,233,233},
{233,233,233,233,90,171,222,233,233,233,233,83,101,132,16,75,92,233,232,130,214,233,36,233,233,233,143,24,207,171,233,172,116,148,233,201,82,14,230,219,233,233,200,233,233,233,31,233},
{119,123,144,230,0,221,233,233,191,233,75,211,233,233,233,233,233,233,233,233,228,141,233,233,233,76,204,233,233,182,92,233,161,233,66,176,233,233,19,233,59,226,162,0,49,136,233,152},
{187,174,233,233,233,35,233,53,154,208,105,186,233,174,156,182,233,233,233,90,171,233,233,135,60,119,233,233,126,233,48,78,233,233,206,227,233,124,175,233,22,233,223,233,225,196,233,48},
{233,233,136,233,73,233,233,233,0,233,20,233,233,16,169,233,111,233,90,126,232,171,77,233,233,178,171,139,233,0,74,183,233,233,233,142,233,220,138,233,233,233,142,174,233,224,233,59},
{233,233,233,233,121,233,233,156,233,233,56,233,107,142,195,233,178,128,149,100,216,181,113,85,160,201,233,220,233,158,233,154,233,233,107,188,233,124,233,187,213,233,233,84,50,123,174,233},
{64,204,102,233,233,233,192,233,233,233,86,233,118,233,70,233,171,233,228,88,55,233,233,233,40,233,233,207,233,233,233,233,233,132,233,233,233,233,233,233,39,233,233,73,99,233,184,233},
{218,92,223,87,233,233,233,151,233,214,226,233,233,123,173,43,233,233,228,186,220,233,233,233,194,233,179,138,152,205,233,233,233,209,233,233,190,233,190,73,233,200,233,233,233,233,113,233},
{179,113,88,233,167,233,206,36,119,233,233,41,233,233,233,127,232,233,233,206,233,233,0,233,233,4,233,233,233,233,233,233,233,0,233,105,100,233,233,233,231,120,233,196,110,125,233,233},
{226,30,211,233,233,143,233,173,233,233,233,233,233,233,18,1,186,233,214,139,197,233,233,233,233,233,104,233,203,229,110,233,233,233,54,233,233,233,184,59,233,233,233,233,195,233,233,34},
{88,189,233,233,194,233,197,0,196,233,190,233,187,2,205,27,217,211,233,201,233,233,233,226,194,21,233,227,233,14,145,233,134,130,233,120,233,153,233,233,233,175,88,233,80,233,233,134},
{233,233,137,233,233,233,194,233,233,140,233,233,233,158,112,209,233,233,233,143,177,233,195,84,233,233,233,216,215,233,233,233,233,134,153,233,216,233,233,233,233,195,233,63,143,233,0,144},
{233,93,233,233,34,233,233,233,181,159,233,233,168,233,233,190,50,233,233,233,233,233,233,31,233,233,233,179,233,144,233,176,75,86,233,222,233,233,233,180,178,233,233,38,224,69,233,203},
{230,204,79,233,143,233,233,233,163,190,233,233,233,230,233,233,170,233,233,35,233,233,218,113,233,231,233,233,233,123,233,233,233,139,233,228,233,163,233,197,68,111,233,224,233,233,233,233},
{182,129,191,134,231,233,108,233,122,233,212,121,111,21,153,233,231,179,144,233,233,153,233,199,141,233,186,233,233,233,233,233,212,0,124,233,233,107,147,62,173,233,233,214,43,57,45,233},
{233,233,232,233,233,233,233,233,215,98,233,98,233,99,233,121,233,168,233,81,233,129,225,233,225,56,168,78,138,233,233,233,233,0,233,145,233,233,233,163,106,0,158,233,233,233,233,233},
{226,115,233,75,233,225,233,233,137,233,233,233,233,144,233,101,34,233,118,117,233,233,127,233,136,84,233,82,190,182,0,207,77,233,233,222,233,233,233,143,155,233,216,233,233,155,65,81},
{233,233,233,233,113,178,233,175,183,193,233,122,136,233,233,233,148,233,233,212,52,233,233,233,233,0,233,233,233,231,233,233,176,215,233,191,233,233,166,232,233,206,233,233,104,233,183,113},
{102,206,233,105,33,233,233,227,233,233,133,233,230,233,162,202,228,118,233,233,233,0,222,233,176,15,222,104,179,233,233,33,233,233,110,233,233,0,233,233,233,228,233,233,112,233,127,100},
{233,233,233,201,67,233,191,225,233,233,105,22,210,233,233,210,195,233,233,233,233,96,166,233,229,233,143,233,62,191,229,233,233,183,233,233,127,42,233,231,146,104,171,233,119,197,233,0},
{157,189,233,233,229,142,233,101,233,191,233,151,155,233,233,233,233,233,105,137,233,233,233,233,233,233,233,233,233,233,233,184,23,233,233,159,194,215,233,233,233,233,233,189,226,233,128,233},
{233,233,233,233,129,233,233,162,233,195,0,233,233,233,233,149,211,13,0,220,233,57,233,233,233,166,233,136,233,233,233,233,233,210,109,233,233,233,171,233,233,142,233,233,233,233,92,74},
{188,233,135,233,213,233,233,12,233,233,233,233,233,63,233,233,94,229,50,177,229,224,0,233,184,233,103,233,233,233,176,73,233,216,233,0,193,233,233,190,233,233,54,188,233,62,233,233},
{105,170,233,233,73,233,233,233,175,233,233,233,233,233,121,104,181,233,233,233,233,207,233,116,88,233,156,230,233,233,233,233,233,193,233,233,162,233,95,156,233,233,233,121,174,0,233,150},
{204,184,169,158,219,103,132,100,233,233,179,201,49,129,83,185,233,157,233,152,233,233,151,209,233,233,233,44,233,233,229,0,233,216,73,85,153,131,233,76,185,233,233,197,233,233,233,233},
{127,233,233,233,193,175,233,233,143,0,233,233,164,69,233,233,185,229,233,80,136,233,233,81,137,164,233,107,172,233,159,233,118,233,38,233,72,230,178,85,205,233,133,189,194,166,229,233},
{219,233,233,227,233,233,133,0,233,191,233,81,233,233,230,87,220,89,233,233,233,22,127,134,233,159,233,66,203,233,233,157,35,84,233,233,180,233,29,233,233,233,233,103,233,222,70,157},
{119,146,0,45,145,177,233,233,153,155,212,233,233,233,135,233,233,0,134,233,233,49,233,196,233,233,233,233,233,233,147,233,185,233,233,78,62,226,147,233,131,139,233,233,225,233,233,201},
{233,17,233,233,233,98,170,233,200,233,124,233,233,233,233,233,233,233,233,233,147,233,209,0,233,48,233,233,233,231,175,233,209,221,233,233,183,233,73,233,233,233,233,215,112,233,0,180},
{125,233,233,233,233,182,233,233,212,233,233,233,108,233,68,10,233,58,113,233,93,233,215,233,222,108,217,166,213,233,0,172,162,7,41,150,223,233,233,233,120,233,233,233,233,233,94,180},
{0,170,130,233,204,233,116,233,6,233,233,92,230,126,211,233,217,233,167,233,231,233,233,233,233,18,233,198,233,35,233,233,152,233,233,233,35,88,231,233,0,165,138,233,233,216,233,140},
{220,215,8,233,233,177,233,172,31,233,206,1,233,199,155,233,233,12,112,233,233,233,233,32,233,233,191,233,233,105,233,233,40,128,34,233,233,113,203,233,233,110,233,233,233,3,39,233},
{233,226,225,182,233,233,135,129,90,233,209,3,233,233,47,145,233,233,184,233,214,233,18,180,233,143,233,223,151,233,233,233,233,196,233,143,233,233,51,216,233,169,233,83,233,233,97,72},
{135,233,233,233,233,186,48,233,221,233,233,53,203,209,233,233,233,158,0,231,233,62,87,233,233,233,16,233,233,233,99,233,195,233,233,233,196,155,233,233,233,168,210,121,233,233,233,233},
{233,233,233,233,0,233,233,0,122,233,233,233,57,233,224,38,233,233,58,88,77,233,233,233,233,61,223,40,34,233,92,233,233,225,233,115,0,183,111,155,131,114,132,208,233,233,140,233},
{152,166,74,233,233,233,212,113,233,164,63,98,233,233,233,191,233,233,233,182,233,28,233,233,164,233,233,233,230,233,233,233,75,233,225,233,169,86,164,233,233,233,233,176,233,233,71,139},
{189,233,233,233,210,217,233,233,233,233,233,166,233,233,39,44,193,87,44,233,233,232,233,46,233,233,180,233,233,233,170,233,10,233,233,224,150,233,233,63,233,233,233,233,233,233,233,233},
{199,149,206,210,167,185,190,181,55,231,231,21,79,233,0,223,94,233,147,233,215,211,233,233,227,233,176,233,188,233,233,123,233,233,182,150,233,233,139,233,136,233,5,13,233,170,217,233},
{141,233,233,233,221,146,233,165,32,233,233,233,103,179,233,166,233,233,233,233,32,233,233,158,206,164,233,233,104,100,233,233,233,115,204,233,150,233,89,205,206,233,218,207,131,220,233,209},
{233,233,233,233,95,156,198,124,233,75,233,233,168,233,233,49,19,114,233,143,233,233,199,233,51,233,183,233,233,233,114,233,233,233,233,233,210,233,203,233,210,117,233,185,233,233,39,233}
};
This diff is collapsed.
This diff is collapsed.
/*
* sobel_filter.c
*
* Created on: 10.12.2015
* Author: Christof Schlaak
* Refactored: Ralf Stemmer on 16.05.2018
*/
#include <sobel.h>
#ifdef TEST
#include <stdio.h>
#endif
/*
* Here you can select different images.
* All headers provide the following variables with different image sizes:
static int image_width = 12;
static int image_height = 12;
static int image[12][12]= {{},..,{}};
*/
//#include <image/noise12.h>
//#include <image/noise24.h>
#include <image/noise48.h>
//#include <image/noise96.h>
//#include <image/noise256.h>
//#include <image/noise512.h>
int image_x = 0;
int image_y = 0;
void GetPixel(token_t tokensOut[])
{
// check if pixel available
// If not, start from the beginning
if(image_y >= image_height)
{
image_x = 0;
image_y = 0;
}
int i = 0;
int x_mask;
int y_mask;
for(y_mask = -4; y_mask < 5; ++y_mask)
{
for(x_mask = -4; x_mask < 5; ++x_mask)
{
int xnew;
int ynew;
xnew = image_x + x_mask;
ynew = image_y + y_mask;
if(xnew < 0)
xnew = 0;
if(xnew >= image_width)
xnew = image_width - 1;
if(ynew < 0)
ynew = 0;
if(ynew >= image_height)
ynew = image_height - 1;
tokensOut[i] = image[ynew][xnew];
i++;
}
}
image_x++;
if(image_x >= image_width)
{
image_x = 0;
image_y++;
}
}
void GX(token_t tokensIn[], token_t tokensOut[])
{
const int sx[81] = {
4, 3, 2, 1, 0, -1, -2, -3, -4,
5, 4, 3, 2, 0, -2, -3, -4, -5,
6, 5, 4, 3, 0, -3, -4, -5, -6,
7, 6, 5, 4, 0, -4, -5, -6, -7,
8, 7, 6, 5, 0, -5, -6, -7, -8,
7, 6, 5, 4, 0, -4, -5, -6, -7,
6, 5, 4, 3, 0, -3, -4, -5, -6,
5, 4, 3, 2, 0, -2, -3, -4, -5,
4, 3, 2, 1, 0, -1, -2, -3, -4
};
tokensOut[0] = 0;
int i;
for(i = 0; i < 81; i++)
{
tokensOut[0] += tokensIn[i] * sx[81-1 - i];
}
}
void GY(token_t tokensIn[], token_t tokensOut[])
{
const int sy[81] = {
4, 5, 6, 7, 8, 7, 6, 5, 4,
3, 4, 5, 6, 7, 6, 5, 4, 3,
2, 3, 4, 5, 6, 5, 4, 3, 2,
1, 2, 3, 4, 5, 4, 3, 2, 1,
0, 0, 0, 0, 0, 0, 0, 0, 0,
-1, -2, -3, -4, -5, -4, -3, -2, -1,
-2, -3, -4, -5, -6, -5, -4, -3, -2,
-3, -4, -5, -6, -7, -6, -5, -4, -3,
-4, -5, -6, -7, -8, -7, -6, -5, -4
};
tokensOut[0] = 0;
int i;
for(i = 0; i < 81; i++)
{
tokensOut[0] += tokensIn[i] * sy[81-1 - i];
}
}
token_t ABS(token_t tokensIn1[], token_t tokensIn2[])
{
if(tokensIn1[0] < 0) tokensIn1[0] = tokensIn1[0] * -1;
if(tokensIn2[0] < 0) tokensIn2[0] = tokensIn2[0] * -1;
int result;
// Usually, the formular is sqrt(GX² + GY²), we hacket it this way:
result = (tokensIn1[0] + tokensIn2[0]) & 0x000000FF;
return (token_t) result;
}
/*
* testing procedure only for local computer (no multi processor)
*/
#ifdef TEST
int main()
{
token_t source[9*9];
token_t gx[9*9];
token_t gy[9*9];
token_t result;
// main loop
for(int i = 0; i < image_height*image_width; i++)
{
GetPixel(source);
GX(source, gx);
GY(source, gy);
result = ABS(gx, gy);
printf(" %3d", result);
if((i+1)%image_width == 0)
printf("\n");
}
return (0);
}
#endif
// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
/*
* sobel_filter.h
*
* Created on: 10.12.2015
* Author: Christof Schlaak
* Refactored: Ralf Stemmer on 16.05.2018
*/
#ifndef SOBEL_FILTER_H_
#define SOBEL_FILTER_H_
#ifndef LIBSDF_H
typedef int token_t;
#endif
void GetPixel(token_t tokensOut[]);
void GX(token_t tokensIn[], token_t tokensOut[]);
void GY(token_t tokensIn[], token_t tokensOut[]);
token_t ABS(token_t tokensIn1[], token_t tokensIn2[]);
#endif
// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
#!/usr/bin/env bash
SOURCEPATH="./Sobel-Filter"
INSTALLPATH="./mb"
BUILDPATH="./build"
INCLUDEPATHS="-I$SOURCEPATH -I./mb"
SHARED_CFLAGS="-O0 -c -mcpu=v9.6 -mlittle-endian -fdata-sections -ffunction-sections -std=c99"
GCC=mb-gcc
OBJCOPY=mb-objcopy
AR=mb-ar
for lib in libsobel.a libsobel-ea.a
do
if [ -f "$INSTALLPATH/$lib" ] ; then
echo -e "\e[1;31m$lib does already exist."
echo -e "\e[1;30mTo create a new $lib library, the old one must be removed manually."
exit 1
fi
done
if [ -d "$BUILDPATH" ] ; then
echo -e "\e[1;31m$BUILDPATH does already exist."
echo -e "\e[1;30mThe scripts expects that this directory does not exist. Please remove it manually."
exit 1
fi
mkdir -p $BUILDPATH
# 1st argument: libname "jpeg-ef" for example
# 2nd argument: CFLAGS
function Build
{
LIBNAME="$1"
CFLAGS="$2"
SOURCES=$(find $SOURCEPATH -type f -name "*.c")
for s in $SOURCES ;
do
echo -e -n "\e[1;34m - $s\e[0m "
FILENAME="${s##*/}"
OBJFILE="${FILENAME%.*}.o"
$GCC $CFLAGS $INCLUDEPATHS -I$SOURCEPATH -c -o "$BUILDPATH/$OBJFILE" $s
if [ $? -ne 0 ] ; then
echo -e "\e[1;31m$GCC FAILED!\e[0m"
exit 1
else
echo -e "\e[1;32m✔\e[0m"
fi
done
$AR rv $INSTALLPATH/lib${LIBNAME}.a $BUILDPATH/*.o
rm $BUILDPATH/*.o
}
mkdir -p $INSTALLPATH
# Build Libraries
Build sobel "$SHARED_CFLAGS -mxl-soft-mul -mxl-soft-div -msoft-float"
Build sobel-ea "$SHARED_CFLAGS -mno-xl-soft-mul -mno-xl-soft-div -msoft-float"
# Copy Headers
cp $SOURCEPATH/*.h $INSTALLPATH/.
# Make Clean
rmdir $BUILDPATH
#!/usr/bin/env bash
clang -I ./Sobel-Filter -DTEST -o sobeltest ./Sobel-Filter/sobel.c
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment