Honesty Rocks! truth rules.

Finding The Rgb Color Of An Image Using any programming language

HOME      >>       Programming


hello friends i am doing a project , in that i am inneed to fine the mean RGB value of a particular image , is there any program in any language which can do this ? the input to the program will be any image ( can be linked in the program) and the putput must be the mean RGB value of that particular image , is this Possible ? If so please post the Coding , no matter in what ever language it may be written.Thanks in Advance


Check this php function http://ca3.php.net/manual/en/function.imagecolorat.php
Requires the GD Library, which is fairly standard for a PHP installation.
User Notes at that link include some scripts.


Thank you for your help and i have found a solution, the same can be obtained using C# , C# has an inbuilt class known as the Bitmap and with C# i was successfully able to code a program to get the mean RGB color by giving the Image location as input.


You can also do that in C++ using CImg library..


Please help

Finding The Rgb Color Of An Image


Replying to nirmaldaniel


Dear Nirmaldaniel,


I read your reply on the C++ used for the color detection. If possible

Could be please send me the codes coz I am also looking for similar probelm.


Thank you..Please help me



-question by Catherine


!!!HelpFinding The Rgb Color Of An Image

Replying to bluedragon

Dear BrotherI want to take some information about the RGB file.How can I read the RGB file and also tell me how I create the new RGB file in C/ C++.I will thanks to you

-Muhammad Mohsan Shabbir


RGB creation and recreation ...Finding The Rgb Color Of An Image

I have below VB program which can segregate the are G B values and the same tries to recreate as the original file.  Recreation is done using C++; if you want you can collect it from me.

  Dim bmpObj As Object   Set bmpObj = CreateObject("jpeg.CJpegImage")   'CALL COMImageSize (Me.ImgJPG.ScaleWidth, Me.ImgJPG.ScaleHeight)   bmpObj.SetFormatSize Me.PicSourceImage.ScaleWidth, Me.PicSourceImage.ScaleHeight   With picSourceImage   For ctrY = 0 To Me.PicSourceImage.ScaleHeight - 1   For ctrX = 0 To Me.PicSourceImage.ScaleWidth - 1   Pixel = GetPixel(.HDC, ctrX, ctrY)   myGRed(ctrX, ctrY) = RgbColor(Pixel).Red   myGGreen(ctrX, ctrY) = RgbColor(Pixel).Green   myGBlue(ctrX, ctrY) = RgbColor(Pixel).Blue   bmpObj.SetJpegImageData myGRed(ctrX, ctrY), myGGreen(ctrX, ctrY), myGBlue(ctrX, ctrY)   Next ctrX   Next ctrY   End With   bmpObj.SaveJpegImage (App.Path & "ProcessedImage" & Left(Me.TxtFileName.Text, InStr(1, Me.TxtFileName.Text, ".") - 1) & ".Jpg")

-reply by Srinivasan


conversion of rgb to hsiFinding The Rgb Color Of An Image

Replying to (G)SrinivasanI am doing this project actually showing a movie in opengl but I am using the green screen where I need to convert the rgb of the pictures to hsi in c++ and reverse. Can you help me?

-reply by pugsy


As this was posted in C/C++ I feel it should be mentioned that if on windows, there are the windows GDI functions/classes to use and thus, no need for 3rd party libs or .NET.

#include <gdiplus.h>...Bitmap* bm = new Bitmap("image.jpg");...// bm->LockBits() or bm->GetPixel()...delete bm;...