Skip to content

Commit

Permalink
Fixed FAT PURPLE bands that appeared with AMaZE
Browse files Browse the repository at this point in the history
Some core counts/image resolutions meant debayer stripe did not start on an even number, so the pixels were wrong colours, leading to funky purple images. Fixed now with % 2.
  • Loading branch information
ilia3101 authored Jul 18, 2017
1 parent 7a6a3ca commit 9b22607
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/debayer/debayer.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,22 @@ void debayerAmaze(uint16_t * debayerto, float * bayerdata, int width, int height
/* Else do multithreading */
else
{
uint16_t startchunk_y[threads];
uint16_t endchunk_y[threads];
int startchunk_y[threads];
int endchunk_y[threads];

/* How big each thread's chunk is, multiple of 2 - or debayer
* would start on wrong pixel and magenta stripes appear */
int chunk_height = height / threads;
chunk_height -= chunk_height % 2;

/* Calculate chunks of image for each thread */
for (int thread = 0; thread < threads; ++thread)
{
startchunk_y[thread] = ( (height) / threads ) * thread;
endchunk_y[thread] = ( ( (height) / threads ) * (thread + 1) );
startchunk_y[thread] = chunk_height * thread;
endchunk_y[thread] = chunk_height * (thread + 1);
}

/* Last chunk must reach end of frame */
endchunk_y[threads-1] = height;

pthread_t thread_id[threads];
Expand Down Expand Up @@ -233,4 +239,4 @@ void debayerBasic(uint16_t * debayerto, float * bayerdata, int width, int height
memcpy(debayerto, debayerto + (width * 3), width * 6); /* Unsure why width needs to be * 6, but * 3 didn't fill whole row */
memcpy(debayerto + (width * (height - 1) * 3), debayerto + (width * (height - 2) * 3), width * 6);

}
}

0 comments on commit 9b22607

Please sign in to comment.