Split image in parts - c#

I want to be able to reproduce something like this image (taken from NBA.com )
What I have :
- A court with the white lines
- A list of Position for each shot and I know if they are made or missed.
But I'm stuck on the method to realize the image :
Should I create images for each part of the field using photoshop/paint.net and then color it in c# ?
Of course the best way would be to have an equation for each part so I can check easily if the position is in and I could also draw it.
How would you do it ?

You need to first decide on how replicable you need the solution. If you need it for a 1-10 pictures, then don't bother with code- it will most surely take much longer to fine tune it.
If was to work on this specific image, I would probably take my time to find expressions for all lines to make calculations more precise though.

Related

Redraw Image every ~5ms

I have a Picturebox with...content approximately 2000x1080 pixel (yes, this makes sense for me)
Now I need to get the old content, replace it 1 pixel down and fill the empty line on the top with new data.
BUT I have to do this in a very short time ~5ms maybe a little bit more.
I get the trigger and the new data to do so.
So now the question is:
What is the fastest and cleanest way to do this?
Maybe I need to buffer the new data and write them in a more "human" time!?
You didn't mention what kind of app it is... I'm more of a web developer, but in jquery, the trick to this is to load all images with zero visibility, and then use logic to determine which to display; I would think that even if this isn't web based, you could use a similar approach... just line them all up on the screen, set the left most to be visible, and then every 5ms, make the next visible... if you were constantly adding images, just make sure you're loading them earlier, maybe during the 5ms between switches?

Animate a sprite by using two images

I would have thought this was a common desire, but I'll be damned if I can find this.
I simply want to Animate an image by swapping two images back and forth. I tried StoryBoard, but apparently you can't change the source in a storyboard. The only answer I can come up with is a Timer, which I don't think is the best way.
Edit: How do I animate image content in WPF? Came up in the "Similiar Questions" window. And while this will do what I want, it is "hackish" as the OP of it says, and it only swaps two images, what if I wanted a whole sequence of 10 or 20 or 100.
I found another post here on SO whose answer sounds like it could solve your problem: Change an image during animation using storyboard
The problem with this approach is that it also doesn't satify your request for supporting an arbitrary number of images.
I was going to propose a different method that involves databinding the Image Source to the image path, and then in code behind simply changing the path, but I haven't gotten it to work yet.
Here's an article that seems to have an elegant way to handle your requirements: http://www.codeproject.com/Articles/364529/Animation-using-Storyboards-in-WPF
Hopefully that will work for you.

Choosing between two methods of screen capturing in C#

The purpose of my Program is to capture multiple areas on the screen. I'm choosing between 2 methods to write this program:
Making one big screenshot 800x600 for further cropping (10+ areas)
Or making multiple Small screenshots with given coordinates. (10+)
what's better in terms of performance?
another question which is also related to this question is:
where do I keep all crop coordinates? I'll need at least one Column to specify numbering, Next two columns will have X and Y coordinates and last two - W and H. I was thinking about making a dictionary for a separate crop.. or maybe a table, SQL, INI, array ?? that's the second question. Easiness of use and performance are top priorities.
thanks
Edit: Rephrasing the question. What's faster - To capture a screenshot of whole screen and Crop it into 100 small areas (W:10 & H:100) OR to capture 100 small Screenshots without the need to crop anything?
The answer is to measure this. We can't know the answer without trying. It also probably depends on the exact count and sized of the screenshot areas.

Image OCR - Filtering unwanted data

Basically I'm reading vehicle license plates using tessract OCR, however despite being able to emphasise text easily enough via changing contrast, reducing noise an so on, some 'parts' of the vehicle remain on the image which does cause the OCR to throw bad results.
For example take:
I can change this easily enough, such as:
I'm looking to eliminate the edges off each plate, here's another example:
I could remove the edges using pixel manipulation algorithm, however I don't feel it's the right method, and would cause quite a lot of problems.
I've been using the following application to test various methods such as morphology and eliminating the unwanted data, so far I haven't been successful.
http://www.codeproject.com/KB/GDI-plus/Image_Processing_Lab.aspx
However someone with knowledge of this could use the application on the article above to achieve want I'm trying, so feel free to give it a try.
Thanks
Please try to use stroke width transformation concept.
This concept use to segment text from natural images.....
I already did such an algorithm. I just can say that it works great. The secret is, that you need to know that the light is coming just from one side perhaps. You cannot set the image to "black/white" just by using ONE threshold.
Detect the average luminance of parts of the image and use this luminance calculation to set the threshold for each region.
For example, if the left top is lighter, you need a lower threshold to make these parts not to bright. And if the bottom right has low light, you need to set the threshold higher to receive all existing light information.
Then, you need just to drive into the image from each side by using the method:
IsPixelAboveThreshold ?
If it is below, you are on the border, if it is above, you can say you are on the middle of the image with more brightness.
Regards

What is the best algorithm to locate a point in an image file?

I want to create a mark sheet recognizer.
Here is the description:
My system uses black and white color scheme.
The mark sheet paper has a small black rectangle on each corner and an additional small black rectangle, to determine orientation, near one of the previous rectangles.
The paper is scanned to yield an image (in bmp format for example).
The first step is to locate these five references in image as eficient as possible.
My rough idea is to trace row by row and from left to right for each row.
It sounds very slow I think.
Is there any better way to do that?
Thank you in advance.
regards,
Suugaku
You can start by searching where you typically expect to find the reference images. You can do this by keeping statistics of where they were before. In particular if you have two frames taken one after the other, the chances are the reference points won't have moved very far.
Once you have found one or more of the reference points, the position of the others becomes heavily constrained so you can make a very good guess as to where the others must lie. Each time you find a new point it provides more hints as to where the remaining points can be.
So you can start by using a bit of guesswork to find the points quickly, and revert to a line-by-line scan if that fails.
Speed is not an issue if you use the BitMap.LockBits() instance method (https://web.archive.org/web/20121203144033/http://www.bobpowell.net/lockingbits.htm). Then, all you need is a couple of hours.

Categories