If you're new to VS, then I would recommend initially no plug-ins. Use it for awhile. Perhaps, after three to six months, you'll be feeling something that you're missing - then look for something to fix that. I've been using VS since the oldest days (1.0) and to date I have one extension installed that didn't come with VS itself. I only have that one because it proved a convenient automated way to do something I'd been doing by hand for years. In ancient times, VS needed a lot of help, but it has grown into quite a mature product and they didn't miss much.
Yrth 18 Newbie Poster
Yrth 18 Newbie Poster
Here's a bit of ancient history for you. Way back in the day one of the very first breakthroughs in image recognition was made by a computer hobbyist, and it is germaine to your problem. The main problem in image recognition is edge extraction - how does one do that? It turns out that there is a fairly simple algorithm for extracting the edges from an image:
1) Take the image as a bitmap.
2) Make a duplicate of the image.
3) Offset the duplicate one pixel horizontally and one pixel vertically from the original.
4) XOR the two images back together, pixel-for-pixel.
This was originally done for monochrome images - for a color image you will probably have to come up with some manner of comparison threshold whereby you can tell whether two colors are sufficiently similar to count as the same (and thus cancel out) rather than using a simple exclusive-or. It will also extract all the edges, which in your sample above might not give you a clean line along the jaws on either side and you'll get lips, nose, brows, hairline and other spurious elements. But you might want to give it a try - it might get you close enough to a solution that you can see a fairly simple way to clean up the result and arrive at an acceptable solution.
You could also combine this with other algorithms. There is a fairly common and popular algorithm whose sole …
Yrth 18 Newbie Poster
1) Count is used to determine how long the number is (in decimal digits).
2) Line 18 extracts the digit at the lowest significant place by calculating the value of the number as it would be if the units digit was missing [(( x / 10 ) x 10 )] and subtracting that from the number itself (eg: if x is 123, then ( x / 10 ) = 12 (integer divide which drops the fraction) x 10 = 120. 123 - 120 = 3).
3) i is not defined twice. it is the value of the highest power of 10 in the number (the initial loop calculates the first power of 10 greater than the entire number, then it is divided by 10 giving the highest power of 10 in the number). In the second loop, that power is reduced by one power of ten for each iteration of the loop.
Thus, the first for() loop calculates the lowest power of 10 greater than x. That is then decreased by one power of 10 giving the highest power of 10 actually in x. In the meantime, count is calculated which gives the total number of digits (powers of 10) available.
In the second for loop, the lowest digit is extracted, multiplied by the highest power in the number and added to the result (making the LSD in the number the MSD in the result). Then the highest power is reduced by one power ( i = 1 / 10 …
jalpesh_007 commented: good explanation. +4
Yrth 18 Newbie Poster
Now, we arrive at the subject of the thread, at last. The question was, "Is that the correct way to save data?" It is the only way to save data. It is the only way to move data. At the end of the day, a hard-disk drive is nothing more spectacular than a very sophisticated, elaborate magnetic tape drive. The material is organized in a different way, there are more heads, and so on, but in terms of how they store data, a cassette tape and a disk drive are identical. The cassette tape and drive are just a lot more primitive than the disk and disk drive.
The real question is, "Is the C# Serialization implementation the correct way to save data? The correct answer is, "It depends."
If you're streaming text data or XML data, then the built-in Text and XML Serialization formatters will save you a lot of work. If you're streaming arbitrary data types, then the Binary formatter will preserve and transmit a lot of information about the data you are transmitting. These are all useful tools, and in many cases will be very useful and time-saving.
If you are, however, saving a fixed data structure of a specific size to a file over and over again, then any of the existing formatters are, at best, a cumbersome and bloated solution to the problem. Whether that disqualifies them as candidates depends on what you are prepared to sacrifice in terms of computing resources …
Murtan commented: Concise, clear and I agree with it +2
Yrth 18 Newbie Poster
Scope can be confusing to some. In C or C++, it was useful to think of scope in terms of braces. In C#, this relationship holds, but with some minor but important differences.
First, there are two types of variable. Global and local. In C#, a global variable is called 'static' and is preceded by the 'static' keyword. A static variable is class-specific. That is, if it is public, it can be used as if it were a property of the class. If it is protected, it is accessible as a property of the class, but only to that class and its descendents. If it is private, it is accessible as a property of the class, but only to instances of that class. Thus, a 'public static' variable can be used by anything anywhere in a program, so these are truly global variables in every sense.
In my code, I frequently have a class that I define that specifies all of the data that can be stored in the registy, and how to read it from the registry and write it to the registry. I normally make the only instance of this class a public static variable of the main form object, so that the values can be accessed and/or set from anywhere else in the program. In general, you should constrain your use of static variable to where they are actually necessary and useful. Over-using them constrains the flexibility of your code uneccessarily.
The other type …
Yrth 18 Newbie Poster
Many people have provided answers here, and I do not wish to step on any of this good advice. I just thought I would toss in mine, because it is my opinion that the more different viewpoints you find, the more likely it is that you will find one that makes perfect sense to you.
I learned that in Calculus. They didn't teach that in High School when I was young, but the topic always fascinated me. After reading about a dozen books on the topic, it still made no sense. Most of them were textbooks predicated on the assumption that there was a professor to fill in the blanks. I finally found a book that explained calculus from basic principles, and that was my Eureka. It made perfect sense, to the point where I started kicking myself for not thinking of it myself.
To make things easier, I will put several articles in here, starting with this one, on Objects.
OOP is often thought about as a 'different' programming paradigm. It isn't really. It's the same old paradigm. People (like one example here) like to describe OOP in terms of real world things. I like to describe it in terms that make sense to a programmer, because if you want to know, you are, or aspire to be one.
An object is a data type. Boom. That's the big mystery. That's all it is. It's a user-defined data type. All data types have behaviors that …
Yrth 18 Newbie Poster
Thanks ppl,
I need to keep track of the indices,
so the strtok approch wont work.But thanks again.
The strtok() approach will work, just with a little added overhead - specifically, tracking the size of tokens you have already passed and either used or discarded.
jephthah commented: true, and good point. i was gonna say about the same thing, but i quit caring. :) +12