mirror of
https://github.com/Steffo99/unimore-hpc-assignments.git
synced 2024-11-25 09:34:23 +00:00
Add loop labels and change loop offset
Co-authored-by: Fabio Zanichelli <274956@studenti.unimore.it> Co-authored-by: Stefano Pigozzi <256895@studenti.unimore.it>
This commit is contained in:
parent
00d632a25a
commit
8692e82290
1 changed files with 19 additions and 6 deletions
|
@ -14,25 +14,38 @@ void sobel(uint8_t *__restrict__ out, uint8_t *__restrict__ in, const int width,
|
|||
{-1, 0, 1}
|
||||
};
|
||||
|
||||
for (int y = 1; y < height - 1; y++)
|
||||
esternoY:
|
||||
for (int y = 0; y < height - 2; y++)
|
||||
{
|
||||
for (int x = 1; x < width - 1; x++)
|
||||
esternoX:
|
||||
for (int x = 0; x < width - 2; x++)
|
||||
{
|
||||
int dx = 0;
|
||||
int dy = 0;
|
||||
|
||||
internoY:
|
||||
for (int k = 0; k < 3; k++)
|
||||
{
|
||||
const int inYOffset = (y + k) * width;
|
||||
|
||||
internoX:
|
||||
for (int z = 0; z < 3; z++)
|
||||
{
|
||||
const int address = (y + k - 1) * width + x + z - 1;
|
||||
const int inXOffset = x + z;
|
||||
|
||||
dx += sobelFilter[k][z] * in[address];
|
||||
dy += sobelFilter[z][k] * in[address];
|
||||
const int inOffset = inYOffset + inXOffset;
|
||||
const int inElement = in[inOffset];
|
||||
|
||||
dx += sobelFilter[k][z] * inElement;
|
||||
dy += sobelFilter[z][k] * inElement;
|
||||
}
|
||||
}
|
||||
|
||||
out[y * width + x] = sqrt((float)((dx * dx) + (dy * dy)));
|
||||
const int outYOffset = (y + 1) * width;
|
||||
const int outXOffset = (x + 1);
|
||||
const int outOffset = outYOffset + outXOffset;
|
||||
|
||||
out[outOffset] = sqrt((float)((dx * dx) + (dy * dy)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue