Skip to content

Commit

Permalink
Merge pull request #1 from syrusakbary/patch-1
Browse files Browse the repository at this point in the history
Updated gray algorithm
  • Loading branch information
ern0 committed Apr 13, 2022
2 parents 601a222 + 69e09a9 commit a7c5594
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions inc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@ extern "C" void gray(int width, int height) {
uint8_t* ptr = &memory;
for (int i = 0; i < width * height * 4; i += 4) {

uint32_t sum = ptr[i] + ptr[i+1] + ptr[i+2];
uint32_t avg = sum / 3;
ptr[i] = avg;
ptr[i+1] = avg;
ptr[i+2] = avg;
uint32_t gray = 0.299 * ptr[i] + 0.587 * ptr[i+1] + 0.114 * ptr[i+2];
ptr[i] = gray;
ptr[i+1] = gray;
ptr[i+2] = gray;

}
}
Expand Down Expand Up @@ -134,4 +133,4 @@ extern "C" void blur(int width, int height) {

}
}
}
}

0 comments on commit a7c5594

Please sign in to comment.