mirror of
https://github.com/Steffo99/unimore-hpc-assignments.git
synced 2024-11-25 17:44:23 +00:00
Reformat code
Co-authored-by: Stefano Pigozzi <me@steffo.eu> Co-authored-by: Fabio Zanichelli <ZukkerinoSugar@users.noreply.github.com>
This commit is contained in:
parent
7cab92df26
commit
585fce92d0
1 changed files with 9 additions and 2 deletions
|
@ -3,13 +3,19 @@
|
||||||
|
|
||||||
void sobel(uint8_t *__restrict__ out, uint8_t *__restrict__ in, int width, int height)
|
void sobel(uint8_t *__restrict__ out, uint8_t *__restrict__ in, int width, int height)
|
||||||
{
|
{
|
||||||
int sobelFilter[3][3] = {{-1, 0, 1}, {-2, 0, 2}, {-1, 0, 1}};
|
int sobelFilter[3][3] = {
|
||||||
|
{-1, 0, 1},
|
||||||
|
{-2, 0, 2},
|
||||||
|
{-1, 0, 1}
|
||||||
|
};
|
||||||
|
|
||||||
for (int y = 1; y < height - 1; y++)
|
for (int y = 1; y < height - 1; y++)
|
||||||
{
|
{
|
||||||
for (int x = 1; x < width - 1; x++)
|
for (int x = 1; x < width - 1; x++)
|
||||||
{
|
{
|
||||||
int dx = 0, dy = 0;
|
int dx = 0;
|
||||||
|
int dy = 0;
|
||||||
|
|
||||||
for (int k = 0; k < 3; k++)
|
for (int k = 0; k < 3; k++)
|
||||||
{
|
{
|
||||||
for (int z = 0; z < 3; z++)
|
for (int z = 0; z < 3; z++)
|
||||||
|
@ -18,6 +24,7 @@ void sobel(uint8_t *__restrict__ out, uint8_t *__restrict__ in, int width, int h
|
||||||
dy += sobelFilter[z][k] * in[(y + k - 1) * width + x + z - 1];
|
dy += sobelFilter[z][k] * in[(y + k - 1) * width + x + z - 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
out[y * width + x] = sqrt((float)((dx * dx) + (dy * dy)));
|
out[y * width + x] = sqrt((float)((dx * dx) + (dy * dy)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue