Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
How can I draw candle charts in C#? Does anybody has any examples with a nice interface?
I've used the MSChart and found it to be pretty good. It supports candlestick charts. I've used ZedGraph as well but found a few graphical anomalies showed up on my charts but they were otherwise good as well.
I use this for stock data but its in VB
With Chart1.ChartAreas("myarea")
.AxisY.Maximum = (Math.Ceiling((HighValue * 100)) / 100)
.AxisY.Minimum = (Math.Floor((LowValue * 100)) / 100)
.AxisY.LabelStyle.Format = "{0.00}"
End With
Dim s1 As New Series
With s1
.ChartArea = "myarea"
.ChartType = SeriesChartType.Candlestick
.XValueType = ChartValueType.String
.YValueType = ChartValueType.Single
.YValuesPerPoint = 4
.CustomProperties = "PriceDownColor=Red, PriceUpColor=Green"
End With
For i = Globals.GraphColumns - 1 To 0 Step -1
OutData = Data_Array.Item(i)
s1.Points.AddXY(OutData.thedate, OutData.high, OutData.low, OutData.close, OutData.open)
Next
Chart1.Series.Add(s1)
Me.Controls.Add(Chart1)
ZedGraph is a very easy-to-use LGPLed charting library that can handle candlestick charts.
If you need to save an image to disk, it can do that. If you need to display an interactive graph that supports zooming/panning, it can do that as well with the excellent ZedGraphControl control.
I'm using the .netCharting library for this and it's pretty good. It supports all sorts of charts - candle included. One thing to watch out for is that with the current version (5.3) you have to reverse the high and low price - a pretty ugly and obvious bug. It's a commercial product, but reasonably priced, so could be worth it, depending on your project.
Maybe ChartDirector can be a good solution
http://www.advsofteng.com/doc/cdcomdoc/candlestick.htm
Try xamChart Control Trial version from Infragistics.
Here is another sample at CodeProject
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
I'm currently using Bellman Ford algorithm to find the shortest paths with negative value. Is there any faster algorithm that would outperform Bellman Ford for finding shortest paths with negative values?
A simple improvement is to only check for "active" nodes instead of iterating on all of them as the naive implementation does.
The reason is that if a node didn't lead to improvements on any of its neighbors and didn't change value in last iteration there is no need to redo the computation again (it will still produce no improvements).
Pseudocode (Python, actually):
A = set([seed])
steps = 0
while len(A) > 0 and steps < number_of_nodes:
steps += 1
NA = set()
for node in A:
for nh in neighbours(node):
x = solution[node] + weight(node, nh)
if x < solution[nh]:
# We found an improvement...
solution[nh] = x
pred[nh] = node
NA.add(nh)
A = NA
A is the "active" node set, where an improvement was found on last step and NA is the "next-active" node set that will need to be checked for improvements on next iteration.
Initially the solution is set to +Infinity for all nodes except the seed where the solution is 0. Initially only the seed is in the "active" set.
Note that in case of negative-sum loops reachable from the seed the problem has no "minimum path" because you can get the total as low as you want by simply looping; this is the reason for the limit on the "steps" value.
If when coming out of the loop A is not empty then there is no solution to the minimum cost problem (there is a negative-sum loop and you can lower the cost by simply looping).
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
I've been researching on finding an efficient solution to this. I've looked into diffing engines (google's diff-match-patch, python's diff) and some some longest common chain algorithms.
I was hoping on getting you guys suggestions on how to solve this issue. Any algorithm or library in particular you would like to recommend?
I don't know what "longest common [[chain? substring?]]" has to do with "percent difference", especially after seeing in a comment that you expect a very small % difference between two strings that differ by one character in the middle (so their longest common substring is about one half of the strings' length).
Ignoring the "longest common" strangeness, and defining "percent difference" as the edit distance between the strings divided by the max length (times 100 of course;-), what about:
def levenshtein_distance(first, second):
"""Find the Levenshtein distance between two strings."""
if len(first) > len(second):
first, second = second, first
if len(second) == 0:
return len(first)
first_length = len(first) + 1
second_length = len(second) + 1
distance_matrix = [[0] * second_length for x in range(first_length)]
for i in range(first_length):
distance_matrix[i][0] = i
for j in range(second_length):
distance_matrix[0][j]=j
for i in xrange(1, first_length):
for j in range(1, second_length):
deletion = distance_matrix[i-1][j] + 1
insertion = distance_matrix[i][j-1] + 1
substitution = distance_matrix[i-1][j-1]
if first[i-1] != second[j-1]:
substitution += 1
distance_matrix[i][j] = min(insertion, deletion, substitution)
return distance_matrix[first_length-1][second_length-1]
def percent_diff(first, second):
return 100*levenshtein_distance(a, b) / float(max(len(a), len(b)))
a = "the quick brown fox"
b = "the quick vrown fox"
print '%.2f' % percent_diff(a, b)
The Levenshtein function is from Stavros' blog. The result in this case would be 5.26 (percent difference).
In addition to difflib and other common subsequence libraries, if it's natural language text, you might look into stemming, which normalizes words to their root form. You can find several implementations in the Natural Language Toolkit ( http://www.nltk.org/ ) library. You can also compare blobs of natural language text more semantically by using N-Grams ( http://en.wikipedia.org/wiki/N-gram ).
Longest common chain? Perhaps this will help then: http://en.wikipedia.org/wiki/Longest_common_subsequence_problem
Another area of interest might be the Levenshtein distance described here.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am working on an algorithm to extract diffrences between two images with diffrent qualities for example you have a photoshop file which is created by a designer and then you print it out with some devices and you have scaned it and saved it as a bmp file.
the main question is how we can compare these two images?
it is not possible two compare pixel by pixel, because in scaned version many objects have changed for example lines become thicker.
my idea is to find any shapes in two images then compare them based on location and other shape featurs but the main problem is that in low quality images it become too difficult to compare.because in low quality we have noise and after noise canceling some shapes will be lost. for example when i use open and close or morphology filters i lose some characters such as "i Q O 0" or other shapes.what is your opinion ?
you have image1 & image2 that have to compare .In both images find corners by hough transform then register two images by corners.you can use findhomogrphy() .Now the two images are the same size.In the finial you can use matchTemplate() for find difference between two images.
The suggestion of #Mostafa Sataki sounds good. An alternative would be to align the images as suggested, then use a similarity measure such as MSE or PSNR
Another possibility would be to try to match keypoints from the two images to see if they are the same image.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I need a library to read 2D barcode (datamatrix) from images on C# project (windows Forms).
I tried using some SDKs, but the SDKs I tried are not free.
Is there any free SDK for reading 2d Barcode from images?
There's an example available:
using DataMatrix.net; // Add ref to DataMatrix.net.dll
using System.Drawing; // Add ref to System.Drawing.
[...]
// ---------------------------------------------------------------
// Date 180310
// Purpose Get text from a DataMatrix image.
// Entry sFileName - Name of the barcode file (PNG, + path).
// Return The text.
// Comments See source, project DataMatrixTest, Program.cs.
// ---------------------------------------------------------------
private string DecodeText(string sFileName)
{
DmtxImageDecoder decoder = new DmtxImageDecoder();
System.Drawing.Bitmap oBitmap = new System.Drawing.Bitmap(sFileName);
List<string> oList = decoder.DecodeImage(oBitmap);
StringBuilder sb = new StringBuilder();
sb.Length = 0;
foreach (string s in oList)
{
sb.Append(s);
}
return sb.ToString();
}
You'll need DataMatrix.net!
Best free Datamatrix coder\decoder that i've used is libdmtx: http://www.libdmtx.org/ . It has c# wrapper, so feel free to use it. I can't write sample code right now, but if you won't be able to handle it yourself, i'll help you a bit later with that.
EDIT:
libdmtx comes with console utils - if you will be able to read your barcodes with console app, you surely will read it using code.
EDIT2:
Here's code samples: http://libdmtx.wikidot.com/libdmtx-net-wrapper
I wonder if you have pictures containing some other info, except the barcode. The thing is - i don't know any free\open source lib to handle finding barcode on a picture, containing any other data properly.
And here's the link to other datamatrix implementations: http://www.libdmtx.org/resources.php
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I find a algorithm writen by javascript,now i want to convert it to C#,
Any tool can do this?
Well, you could start with Javascript.Net to try your code within another application before rewriting/converting it. Whatever you do, don't rely on auto-generated code for an algorithm of any importance.
If memory serves, there was actually a flavor of JavaScript that ran on the .Net CLR. I don't think it ever caught on.
Using javascript.net or jscript with .net Reflector, will save you brain and keyboard, may be
There is a dialect of JavaScript called UnityScript that can be converted into C# using the UnityScript-to-C# converter.
I also wrote a tool called universal-transpiler can convert a small subset of JavaScript into C# and several other languages.
Input in JavaScript:
function add(a,b){
var g = [3,4,5];
return a+b+(g[0])+(g.length);
}
function divide(a,b){
return a/b;
}
Output in C# from universal-transpiler:
public static int add(int a,int b){
int[] g={3,4,5};
return a+b+(g[0])+(g.Length);
}
public static int divide(int a,int b){
return a/b;
}