Solved

Simple Desktop Application for projecting RGB values from an image

Posted on 2008-10-03
6
803 Views
Last Modified: 2013-12-14
I have  a programming trouble can you help me with this ?
 
I need a small graphical user interface which asks for a input which is an image (jpeg or bmp) and we need to supply it with an image.
It would calculate the RGB values for all the pixels and average (Some kind of mean; purpose is to confirm with an uniform value) and
it would look up in a table (the type of table is up to us it can be a text based, two coloumn or a comma separated file what ever)
and project the value(float or int) as the output.

Any idea or help
0
Comment
Question by:thirst4truth
  • 3
  • 3
6 Comments
 
LVL 2

Assisted Solution

by:jvulliet
jvulliet earned 400 total points
ID: 22638579
Hello,

are you in unmanaged C++ or managed C++ (.NET)?

If you are in C++ .NET check the following code snippet to calculate average of image.
 OpenFileDialog^ odlg = gcnew OpenFileDialog();

 odlg->Filter = "Image Files|*.bmp;*.jpg";

 if (odlg->ShowDialog() == System::Windows::Forms::DialogResult::OK) 

 {

	 System::Drawing::Bitmap bitmap = gcnew System::Drawing::Bitmap(odlg->FileName);

	 long sumr = 0;

	 long sumg = 0;

	 long sumb = 0;

	 

	 for (int i = 0; i < bitmap.Width;i++) 

	 {

		 for (int j = 0; j < bitmap.Height; j++) 

		 {

			 Color color = bitmap.GetPixel(i,j);

			 

			 //Process the pixel here

			 Byte r = color.R;

			 Byte g = color.G;

			 Byte b = color.B;
 

			 sumr += r;

			 sumg += g;

			 sumb += b;

		 }

	 }
 

	 long totalpixel = bitmap.Width * bitmap.Height;

	 Byte avgred = Convert::ToByte(sumr / totalpixel);

	 Byte avggreen = Convert::ToByte(sumg / totalpixel);

	 Byte avgblue = Convert::ToByte(sumb / totalpixel);

 }

Open in new window

0
 

Author Comment

by:thirst4truth
ID: 22639530
I am using un managed c++ then.

Well how to complie this peice of code?

How to give image as an input?
0
 
LVL 2

Assisted Solution

by:jvulliet
jvulliet earned 400 total points
ID: 22640894
Just to know, which compiler and development environment are you using?

and what api are you using for user interface as well (MFC, Qt, Gtk...)?
Some of those have built in classes for images.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:thirst4truth
ID: 22641334
Iam using visual studio to complie it.

i dont know abt api

sorry for i have only intermediate knowledge in this subject
0
 
LVL 2

Assisted Solution

by:jvulliet
jvulliet earned 400 total points
ID: 22658553
Which version of visual studio (6.0, 2003, 2005, 2008) are you using?

If you show me a little code example you use just to create a form I should be able to see which api you use (considering you use visual studio should be mfc or winforms, but just to make sure), then make you a little project which works.
0
 

Accepted Solution

by:
thirst4truth earned 0 total points
ID: 22678155
Hello jvulliet

   i attached a screen shot of what i am using
as far as i know it is : Microsoft Visual Studio Express Edition 2008

thank You
cpp.JPG
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Cut little around the images in a folder 6 97
Java Help 2 79
Best IDE for PHP starters 11 113
how to blot out certain parts of a video 2 63
I. Introduction In a previous article (http://www.experts-exchange.com/Web_Development/Document_Imaging/A_6537-PaperPort-Upgrade-How-to-download-and-install-updated-versions-of-PaperPort-11-and-12.html) (now deprecated), I discussed how to upgrad…
This article shows how to convert a multi-page PDF file into multiple image files, with one image file created for each page of the PDF. It does this by utilizing an excellent, free software package called GraphicsMagick. The solution is amazingly s…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The goal of the tutorial is to teach the user how to use import presets downloaded from the internet into Adobe Lightroom. Once you downloaded the presets go into the preset folder and press import then import your preset and your set it to go.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now