|
Hello,
I want to quantization the value of HSV color using Non-equal Intervals with C#, I made a search but found nothing
I need a source code/pseudocode for that method
any help will be appreciated
Thanks
|
|
|
|
|
We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.
So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
And just asking for the code doesn't win you any friends...
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
You will find lots of detailed explanations of HSV colour on the internet. Writing the C# code to perform actions on the values is your task.
|
|
|
|
|
The code is as follows,Set to file p
try
{
if (AvCoBox.SelectedIndex < 0) return;
MainCamera.SetSetting(PropertyID.Av, AvValues.GetValue(AvCoBox.Text).IntValue);
}
catch (Exception ex) { ReportError(ex.Message, false); }
|
|
|
|
|
Please don't repost if your question does not appear immediately: all of these went to moderation and required a human being to review them for publication. In order to prevent you being kicked off as a spammer, both had to be accepted, and then I have to clean up the spares. Have a little patience, please!
I've deleted the "extras" and kept the one with code.
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
What's in "AvCoBox.Text"? How can you be sure it has a valid value when you don't even bother checking it before firing it off?
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
I had all my classes made public so that I could use variables in any part of the code.
I found that if I used the variable 'i' like this Name[i] where 'i' had been declared a integer then I could not use 'i' elsewhere in my program.
To get over this problem I had to add the code maxcount=i; then I could refer to the variable maxcount elsewhere in my code.
There must be a good reason for this but as I'm new to C# I found this strange.
I also find that sometimes you need an instance of a variable (Students student = new Students) and other times you don't need to do this.
I'm still trying to get my head around reasons for this when learning C#.
Brian
Brian
|
|
|
|
|
A class should be a black box, where you don't have to know about the inside, and can't muck up the internal state from the outside. The parts where you find you need access to a variable, you'll often need a property.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Thanks Eddy for giving me another way of understanding things in C#.
Correct me if I'm wrong but I'm also thinking that an instance variable is a reference to a variable.
Brian
|
|
|
|
|
Doesn't have to be; you can also have a value-type as an instance variable. If it is not a value-type, then it is indeed a reference.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
It sounds like you're not using OOP at all and just declaring all of your variable and classes as static. That's not good practice.
But, that's just a guess as we can't see you're code and you haven't posted any.
|
|
|
|
|
Hi Dave.
Sorry but my code is a bit messy as I'm experimenting while learning C#.
At the bottom of the code you'll find num=i; then near the top I have numberOfVerbs = num;
I could not use numberOfVerbs = i;
I have found out since that I could have used the .long command to find out how many CollectText's created.
I use to be able to run the code without errors but something has changed to cause some errors.
namespace Lads_in_CSharp
{
public class Program
{
int i = 0;
int num;
int numberOfVerbs;
int y=0;
int a = 0;
String Text1="";
String[] CollectText = new String[1000];
String [] TT = new String[3] ;
public static void Main(string[] args)
{
Program prog = new Program();
StreamReader sr = new StreamReader("demo.adv");
Console.WriteLine("Start of Program");
prog.y = 4;
prog.ReadHeader(sr);
Console.WriteLine(prog.i);
prog.ReadVerbs(sr);
prog.ReadNouns(sr);
prog.ReadObjects(sr);
prog.ReadStartRoom(sr);
prog.ReadRooms(sr);
prog.ReadMessages(sr);
prog.ReadAutoActions(sr);
prog.ReadActions(sr);
sr.Close();
Console.Read();
}
public void ReadHeader(StreamReader sr)
{
Console.WriteLine("Read Header");
ReadLineOfText(sr);
Console.WriteLine("Text1 is: " + sr);
}
public void ReadVerbs(StreamReader sr)
{
Console.WriteLine("Read Verbs++++++++++");
int i=0;
ReadLineOfText(sr);
numberOfVerbs = num;
Console.WriteLine("Text1 is:: " + Text1);
Console.WriteLine("Collect Text 2 = "+CollectText[2]);
Console.WriteLine("Number of Verbs is "+num);
Console.WriteLine("Comma separated strings");
{
i = 0;
while (a < 10)
{
string[] parts = CollectText[1].Split(',');
foreach (string part in parts)
{
Console.WriteLine("part = {0} ", part);
i++;
if (i == 1)
{
TT[i] = part;
}
else
{
TT[i] = part;
}
a++;
}
}
}
Console.WriteLine("TT[1] = " + TT[1]);
Console.WriteLine("TT[2] = " + TT[2]);
i++;
}
}
public void ReadNouns(StreamReader sr)
{
Console.WriteLine("Read Nouns ++++++++++++++++++");
ReadLineOfText(sr);
Console.WriteLine("Text1 is: " + Text1);
}
public void ReadObjects(StreamReader sr)
{
Console.WriteLine("Read Objects+++++++++++++");
ReadLineOfText(sr);
Console.WriteLine("Text1 is: " + Text1);
}
public void ReadStartRoom(StreamReader sr)
{
Console.WriteLine("Read Start Room+++++++++++");
ReadLineOfText(sr);
Console.WriteLine("Text1 is: " + Text1);
}
public void ReadRooms(StreamReader sr)
{
Console.WriteLine("Read Rooms+++++++++++++");
ReadLineOfText(sr);
Console.WriteLine("Text1 is: " + Text1);
}
public void ReadMessages(StreamReader sr)
{
Console.WriteLine("Read Messages+++++++++++");
ReadLineOfText(sr);
Console.WriteLine("Text1 is: " + Text1);
}
public void ReadAutoActions(StreamReader sr)
{
Console.WriteLine("Read Auto Actions+++++++++");
ReadLineOfText(sr);
Console.WriteLine("Text1 is: " + Text1);
}
public void ReadActions(StreamReader sr)
{
Console.WriteLine("Read Actions");
ReadLineOfText(sr);
Console.WriteLine("Text1 is: "+Text1);
}
public void ReadLineOfText(StreamReader sr)
{
Text1 = "null";
i = 0;
while (Text1 != "")
{
Text1 = sr.ReadLine();
Console.WriteLine("ReadLine is: [read from ReadOfText producer]" + Text1);
i++;
CollectText[i] = Text1;
}
i = i-1;
num = i;
Console.WriteLine(i);
}
}
<pre>
|
|
|
|
|
Yeah, you've thrown all the variables at the class level. That's bad. You have no reason to do that at all.
Rewrite the thing from scratch, but think about what each method is going to handle, what it's going to need to do that job, and what it's going to return. Each method is going to need its own variables, so declare them in that method.
In this code, you've got no reason to have ANY class level variables at all.
|
|
|
|
|
Thanks David for your feedback.
Well it started as a old program I wanted to convert to C# and I decided toturn methods into classes to try and separate the code and give me some practice on using classes.
The program collects information from a script file then compiles and writes the compiled data to file which is loaded into the main program.
While I started to write the program code to create a suitable program I'm now using the code to experiment with and try out things I have learnt.
The code is likely to be re-wriiten.
Brian
|
|
|
|
|
I would strongly urge you to stop trying to write code until you have worked through the two books that I have suggested. Unless and until you fully understand the basics you will be falling over simple issues like this. There are no shortcuts to becoming a developer, it requires time, effort and practice, practice, practice.
|
|
|
|
|
I understand what your saying Richard and like you said it takes practice which is what I'm doing in writing some code.
I see it like trying to drive a car. You can read a lot but you need to get behind the wheel and start driving to get the practice.
I only submitted code because I was asked to do so by someone giving me some feedback.
If I can write a simple example program from something I've learnt from a book and it successfully works then I move on to learn more of the C# programming.
Brian
|
|
|
|
|
You have discovered "references" (very early).
Once you understand them (and public, private and static), you will achieve enlightenment.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Apart from the book 'Dot Net Book Zero' can some one recommend a good book for learning C#.
I find that books with example code are good for learning.
I'm not new to programming but have mainly programmed in the older Visual Basic language and started with BASIC (which became Quick Basic later on).
I'm looking for a book that's easy to follow and does not assume that the reader knows certain things.
Following a program step by step in a book until it is fully written can be helpful as I can see how things fit together.
Any suggestion would be welcome things.
Brian
|
|
|
|
|
|
I'm wondering why you suggested Pro C# 7, correct me if I'm wrong but the title suggests that this book is for experienced C# users.
I've read some "In a Nutshell" books before and they seem to be helpful.
Brian
|
|
|
|
|
Follow the link, and click "look inside" - it'll give you (at least) the contents pages. It starts assuming you aren't familiar with .NET, so it's pretty good for beginners with coding experience in other languages.
IIRC it was one of the ones I started in C# with, from a C / C++ / Assembler background.
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
If you come from Visual Basic you have two things to learn :
- .Net
- the Syntax of C#
I suggest you, if you like, to learn at first .Net with VB.Net.
After this you could eaiser come into the C#-Syntax ... (my opinion)
|
|
|
|
|
I'd disagree. If you have VB <= 6 experience you are better off learning C#, as you don't try to use outdated VB6 stuff (some of which still works) instead of the more modern equivalents.
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
as I wrote : my opinion ... and also it was my way to come into it ...
|
|
|
|
|
Thanks Griff.
That's one reason for learning C# rather than VB.Net then C#.
VB.Net seems less popular these days going buy the list of the top 10 popular programming languages.
I hope to learn ways of reducing code that C# seems good at doing.
Brian
|
|
|
|