Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
in C# write the output of an image value (pixel value) at the track mouse position, also showing x coordinate and y coordinate? in computer vision. See this code below:
C#
private void OnMouseMoved ( object sender, MouseEventArgs e ) {
            //throw new Exception( "The method or operation is not implemented." );
            mMouseMoveValid = true;
            mMouseX = e.X;
            mMouseY = e.Y;
            Invalidate();
        }

So, what I need to do is modify this code to show also the output value of the image... it is something like for example : (143,213)= 230 which is x = 143, y = 213 and the image value at those coordinates is 230 pixel value.

Thank you
Posted
Updated 21-Feb-12 20:46pm
v5
Comments
Khaledc419 21-Feb-12 23:06pm    
Thank you for your answer, but this code below may help to understand my questions better:


private void OnMouseMoved ( object sender, MouseEventArgs e ) {
//throw new Exception( "The method or operation is not implemented." );
mMouseMoveValid = true;
mMouseX = e.X;
mMouseY = e.Y;
Invalidate();
}

So, what I need to do is modify this code to show also the output value of the image... it is something like for example : (143,213)= 230 which is x = 143, y = 213 and the image value at those coordinates is 230 pixel value.

Thank you for trying
krumia 21-Feb-12 23:51pm    
Is this (http://www.codeproject.com/Questions/333731/Computer-Vision-image-code-program) the same questions?

Below JQuery will resolve

JavaScript
$("body").mousemove(function(e) {
    document.Form1.posx.value = e.pageX;
    document.Form1.posx.value = e.pageY;
})
 
Share this answer
 
I read your question as "I need to get the colour value at the mouse position."

You can use Bitmap.GetPixel()[^].

But there are several drawbacks to that.
1. You need a bitmap image you can call the method on. Maybe that's not a problem but in your code sample there is nothing that points to where the OnMouseMoved event comes from, especially since Control.OnMouseMove[^] doesn't have a "d" at its end.

2. It is a rather slow operation. However, since it's used in a user-induced event, this may not hurt too much (Users are even slower than slow operations).
 
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