Click here to Skip to main content
15,891,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.

C++
#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;

	//	Finding the Number of Frames
	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);


	/************************************************************************
	 * Read one frame & upscale the frame									*
	 * Repeat the above process for all the frames in the file				*
	 ************************************************************************/
	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;

	// Calculation of Input & Output YCbCr positions
	inY = in;
	inCb = inY + WIDTH * HEIGHT;
	inCr = inCb + (WIDTH >> 1) * (HEIGHT >> 1);
	outY = out;
	outCb = outY + 4 * WIDTH * HEIGHT;
	outCr = outCb + WIDTH * HEIGHT;

	//	Processing the Luminance(Y)
	Process(inY, outY, width, height);
	//	Process the Chrominance(CbCr)
	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
Posted
Updated 17-Oct-16 1:11am
Comments
Suvendu Shekhar Giri 17-Oct-16 6:49am    
Who has written this code? are not you?
If not, ask the original writer to make you understand it.

1 solution

Hi Giri,
Its not by me but i understood the code.Am asking to you people to change the color of the image as am CCSv6.2 WITH DSP KIT DM6437 and not asking your decisions.
thank you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900