20 lines
426 B
C++
20 lines
426 B
C++
#include "image.h"
|
|
|
|
namespace Image
|
|
{
|
|
void threshold(SDL_Surface *image, int lowerBound, int upperBound)
|
|
{
|
|
int x, y;
|
|
for (int i = 0; i < image->w * image->h; ++i)
|
|
{
|
|
int gray = GRAY(((uint32_t*)image->pixels)[i]);
|
|
if (gray > lowerBound && gray < upperBound)
|
|
((uint32_t*)image->pixels)[i] = 0xffffffff;
|
|
else
|
|
((uint32_t*)image->pixels)[i] = 0xff000000;
|
|
//gray | (gray << 8) | (gray << 16);
|
|
|
|
}
|
|
}
|
|
}
|