Dear sir,
I have a code for image processing,i need to change COLOR like saturation,brightness,or something else.so can you tell me where i can change the code and what i need to change my code.
thank you.
#include<stdio.h>
#include<stdlib.h>
#define WIDTH 176
#define HEIGHT 144
void NearestNeighbor(unsigned char *in, unsigned char *out, unsigned int width, unsigned int height);
void Process(unsigned char *in, unsigned char *out, unsigned int width, unsigned int height);
unsigned char *yIn, *cbIn, *crIn;
unsigned char *yOut, *cbOut, *crOut;
int main(void)
{
FILE *fin, *fout;
unsigned char *inbuf, *outbuf;
unsigned int NoOfFrames, filesize, frame, Framesize;
if ((fin = fopen("C:\\miss-america_qcif.yuv", "rb")) == NULL) {
printf ("Error: Opening YUV file...\n");
return -1;
}
if ((fout = fopen("Output.yuv", "wb")) == NULL) {
printf ("Error: Opening output YUV file...\n");
return -1;
}
Framesize =( WIDTH * HEIGHT) * (3 / 2);
inbuf = (unsigned char*) malloc(sizeof(Framesize));
outbuf = (unsigned char*) malloc(sizeof((2 * WIDTH) * (2 * HEIGHT) * 3 / 2));
if (inbuf == NULL) {
printf ("Error: Memory allocation of Input buffer.\n");
return -1;
}
if (outbuf == NULL) {
printf ("Error: Memory allocation of Output buffer.\n");
return -1;
}
yIn = inbuf;
cbIn = yIn + (WIDTH * HEIGHT);
crIn = cbIn + ((WIDTH >> 1) * (HEIGHT >> 1));
yOut = outbuf;
cbOut = yOut + WIDTH * HEIGHT * 4;
crOut = cbOut + WIDTH * HEIGHT;
fseek(fin, 0, SEEK_END);
filesize = ftell(fin);
printf ("Number of filesize = %d\n", filesize);
rewind(fin);
NoOfFrames = filesize / Framesize;
printf ("Number of Frames = %d\n", NoOfFrames);
for (frame = 0; frame < NoOfFrames; frame++) {
fread(inbuf, sizeof(unsigned char), Framesize, fin);
NearestNeighbor(inbuf, outbuf, (unsigned int) WIDTH, (unsigned int) HEIGHT);
fwrite(outbuf, sizeof(unsigned char), Framesize * 4, fout);
printf ("Processed Frame %d.\n", frame);
}
fclose(fin);
fclose(fout);
return 0;
}
void NearestNeighbor(unsigned char *in, unsigned char *out, unsigned int width, unsigned int height)
{
unsigned char *inY, *inCb, *inCr, *outY, *outCb, *outCr;
inY = in;
inCb = inY + WIDTH * HEIGHT;
inCr = inCb + (WIDTH >> 1) * (HEIGHT >> 1);
outY = out;
outCb = outY + 4 * WIDTH * HEIGHT;
outCr = outCb + WIDTH * HEIGHT;
Process(inY, outY, width, height);
Process(inCb, outCb, width >> 1, height >> 1);
Process(inCr, outCr, width >> 1, height >> 1);
return;
}
void Process(unsigned char *in, unsigned char *out, unsigned int width, unsigned int height)
{
unsigned int row, col;
for (row = 0; row < height; row++) {
for (col = 0; col < width; col++) {
*out++ = *in;
*(out + 2 * width) = *in;
*(out + 2 * width - 1) = *in;
*out++ = *in++;
}
out += 2 * width;
}
return;
}
What I have tried:
I diplayed only the image not done nay processing