Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Need Visual C++ functions to implement Digital Image Processing

Status
Not open for further replies.

spyderlove

Newbie level 1
Joined
Aug 31, 2006
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,285
can anyone suggest book having Digital Image Processing using Visual C++?

Its very urgent..
 

Re: DIP using Visual C++

I haven't seen a book that gives you ready to use C++ functions for image processing. But if you have a good book, it's easy to implement DIP algorithms after reading the explanation.

Check out this example I made for grayscale "gamma correction", try to understand it, and you can modify it to make other kinds of filters, just change the operator that acts over the input data in the section between "HERE YOU WRITE THE CODE FOR PROCESSING INPUT DATA" and "HERE ENDS IMAGE PROCESSING CODE".

Code:
#include<iostream.h>
#include<stdlib.h>
#include <fstream.h>
#include<math.h>

 void main()

    {

     unsigned char buffer;  
	 int width=0,height=0,i=0,y=0,s=0,temp;
     char inputFile[]="test2.bmp";			//This is the input image
	 char ouputFile[]="C:\\outdata.bmp";	//This is the output image 
	 float j=1.75,s1=0,temp1=0;
	 double gamma;
		

	 ifstream input(inputFile,ios::in|ios::binary);   
	ofstream output(ouputFile,ios::out|ios::binary);

	cout<<"Gamma Correction Example"<<endl;	
	cout<<"Type value for gamma = "<<endl;

	cin>>gamma;


     if (!input)                        

       cout << "Error in file name"<<endl;    

     else

       {                                
		 		
         cout << "File: " << inputFile << endl;
		 //Calculate Image width
		 for(i=0;i<=3;i++)
		 {
	
			input.seekg(18+i,ios::beg);
			input.get(buffer);
			width += (buffer<<8*i);
		
		 }
		 //Calculate Image height
		 for(i=0;i<=3;i++)
		 {
			input.seekg(22+i,ios::beg);
			input.get(buffer);
			height += (buffer<<8*i);
		
		 }
	
	
		

		 cout<<"Width of image in pixels = "<<width<<endl; 
		 cout<<"Height of image in pixels = "<<height<<endl; 

	if (gamma < 1)
	{
		while(y <= 254)
		{
				y = pow(255,gamma)*j;
				j = j + 0.01;
				
		}

	}

		//Copy same header and color table for the output image
		for(i=0;i<=(54+1024+width*height-1);i++)
		{
			input.seekg(i,ios::beg);
			input.get(buffer);//Here we read input data from input image

			if (i > 1077)
			{
			////////////////////////////////////////////////////
			//HERE YOU WRITE THE CODE FOR PROCESSING INPUT DATA
			///////////////////////////////////////////////////
				if (gamma >= 1)
				{
					temp = buffer;
					s = pow(temp,gamma)/pow(255,(gamma-1));
					buffer = s;
					output.put(buffer);
					//cout<<s<<endl;
				}
				else
				{

					
					temp1 = buffer;
					s1 = pow(temp1,gamma)*j;
					buffer = s1;
					output.put(buffer);//Here you copy data to the output image
					//cout<<s1<<endl;
				}
			////////////////////////////////////////////////////
			//HERE ENDS IMAGE PROCESSING CODE
			///////////////////////////////////////////////////

			}
			else
			output.put(buffer);//Here you copy data to the output image
			
		
		}

			
     }  
}
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top