Chart. Drawing Graphics - c#

There was a problem with rendering charts. The first graph is a histogram, the second is a normal distribution.
When you try to draw them together, one graph offsets the second and they do not overlap.
I set rendering like this:
chart1.Series["Series1"].Points.AddXY(pointsX[i], pointsY[i]);
chart1.Series["Series2"].Points.AddXY(data[i], points_normal[i]);

Related

Win2D draw single image

I'm able to fill a rectangle with an image and i apply a mask on top of the image using this code
args.DrawingSession.FillRectangle(rect, imgRnd, mask);
i need to apply some transform to this image, i'am able to do that with no issue, but i have encounter a strange issue, the last pixel is repeated.
i have used
imgRnd.ExtendX = CanvasEdgeBehavior.Wrap;
imgRnd.ExtendY = CanvasEdgeBehavior.Wrap;
and the image is repeated continuously.
My question is : there is a way to draw one time the image disabling and ExtendX and ExtendY?
FillRectangle will always fill all the pixels within the specified rectangle. The edge behavior enum controls what value they are filled with if the image is positioned such that it does not completely cover the rectangle being drawn.
How exactly are you transforming the image? Can you change that to also transform the rectangle itself, so you won't be trying to fill pixels that aren't covered by the image?
Another option is to use image effects (Microsoft.Graphics.Canvas.Effects namespace) which give much more detailed control than FillRectangle over how multiple images are transformed, combined, etc.

YLScsDrawing Antialiased Edges

There's a neat little library called YLScsDrawing that allows you to skew a bitmap between four corners, and then draw it. Unfortunately, whenever I attempt this, my rectangular bitmap always has incredibly aliased edges, even with IsBilinearInterpolation = True. How could I go about changing this library so that it antialiases the edges?
An example of what I mean can be found below. Look at the top of the green line.

blob detection algorithm in aforge and C#.net for tiff image

I have to extract the red mark graph using Aforge blob extraction method but I am unable to extract that particular grid in order to read it.
This task may be pretty simply solved without further AForge using.
If all grids in your sample have a similar structure: i.e. homogeneous grid with vertical-horizonal graphic of function, you can use following algorithm:
Calculating white pixel density for vertical direction as you can see at image below. It's just a normalized value of sum of all RGB components in each horizontal line (Dont know what's name of it. If anybody knows it, please report).
You must extract y-axis values with lowest white pixel density and ignore y-axis values in green ellipses. If this minimums has not been founded, you must consider values in green ellipses too. If in considered y-axis values there are white pixels at right in image too many, just ignore it. Otherwise, congrats! We found segment of black line until right angle.
After that this process must be repeated for next horizontal line detection until end of image.
Construction of final function from founded horizontal lines.
If you want to just retain the graph in the grid and remove all other lines or line segments and if your image is a sample of all the images that you are planning to process, then I see two options to try out:
1) If there is a difference in greyscale threshold of area which is not having graph line to that of graph line, then use that and apply one of the Thresholding APIs of Aforge.Net, like IterativeThreshold.
2) You may try errosion API of AForge.Net and iterate that for N times, until all other lines are eroded except the graph line. If graph line becomes lighter due to erossion, apply Dillation on top of it.

Line not visible in zedgraph - How to create overlapping filled line graphs using zedgraph such that all the curves and their fills are visible?

I am creating a line graph using zedgraph which contains multiple lines and all of them are filled with labels displaying the data points. There are times when one of the lines is not visible at all but only the data point labels for that line are visible. I think this happens when the data is such that one line completely envelopes the other in terms of area covered and the order of rendering for the lines is such that the inner line is rendered before the container line. This I think is making the inner line invisible except for its data point.
So my question is:
How using zedgraph can I ensure that all portions of the filled curves along with their lines are rendered properly irrespective of their filled overlapping areas being subsets of each other and the order in which the curves are rendered?
How using zedgrapgh can I force the overlapping portions of the curves to display a fill color that is a resultant of the individual fill colors for the curves like in the chart image I found on google charts demo page below?
SOLVED!! - The only thing to do was add the alpha channel transparency to my line curve fills and everything else gets sorted automatically. Hope this helps someone.

screen color filtering

I want to create a filter over a specific area of the screen to perform filtering opertions.
Examples what a filtering opertion might be:
    - inverting (e.g. change black pixel to white pixels, red to cyan)
    - masking pixels (e.g. mask = ff0000; input c79001 -> c70000)
    - operations like photoshop's layer effects
Here is an example of what it should look like:
http://img443.imageshack.us/img443/1462/overlayk.png
Does anyone know how to perform this under Windows OS.
(my prefered language is C#)
Thanks!
Depending on how fast you need the "filter" to update, a quick and hacky way is just to get a screenshot using CopyFromScreen while your filter window is invisible, apply the filter to the image data, and then set the filter window to display the image data.
If you want to do it without having to hide the window first, you'll probably need to do something like http://www.codeproject.com/KB/system/snapshot.aspx where you capture individual windows.
An even trickier but potentially faster thing to do, and requiring nearly complete use of p/invoke win32 calls, would be to not have a window at all, get the required capture windows based on their coordinates, capture the images as above, and then draw directly to the screen DC.
To clarify: you want an area of the desktop, not just within the bounds of your window, to be under your control allowing you to apply a per-pixel filter. If that's the case, I think what you need is DirectDraw using the XNA libraries. WPF MAY get you what you need, but WinForms will most likely not. There are third party tools as well.
If you want this capability only within the bounds of your application's window, for instance in a drawing application, it gets far easier. Every class in the Windows.Forms namespace that inherits from Control exposes a CreateGraphics() method. This method returns an object representing a drawing surface covering the screen area of the control, and is the basis for just about anything you want to do on a window involving custom graphics (and internally, it's used to draw the controls in the first place).
Once you have the Graphics object, you can draw Images on it. A popular method of drawing custom graphics like animations or games is to do the actual drawing on a Bitmap object (derived from the abstract Image) and then when you're done, draw the Bitmap on the Graphics area. This is done to reduce flicker; if the graphics area is shown to the user while it is being drawn on, the user will only see the complete image for a split second before it is "wiped" and redrawn, and shapes drawn halfway through will be there one moment and gone the next as they wait to be drawn. Drawing to a bitmap, then showing the Bitmap on the screen when you're done, means the user sees a complete image at a time.
You can extend this using transparency features to create multi-layered images. Have a Bitmap for every layer you wish to manipulate. Work on them seperately, then draw each of them, in their proper order from back to front, onto a master Bitmap, and draw that Bitmap on the screen. This allows you those PhotoShop-type manipulations where a part of the image is one layer, and can be manipulated independently of all others.
As for per-pixel filtering, Bitmap objects expose GetPixel() and SetPixel() methods, which allow you to grab the color of a single pixel, perform a filter calculation, and re-draw it. This process will be totally unaccelerated, and so limited by your CPU speed, but allow very fine control of your image, or repetitive tasks like your filters.

Categories