![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Professional Programmer
|
I added the HistogramComparison class but it is not working correctly. The result of applying the formula either gives me 1 or 0. Something is definitely wrong however I can't find it. I am not sure if I am going about making the histogram the correct way.
Here is the code.:mad: csharp Syntax (Toggle Plain Text)
Any ideas? ![]()
__________________
JG-Webdesign Last edited by Wizard1988; Feb 15th, 2007 at 8:03 PM. |
|
|
|
|
|
#12 |
|
Professional Programmer
|
I decided that it will be easier if I just use 3 arrays instead of a cubed array.
I reviewed my code and I wanted to cry a little. It was way too messy. I realized that the three dimensional array wasn't the way to go. Instead I have a struct which contains three arrays which represent the red, blue and green channels. Unfortunately I am again having trouble with the comparison. The way Arevos showed the comparison makes sense but I am not sure how I would do it with a histogram constructed of three arrays. Here is the updated code: csharp Syntax (Toggle Plain Text)
Am I supposed to take the sum the minimum of each channel from the specific bin per histogram?
__________________
JG-Webdesign Last edited by Wizard1988; Feb 15th, 2007 at 10:43 PM. |
|
|
|
|
|
#13 | |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
Quote:
c# Syntax (Toggle Plain Text)
As an aside, I'd say there was an advantage to using a three dimensional array over a set of three arrays; you don't have to have any specific switch statements. |
|
|
|
|
|
|
#14 |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
A quick addendum. Three separate arrays wouldn't work, or at least the results produced by them will be less accurate. Typically, a colour histogram is a 2D or 3D set of tabulated data. So if you put all red values in 4 bins, and all blue values in 4 bins, then you'll end up with a 2D table of 4 rows (for reds) and 4 columns (for blues), and a total of 4 * 4 cells. Likewise, a 3 colour histogram with 4 bins per colour typically takes up 4 * 4 * 4 cells in total.
By contrast, a set of three arrays only holds 4 + 4 + 4 elements, and since the results aren't cross-referenced, the amount of information you'll get with three separate 1D histograms is significantly less than with one correlated 3D histogram. In order to get any data out of these three histograms, you'll have to find their intersections individually and then average the result. However, I'd advise you stick with a single 3D histogram. You'll likely get more useful data that way. So your initial attempt using a 3 dimensional array is correct, I feel. The logic for placing the colours in the right bins also appears correct. The only part where you slipped up is when you attempted to divide two integers expecting a floating point number as a result. C# isn't smart enough to figure out that just because you're putting the result into a double, that it should use floating point arithmetic. You need to explicitly declare one of the variables in the equation as a float or a double in order for it to work. |
|
|
|
|
|
#15 |
|
Professional Programmer
|
So would it be possible to add a method to RGBHistogram struct which would construct a 3 dimensional array out of the one dimensional ones?
__________________
JG-Webdesign |
|
|
|
|
|
#16 | |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
Quote:
Just use your original code. If you've overwritten your local copy, you can use the code from your earlier post. A three dimensional array is the best way to do this, because your histogram is essentially a 3D cube of values. Trying to fit this into a data-structure that isn't 3D isn't going to work as well. |
|
|
|
|
|
|
#17 |
|
Professional Programmer
|
Ok thanks. I will try to fix my code when I get home.
__________________
JG-Webdesign |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| confused with distances | ktsirig | Perl | 1 | Mar 23rd, 2006 1:02 PM |