Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdint.h>
- #include <stdio.h>
- #include <stdlib.h>
- void f(const uint32_t* image_bgra, int H, int W,
- float* out,
- int margin)
- {
- const int mu = margin;
- const int md = margin;
- const int mr = margin;
- const int ml = margin;
- //const int ml = 3;
- printf("params: H=%d W=%d, ml%d mr%d mu%d md%d\n", H, W, ml, mr, mu, md);
- for(int y=0; y<H; y++) {
- for(int x=0; x<W; x++) {
- const int idx = x + W*y;
- if ((y < mu) || (y >= H - md) ||
- (x < ml) || (x >= W - mr)) {
- out[idx + H*W*0] = 0.0f;
- out[idx + H*W*1] = 0.0f;
- out[idx + H*W*2] = 0.0f;
- out[idx + H*W*3] = 0.0f;
- } else {
- out[idx + H*W*0] = 1.0;
- out[idx + H*W*1] = 2.0;
- out[idx + H*W*2] = 3.0;
- out[idx + H*W*3] = 4.0;
- }
- if (x==0) {
- printf("out(x = %d ,y = %d, idx = %d , H = %d, W = %d) = %.f.\n",x,y,idx,H,W,out[idx + H*W*0]);
- }
- }
- }
- for (int y = 0; y < H; y++) {
- if (out[W*y] > 0.0f) {
- printf ("This shouldn't be seen: Line %d, value = %f\n", y, out[W*y]);
- }
- }
- return;
- }
- int main ()
- {
- const int H = 42;
- const int W = 32;
- const int D = 4;
- float* out2 = (float*) malloc(H * W * D * sizeof(float));
- f(NULL, H, W,
- out2,
- 3);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement