Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
In this image there are some lines and some elliptical (circular) patterns on these lines.
I want to detect these elliptical patterns in C# using Emgu.CV and OpenCV functions. Can any body please help me where should I start and what should I do first to detect these elliptical patterns?
a very simple method that still finds most of the bubbles:
threshold the image
find contours in threshold image
filter out all contours that are too small and draw all others filled
erode that mask until the vertical lines have disappeared
count the new number of blobs/contours and dilate if you need the original size
steps look like these:
thresholded (50)
contours (all)
contours (filtered mask)
eroded mask
dilated mask and overlay
as you can see it is very simple and finds most of the bubbles. If you dont know how often you have to erode, you can detect the vertical lines with HoughLines first.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I have a picture and in my picture there are several drops of blood of different colors. I want to get the color of each drop of blood (either by color name, or by color code)
you can use this to get each Pixel Color in image
using System.Drawing;
Bitmap b = new Bitmap( "Image file Path" );
Color x = b.GetPixel( x, y );
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I havent found anything in this librairy to resize an image. In the object Novacode.Image there is very few methods / properties and none of them seem to be usefull to resize an image.
If anyone has a clue on how to do it, it will be very usefull
Thank you
Ok, actually you cant resize the Novacode.Image object BUT you can do this :
DocX document = DocX.Load("D:\\Template.docx");
Novacode.Image drawing = document.AddImage(#"\images\img.png");
Picture pic = drawing.CreatePicture();
pic.Height = 340;
pic.Width = 310;
document.Paragraphs[0].InsertPicture(pic, 0);
document.SaveAs(#"docs\TemplateCompleted.docx");
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am making a program in C#. I want it to do something if image is detected on screen. For example let's say I am making a game bot. And my health is image on my screen filled with green color like so:
FULL HP BAR
And something took my hp to this level:
TAKEN HP BAR
If the C# detects the image with hp taken, do something ... Is this possible and how can i do it ? Thanks.
I wrote the bot for game. To detect when life become low you can scan a certain pixel color and test it with the sample value (for example you can capture pixel in the middle of your rectangle and if it is green you have more then half of life).
Also I made screenshots, cut some areas and kept them as bitmaps. In a game I loaded them, then I made screenshot every second and checked if some of these bitmaps appeared in the screenshot.
To capture the screen in C# you can use CopyFromScreen method of Graphics:
var screen = new Bitmap(Screen.PrimaryScreen.Bounds.Width,
Screen.PrimaryScreen.Bounds.Height,
PixelFormat.Format32bppArgb);
var graphics = Graphics.FromImage(screen );
graphics.CopyFromScreen(Screen.PrimaryScreen.Bounds.X,
Screen.PrimaryScreen.Bounds.Y,
0, 0,
Screen.PrimaryScreen.Bounds.Size,
CopyPixelOperation.SourceCopy);
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I have a set of points (x, y) that I would like to know if it forms a closed region (within a rectangular 2D raster). This seems like a simple problem, but after a half-hour of googling, I was unable to find an algorithm that addresses this issue. Is there a known algorithm for this problem?
A routine written in C++ or C# (or even pseudo code) would be ideal.
EDIT:
The specific problem I am dealing with here is a drawing program where the application user is supposed to be drawing a boundary around a region of interest. I want to warn the user if the boundary that they've drawn does not form a closed region.
It seems you want to know whether a given set of points contains a closed region. Luckily there's an easy and flexible answer for this :)
Let's say that the point set you are given is the set of black pixels that have been drawn on a white background. Simply perform a black flood-fill starting from a known-outside point (e.g. (0, 0)). Now see whether any white pixels remain in the image. If so, then the originally drawn pixels contained at least 1 closed region.
If you've ever drawn anything with a mouse in a crude bitmap painting program, you'll know that it's easy for small defects to form -- e.g. if you're drawing a freeform line, turn sharply, and continue the line in a different direction, it might be that you accidentally create a tiny bubble of 1 or 2 white pixels. Luckily this algorithm can easily take these into account: just count the number of white pixels that remain after the flood fill, and return "YES" only if this count exceeds some chosen threshold greater than 1. (You might want to make the threshold proportional to the number of points in the set, to allow a given number of defects per pixel drawn.) For even more control, after flood-filling, you could identify and delete all islands of white pixels below some fixed "defect threshold" size. Detection can be done by tentatively trying a flood-fill from each pixel in the image, and stopping (and undoing) once it exceeds the threshold size.
All of these operations, including detection and removal of small defects, take only time linear in the number of pixels in the image. Flood fill is a simple and fast algorithm, but if you wanted a bit more speed, you could flood-fill just the bounding box of the given set of pixels, expanded outwards by 1 pixel on each side.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
My apologies if I'm missing something simple here, but I've running in circles for some time now. In short, I'd like to update the panel graphics (panel will contain simple shapes like circles and rectangles) every time a button is pressed. The code would look something like this:
private void PanelGraphics()
{
ClearThePanel(); //empties the panel
FillThePanel(); //draws new shapes in the panel
}
The function would be then called every time a button is pressed, and I understand button_events well enough so that's not a problem. However, I have no idea how to pull off the PanelGraphics() function, and a few links about panel_paint events didn't help me much.
You can draw to the panel by creating a graphics controller to it.
Graphics g = panel.CreateGraphics();
You can then use the Graphic class's plethora of methods to draw whatever you want to the panel
g.DrawCurve(parameters);
g.DrawEllipse(parameters);
g.DrawLine(parameters);
g.DrawRectangle(parameters);
To clear the panel the easiest way is to draw a box the colour of the background to the panel
g.DrawRectangle(new Pen(panel.BackColor), new Rectangle(new Point(), panel.Size));