|
Yes, to echo what Mark said. The way to approach us on this is to present the problem, describe what you've done to solve it, and ask why you're not getting the results you expect. Then you'll probably get some help. But to post like you're simply looking for a place to cut and paste your homework won't fly. We get plenty of queries like that and they're generally all told to take a hike, some less politely than others.
One potential problem with the method you sketched is that the lines you get after you run the Sobel and threshold is they may contain gaps for one reason or another. You may need a way to look at the partial lines and fill in the blanks. Since the problem is fairly artificial, you have a lot of prior knowledge about what you're looking for.
2 75 22 6
|
|
|
|
|
Tim Craig wrote: to post like you're simply looking for a place to cut and paste your homework won't fly
I ditto that Tim. I was going to give some input, but not now
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Well project done...basically I managed to get all algorithems done, except region search, but well in the end I used AForge .NET Framework and got the job done in the fraction of time.
Thank you all for your help and assistance.
|
|
|
|
|
Hi to all,
I want to send a video file on network (UDP) in C++. But when I do that, it doesn't receive properly.
So can anyone help me or give me an algorithm/code to send data on IP continously at a particular bitrate in C++?
Thanks & Regards,
Aniket A. Salunkhe
|
|
|
|
|
Hi
I work with some very large arrays (millions of items) in an algorithm, however, since most fields contains the value 0 I decided to use a Dictionary<int, int=""> to represent only the array's fields where the value is not 0.
Dictionary<int, int=""> means that the first int is the index of the array in which the value would appear, and the second int is the value of this index.
Now, I have two of these "arrays" that I need to compare. For each _existing_ index I need to find the difference between the arrays.
E.g. index i exists in dict1 (first dictionary) but not in dict2, thus the difference should be the value of dict1[i] alone. index i exists in both dictionaries thus the difference should be dict1[i] - dict2[i].
Now, in theory this should be possible to achieve with iterating each unique index in BOTH dictionaries only once (e.g. if an index occurs in both dictionaries it should only be iterated once)
My suggestion was that I start by getting the first item from each and compare the index of these.if they are equal I would increase both iterators.if one is higher than the other I would increase the iterator until they are equal or the other one is lower. This would be repeated until both are iterated through. Any ideas how I can do this with C# and Dictionary<int, int="">?
Any ideas? need to do this iteration as fast as possible. In C I could do some pointer magic to achieve this, but I am not familiar with C# dictionary iterators/enumerators so I have no idea whatsoever how to solve this.
modified on Friday, May 9, 2008 2:50 PM
|
|
|
|
|
I was going to suggest using pointers until I saw your last paragraph. It seems to me this is a language-specific question with regard to C# rather than an algorithm question, per se. Thus, you could try the C# forum[^]. (I have zero experience with C#.)
|
|
|
|
|
If you could store both arrays in the same dictionary it would solve your problem. So for each index, the dictionary item would be a PAIR of ints (one from each array).
Then you go through each element, and get the difference between the pair of values at that index. This structure would also use less memory than two dictionaries.
Using a struct for the pair of ints would avoid the implicit use of a pointer that would result from a class/reference.
|
|
|
|
|
SortedDictionary might help here. Theres also SortedList which is very similar. Check the API notes. SortedDictionary IIRC is quicker but uses more memory. Main speedup is in adhoc query by key, which isn't what you are doing if you iterate the keys collection.
Probably SortedList will help you out. The actual algorithm could be as you said, quite simple.
|
|
|
|
|
Mark Churchill wrote: Main speedup is in adhoc query by key, which isn't what you are doing if you iterate the keys collection.
There are two approaches I can see. If what you want is to produce a new dictionary containing the differences, then your best bet is probably something like:
if dict1reader.eof then
output dict2reader
advance dict2reader
else if dict2reader.eof then
output dict1reader
advance dict1reader
elseif dict1reader.key = dict2reader.key then
output(dict1reader.key, dict1reader.value-dict2reader.value)
advance dict1reader
advance dict2reader
elseif dict1reader.key < dict2reader.key then
output(dict1reader.index, dict1reader.value)
advance dict1reader
else
output(dict2reader.index, dict2reader.value)
advance dict2reader
endif
Iterate that until both readers report eof.
|
|
|
|
|
I have a slight maths problem - Maybe you guys can help me out
I have 94 unique placeholders, with a possible digit on the end.
I have 16581375 total possibilities.
I'm wondering for a way to calculate which placeholder goes with which possibility.
Eg:
Possibility 1 - PlaceHolder 1 (With a 0)
Possibility 95 - PlaceHolder 1 (With 1)
Possibility 189 - PlaceHolder 1 (With a 2)
- Reelix
-= Reelix =-
|
|
|
|
|
Reelix wrote: I have 94 unique placeholders, with a possible digit on the end.
With a single digit ? Then it means that you have 10 choices for each unique placeholder. So, a total of 940 combinations.
Reelix wrote: I have 16581375 total possibilities.
It's a bit more than 940, don't you think ? So, you cannot fit all your possibilities in your 940 combinations.
|
|
|
|
|
Sorry, my mistake
Multiple Digits
-= Reelix =-
|
|
|
|
|
It's not clear what your problem is. You need to define it better if you want some help with it.
For example, what's the relationship between "placeholders" and "possibilities"? What are your constraints? How is the digit related to the other items?
|
|
|
|
|
Please elaborate (maybe you too will gain some insight).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Reelix wrote: I'm wondering for a way to calculate which placeholder goes with which possibility.
Then you will need a relationship between placeholders and possibilities. Do you have such a relationship?
|
|
|
|
|
Hi all. I've been working on a model in Excel that I'm considering porting into C/C++. I've been using the "Goal Seek" function in Excel to find a value in one cell that causes the results in another cell to equal some target value.
Is there an existing numerical recipe/algorithm to perform a similar function in C without reinventing the wheel?
Thanks for any help!
|
|
|
|
|
Not in C/C++, but this is a custom implementation in VB:
http://www.bmsltd.ie/DLCount/DLCount.asp?file=GoalSeek.zip[^]
Goal seeking is based on linear interpolation, perhaps you can adapt the VB code to C++?
I'm not too familiar with COM, etc. so I don't know the details but I do know that you can make calls to Excel from C++, maybe you can call the Excel Goal Seek function using COM (by loading the Excel .dll)?
|
|
|
|
|
"...but I do know that you can make calls to Excel from C++..."
Well, THAT would solve my problem! I've been doing a lot of processing in Excel (nicer, because I can see the numbers all laid out), then saving data to a text file, reading it into my C program and continuing my model that way. If I could just make calls right into a spreadsheet I could save myself a lot of dumb grunt labor. I'll check into that. Thanks!
|
|
|
|
|
Here[^] is a Microsoft knowledge-base article that provides some explanation. I think you have to use MFC to do it.
If you want to use Managed C++, here's a nice CP article:
Link[^].
I don't know a whole lot about COM, etc...so you might want to try asking for more details in the C++ forums here. Somebody can probably give you more assistance there.
|
|
|
|
|
KimN wrote: Is there an existing numerical recipe
There is a famous book called "Numerical Recipes", the original editions are available online for free. See here[^]. I think you need some adobe plugin to view the books - it is well worthwhile.
What you are interested in is optimisation of functions. The way this is typically done is you define a function that you want to minimize, e.g.
double func(double* x)
which takes N variables in the array 'x' and returns a single value. An optimization routine will attempt to find the values of 'x' that minimize the function. A very simple workhorse is called the downhill simplex method in multidimensions, but to you it is simply a function Amoeba to which you pass mainly a pointer to your function, the number of variables and starting values.
If you want to solve f(x) = c, make func(x) = (f(x) - c)^2
You will find a listing for amoeba in section 10.4 of Numerical Recipes in C.
If you know more about the function you are trying to minimize then there are probably better routines available, but I'd suspect that amoeba will work as well as excel (and be much faster in native code).
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|
|
Good answer, nicely explained.
|
|
|
|
|
Hi,
I am looking for the best way to sort multiple lists of unique items so none of the list items match at the same index.
Here is an example of what I want to do.
Original lists:
List 1: A, B, E, F
List 2: A, C, D, E
List 3: A, C, E, F
List 4: A, D, F, G
Should be sorted to:
List 1: A, B, E, F
List 2: C, A, D, E
List 3: E, F, A, C
List 4: D, G, F, A
Can anyone see a good way to solve this? Let me know if the above doesn't make sense.
Thanks
J
|
|
|
|
|
If the elements of the list can be completely random, then it seems to me you'd have to do this brute-force style. I don't see an obvious algorithm for speeding this up.
I do know that genetic algorithms are used to generate Sudoku tables (which is a similar problem to the above), but GA's are rather non-trivial to implement. It's probably easier to brute-force it for small lists.
|
|
|
|
|
Thanks, yeah I was thinking that I might need to do something pretty ugly to get this working. I've potentially got 5 sets of 42 items to sort so it could turn into alot of cycles to get 5 unique sets.
J
|
|
|
|
|
jrg2000 wrote: I've potentially got 5 sets of 42 items to sort
As a matter of interest, how many different items can there be in each set of 42 and do you have repeats? e.g. the sets are collections of different elements from a set of 80 elements, with no repeats OR the sets are collections from 10 elements with arbitrary numbers of repeats.
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|