|
mm-2k wrote: I have been searching the for "image histogram" and "image quantization", because it seams like these are the most common terms. No luck yet.
Why? It seams really the best way ...
You will have probally only to perform the algorithms setting thresholds..not more
Russell
|
|
|
|
|
Hi Russel,
Thanks for the reply.
I am searching for an example or description on how to do it, but haven't had any luck yet.
|
|
|
|
|
a simple example for "Histogram":
* convert the image in RGB (same if HSV)
* find min and max value for R ,G ,B in all the image
* quantize (for example using 50 slices per color) the range of values in that min-max interval (for every 3 colors, so you will fix 50x50x50 cubes/volumes)
* then look to the pixel of the image and count how many time a color fall in a cube
* when finished the cube with the greater number of pixel inside is the color that you are seraching
*eleway you can analise separately R, G and B. In this way you will have 50+50+50 linear intervals, not volumes.
Russell
|
|
|
|
|
Can you expand on the higher purpose of this? and on the kind of pictures?
From your requirements/intentions you probably first will have to decide which is the
right color space to use (RGB, HSL, just hue, ...), then the required accuracy.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hi Luc,
Thanks for the reply.
I want to use this, to categorize images (web images - only JPG/RGB) by it's color. This will be used on a e-commerce site. When a user uploads a image in the backend, i want to extract the most common used color of the current image (eg. 5-10 colors per image). These values will be stores in the database, with a reference to the image. This will allow me to make a categorizing of the images in the frontend.
If you look at this page (http://goincase.com/products/), on the right corner, you can "Browse all by color". This is what i want to achieve - automatically when images is uploaded.
Best regards
Carsten Petersen
|
|
|
|
|
Hi Carsten,
I have two comments:
1.
the number of colors in the categorization is very limited and they color collection seems
to be predefined. If so, one only needs to determine in which category a picture would fit
best. One way of doing this is by calculating some "error function" for each of the
categories (say the sum over all pixels of the squared deviation between actual pixel
and category color). The main problem remaining is to determine the relevant pixels:
one has to exclude the background, and all zones that are not part of the selectable color
(display, keyboard, whatever).
2.
I am not convinced at all they did it in an automatic way; seems to me if Ipod sleeve
so and so comes in "green" and "blue" according to the manufacturer, they make sure to
have two pictures and add them to the "green" and "blue" category respectively.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
True, i want to show these colors when the image is uploaded. The user can then select one of the colors, or define one manually. This is only for guidance.
|
|
|
|
|
mm-2k wrote: Is there any way to get the most common used color of an image (jpg) in C#/VB? I have been searching the for "image histogram" and "image quantization", because it seams like these are the most common terms. No luck yet.
I am surprised, image histograms are very common. However, if you are looking for tri-color histograms as apposed to single channel (red only, blue only, etc.), that is why. You will find that in most natural images (not created artificially on a computer, or touched up), that most true color (RGB) references will have a very low count. Why? Well, to be frank, it is because in 24bit color (RGB, 8 bits each), any given single color reference is 1:16,777,216 and a given image such as 1024x768 is only 786,432 pixels. Even going up to a relatively large image size, 2921 x 2184 which is a 6megapixel image, the odds of having any given color combination more than once is very low. So doing a color histogram on the complete 24bit color value will generally produce a histogram count of 1 or 0 for all colors with the occasional exception.
If you have seen the posters that use images as tiles to reconstruct another much larger image, these are done by classifying the over-all hue of the image. A histogram and color analysis is easy on a single channel, since it is just a series of 256 values. Over a six megapixel image or even something as small as a 1024x768 image, the number of counts of any single value are easily histogrammed and classified.
Plus as mentioned above by others, you can change color-space to get other channel references. Common channel references are RGB CMYK and YUV. You simply convert color space to the appropriate system, then examine your histogram on any given channel. You can even do all three color spaces and histogram each channel to see which classifies your image best.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
1. allocate an array of 256x256x256 integers. set them all to 0.
2. for every RGB pixel in the image, increase ar[r * 256 * 256 + g * 256 + b] by one.
3. find the element in the array with the highest value.
|
|
|
|
|
confound it; how do i just make my opengl windows and track the mouse state ?
I'm compileing sample opengl code ok in visual studio, but now i'm getting linkage errors. Searching (find|grep for those who used to know) through my little iddy biddy laptop turns up no .lib or .dll (libogl* or gl*.dll).
What is the relationship between runnin openGL and .net 1.1, .net 2, .net 3 and .net 3.5. What is .net anyway ? It seems that the old demos like older .net.
But i'm trying to understand what is going on. I want to bring forward my old c++ code and rewrite it for the brave new world (kids these days!).
I'm remotely controlable for someone to take the time to skype in and unyte to my keyboard and show me the errors of my old fashioned ways.
I'm looking forward to using a modern c++ compiler and making all sorts of math types (with and without STL).
My other problem is getting lots and lots of shared memory. I will move up to a 64 bit big pointer system soon. First I need to get my toes wet with VS 8 and this funny new world.
Cheers!
dr. K
-----------
libcmtd.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
gleasvw.obj : error LNK2019: unresolved external symbol __imp__glFlush@0 referenced in function "public: void __thiscall CGLEasyView::DrawScene(void)" (?DrawScene@CGLEasyView@@QAEXXZ)
gleasvw.obj : error LNK2019: unresolved external symbol __imp__glCallList@4 referenced in function "public: void __thiscall CGLEasyView::DrawScene(void)" (?DrawScene@CGLEasyView@@QAEXXZ)
gleasvw.obj : error LNK2019: unresolved external symbol __imp__glColor3dv@4 referenced in function "public: void __thiscall CGLEasyView::DrawScene(void)" (?DrawScene@CGLEasyView@@QAEXXZ)
gleasvw.obj : error LNK2019: unresolved external symbol __imp__glRotated@32 referenced in function "public: void __thiscall CGLEasyView::DrawScene(void)" (?DrawScene@CGLEasyView@@QAEXXZ)
gleasvw.obj : error LNK2019: unresolved external symbol __imp__glTranslated@24 referenced in function "public: void __thiscall CGLEasyView::DrawScene(void)" (?DrawScene@CGLEasyView@@QAEXXZ)
gleasvw.obj : error LNK2019: unresolved external symbol __imp__glLoadIdentity@0 referenced in function "public: void __thiscall CGLEasyView::DrawScene(void)" (?DrawScene@CGLEasyView@@QAEXXZ)
gleasvw.obj : error LNK2019: unresolved external symbol __imp__glMatrixMode@4 referenced in function "public: void __thiscall CGLEasyView::DrawScene(void)" (?DrawScene@CGLEasyView@@QAEXXZ)
gleasvw.obj : error LNK2019: unresolved external symbol __imp__glColorMaterial@8 referenced in function "public: void __thiscall CGLEasyView::DrawScene(void)" (?DrawScene@CGLEasyView@@QAEXXZ)
gleasvw.obj : error LNK2019: unresolved external symbol __imp__glClear@4 referenced in function "public: void __thiscall CGLEasyView::DrawScene(void)" (?DrawScene@CGLEasyView@@QAEXXZ)
gleasvw.obj : error LNK2019: unresolved external symbol __imp__glClearColor@16 referenced in function "public: void __thiscall CGLEasyView::DrawScene(void)" (?DrawScene@CGLEasyView@@QAEXXZ)
gleasvw.obj : error LNK2019: unresolved external symbol __imp__glEnable@4 referenced in function "public: void __thiscall CGLEasyView::DrawScene(void)" (?DrawScene@CGLEasyView@@QAEXXZ)
gleasvw.obj : error LNK2019: unresolved external symbol __imp__glEndList@0 referenced in function "public: void __thiscall CGLEasyView::PrepareScene(void)" (?PrepareScene@CGLEasyView@@QAEXXZ)
gleasvw.obj : error LNK2019: unresolved external symbol __imp__glEnd@0 referenced in function "public: void __thiscall CGLEasyView::PrepareScene(void)" (?PrepareScene@CGLEasyView@@QAEXXZ)
gleasvw.obj : error LNK2019: unresolved external symbol __imp__glVertex3d@24 referenced in function "public: void __thiscall CGLEasyView::PrepareScene(void)" (?PrepareScene@CGLEasyView@@QAEXXZ)
gleasvw.obj : error LNK2019: unresolved external symbol __imp__glNormal3d@24 referenced in function "public: void __thiscall CGLEasyView::PrepareScene(void)" (?PrepareScene@CGLEasyView@@QAEXXZ)
gleasvw.obj : error LNK2019: unresolved external symbol __imp__glBegin@4 referenced in function "public: void __thiscall CGLEasyView::PrepareScene(void)" (?PrepareScene@CGLEasyView@@QAEXXZ)
gleasvw.obj : error LNK2019: unresolved external symbol __imp__glNewList@8 referenced in function "public: void __thiscall CGLEasyView::PrepareScene(void)" (?PrepareScene@CGLEasyView@@QAEXXZ)
gleasvw.obj : error LNK2019: unresolved external symbol __imp__wglMakeCurrent@8 referenced in function "public: void __thiscall CGLEasyView::PrepareScene(void)" (?PrepareScene@CGLEasyView@@QAEXXZ)
gleasvw.obj : error LNK2019: unresolved external symbol _gluErrorString@4 referenced in function "public: void __thiscall CGLEasyView::OutputGlError(char *)" (?OutputGlError@CGLEasyView@@QAEXPAD@Z)
gleasvw.obj : error LNK2019: unresolved external symbol __imp__glGetError@0 referenced in function "public: void __thiscall CGLEasyView::OutputGlError(char *)" (?OutputGlError@CGLEasyView@@QAEXPAD@Z)
gleasvw.obj : error LNK2019: unresolved external symbol __imp__wglCreateContext@4 referenced in function "protected: int __thiscall CGLEasyView::OnCreate(struct tagCREATESTRUCTW *)" (?OnCreate@CGLEasyView@@IAEHPAUtagCREATESTRUCTW@@@Z)
gleasvw.obj : error LNK2019: unresolved external symbol __imp__glViewport@16 referenced in function "protected: void __thiscall CGLEasyView::OnSize(unsigned int,int,int)" (?OnSize@CGLEasyView@@IAEXIHH@Z)
gleasvw.obj : error LNK2019: unresolved external symbol _gluPerspective@32 referenced in function "protected: void __thiscall CGLEasyView::OnSize(unsigned int,int,int)" (?OnSize@CGLEasyView@@IAEXIHH@Z)
gleasvw.obj : error LNK2019: unresolved external symbol __imp__wglDeleteContext@4 referenced in function "protected: void __thiscall CGLEasyView::OnDestroy(void)" (?OnDestroy@CGLEasyView@@IAEXXZ)
C:\Documents and Settings\karron\My Documents\Visual Studio 2008\Projects\helo2\Debug\gleasy.exe : fatal error LNK1120: 25 unresolved externals
dr d b karron
|
|
|
|
|
do you have the platform SDK installed? Any of this[^] help?
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
Hi
I need to impliment functionality for online image editing that support add text to image, rotate image, ovaerlap new image to existing image, zooming image, crope.
Please give me refferance of such website that can provide tool for image editor.
I want same functionality as in http://www.buildasign.com/PowerDesign.aspx?T=4476553256504A7644356F3D
I am finding tool or source in GDI+ that support this functionality.
If you know any component, free or paid please give me refferance.
Please help me.
Thanks in advance
Mustakim Mansuri
|
|
|
|
|
Hi,
I am trying to do some graphics with Direct3D for Windows Mobile.
Everything works fine until I create a texture:
texture = TextureLoader.FromFile(dev, "My Documents\\abc.bmp", 200, 200, 0, Usage.None, Format.A8R8G8B8,Pool.Managed,
Filter.None, Filter.None, 0);
This throws the InvalidOperationException with no further details how to solve it.
The alternative ways to create a texture lead to the same exception:
texture = TextureLoader.FromStream(dev,
System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("Project1.abc.bmp"));
texture = TextureLoader.FromFile(dev,"Project1.abc.bmp");
Could someone help me with this please?
I would very appreciate any advice!!!
Thank you,
Katerina
|
|
|
|
|
Can any tell me how to start programming or reading of display drivers (xp or vista )any link or any tutorial or any forum where i can get help. i dont have any basic knowledge of drivers too.
thanx
prashant jain malviya national institute of technology
|
|
|
|
|
What exactly are you trying to do ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hello, I'm not exactly certain that this is the riht place to post this. If I am wrong, could someone please redirect me?ve never done graphics programming,
Anyhow, here's my question. What can I use to print graphics to the screen in Unix with C++? I'm rather restricted on platform and compiler choice, but other than that I'm free to do what I want. I'm telnet-ing into a unix server, so I don't know if that will affect my ability to download libraries like OpenGL.
I've never done graphics programming so everything here is somewhat new to me. If I can gain to draw and move bitmaps on the screen it will be enough.
Thanks to anyone who helps or at least pushes me in the right direction.
|
|
|
|
|
MartyExodus wrote: What can I use to print graphics to the screen in Unix with C++?
MartyExodus wrote: I'm telnet-ing into a unix server, so I don't know if that will affect my ability to download libraries like OpenGL.
1st off if you are executing via telnet, you are stuck with Xwindows. OpenGL doesn't remote well. 2nd I wouldn't recommend installing OpenGL into a Unix box unless you have full control over that box, A) I doubt it is possible without root access and B) it's not for the faint hearted.
MartyExodus wrote: If I can gain to draw and move bitmaps on the screen it will be enough.
That definitely sounds simple enough to be an X-windows job. http://trolltech.com/products/qt[^] will let you use Xwindows as a front-end and they have some bitmap manipulation routines as well as 2D drawing. OpenGL will take you beyond that stage into 3D textured environments multi-frame rendering and complex 3D shapes with rotations.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
Be kind please.
The simple C# program below runs correctly until it encounters a "generic error in GDI+" exception. This seems to happen about 500 images into the list, regardless of the actual image data. I have several questions here, insight to any are appreacited. My intent is to use the GDI+ routines to get basic image properties (width and height) from directories containing images. I can't find any smoking gun in the exception data. The error code is -2147467259. Thanks in advance for any direction.
Q1) What is really going wrong here? I can catch the execption, but I don't know what to do with it.
Q2) Correctness and functionality is more important; but isn't there a more efficicent way to do this without a creating a new Bitmap object inside the inner loop?
<code>
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
namespace ListFiles1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("This program lists all the files in the directory");
System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(@"c:\image");
foreach (System.IO.FileInfo file in dir.GetFiles("*.jpg"))
{
Bitmap myBitmap = new Bitmap(file.DirectoryName + @"\" + file.Name);
Console.WriteLine("{0}, {1}, {2}, {3}",
file.Name, file.Length, myBitmap.Width, myBitmap.Height);
}
Console.ReadLine();
}
}
}
</code>
|
|
|
|
|
Hi,
are you sure it is 2147467259 and not -2147467259 ???
that one equals 0x80004005 which is simply good old E_FAIL
GDI+ is very good at error handling, everything is called "general error" and
the error number does not tell anything.
In your case you are running out of memory.
Didn't they tell you you should Dispose of all objects you no longer need when
such objects are instances of a class that offers a void Dispose() method ?
You are polluting your entire system!
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Luc Pattyn wrote: In your case you are running out of memory.
Didn't they tell you you should Dispose of all objects you no longer need when
such objects are instances of a class that offers a void Dispose() method ?
I guess I am naive to think that C# garbage collection would "just work". More likely this is my problem for using GDI+ within C#. So the challenge for me remains to either:
a) Reuse a single instance of myBitmap.
b) Invoke the Dispose() method so too many objects don't overrun the heap.
I'm not sure I know how to do either, but will try.
|
|
|
|
|
Getting a mysterious error message is a good indication naivety has to be scaled back.
Invoking a method with no parameters and no return value is rather easy, reusing a
Bitmap does not sound like a good idea.
ss42a wrote: I'm not sure I know how
Then that's why they invented "documentation", available under either MSDN or Google.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
The next likely cause for a GDI+ general error is a bad image file.
Suggestion: log the files one by one before creating the new Bitmap and/or
show the filename in the catch construct.
The (last) one shown is the suspicious one; try loading just that one; or try
double-clicking it.
BTW: IIRC GDI+ can't handle 1-bit-per-pixel images.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Thank you!
It turns out that some JPEG image files; which look fine as thumnails, display correctly; may have some kind of defect that causes GDI+ to throw an error. This is good, since I'm using the try/catch blocks to isolate them. Thank you for your help.
Below is the modified code which works fine; but coughs up an occasional image file that may look fine, but has some internal defect that confuses the GDI+ decoder.
<br />
using System;<br />
using System.Collections.Generic;<br />
using System.Text;<br />
using System.Drawing;<br />
<br />
<br />
namespace ListFiles1<br />
{<br />
class Program<br />
{<br />
<br />
static void Main(string[] args)<br />
{<br />
<br />
System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(@"c:\image");<br />
<br />
foreach (System.IO.FileInfo file in dir.GetFiles("*.jpg"))<br />
{<br />
<br />
try<br />
{<br />
Bitmap myBitmap = new Bitmap(file.FullName);<br />
Console.WriteLine("{0}, {1}, {2}, {3}", file.Name, file.Length, myBitmap.Width, myBitmap.Height);<br />
myBitmap.Dispose();<br />
}<br />
catch (Exception e)<br />
{<br />
Console.WriteLine("*************** Exception Caught for {0}", file.FullName);<br />
Console.WriteLine(e.Message);<br />
}<br />
<br />
}<br />
Console.WriteLine("Any character to exit...");<br />
Console.ReadLine();<br />
}<br />
}<br />
}<br />
<br />
|
|
|
|
|
Hi there!
Is there any way to figure out the video file width and heigth before loading it using vmr9 or other filters?
Thanks in advance,
Andrew
|
|
|
|
|
Hi
you want the video width height through a filter wether vmr9 or any othr,then note that a Directhow Filter only returns the data when it will receive a MediaSample.
|
|
|
|
|