EDN Admin
Well-known member
I have this function that make histogram of each Bitmap:
<pre class="lang-cs prettyprint prettyprinted
[/code]
Then i have this function that get histogram and make the average of the top <br/>
1000 values per histogram:
<pre class="lang-cs prettyprint prettyprinted
[/code]
This is the scroll event i want that each time i move to the next <br/>
image/bitmap it will show me the current Histogram of the Bitmap in the <br/>
ZedGraph:
<pre class="lang-cs prettyprint prettyprinted
[/code]
Now this is the function in Form1 that im using when i click the menu it will <br/>
show up the ZedGraph control:
<pre class="lang-cs prettyprint prettyprinted
[/code]
And the code of HistogramGraphs:
<pre class="lang-cs prettyprint prettyprinted
[/code]
What i want is to show in some way two modes in the ZedGraph:
<br/>
<ol>
Histogram per Bitmap. The averages of the top 1000 values from each histogram. </ol>
Each mode will be in a different button click event once its showing only the <br/>
Histogram of each Bitmap. And when i close the ZedGraph and click on another <br/>
button it will show me the top averages 1000 values per histogram.
Maybe there is a way to use my text file on the hard disk im creating with <br/>
all the histograms for example:
<pre class="lang-cs prettyprint prettyprinted
[/code]
Frame 000000 is Bitmap number one for example and its histogram. Then there <br/>
is Frame 000001 and many numbers wich its histogram. And so on.
But what i want now is to show the histogram of each Bitmap and the averages <br/>
1000 values per histogram. <hr class="sig danieli
View the full article
<pre class="lang-cs prettyprint prettyprinted
Code:
<span class="kwd public<span class="pln <span class="kwd static<span class="pln <span class="kwd long<span class="pun []<span class="pln <span class="typ GetHistogram<span class="pun (<span class="typ Bitmap<span class="pln b<span class="pun )<span class="pln
<span class="pun {<span class="pln
<span class="kwd long<span class="pun []<span class="pln myHistogram <span class="pun =<span class="pln <span class="kwd new<span class="pln <span class="kwd long<span class="pun [<span class="lit 256<span class="pun ];<span class="pln <span class="com // histogram סופר כמה יש מכל גוון<span class="pln
<span class="typ BitmapData<span class="pln bmData <span class="pun =<span class="pln <span class="kwd null<span class="pun ;<span class="pln
<span class="kwd try<span class="pln
<span class="pun {<span class="pln
<span class="com //Lock it fixed with 32bpp<span class="pln
bmData <span class="pun =<span class="pln b<span class="pun .<span class="typ LockBits<span class="pun (<span class="kwd new<span class="pln <span class="typ Rectangle<span class="pun (<span class="lit 0<span class="pun ,<span class="pln <span class="lit 0<span class="pun ,<span class="pln b<span class="pun .<span class="typ Width<span class="pun ,<span class="pln b<span class="pun .<span class="typ Height<span class="pun ),<span class="pln <span class="typ ImageLockMode<span class="pun .<span class="typ ReadOnly<span class="pun ,<span class="pln <span class="typ PixelFormat<span class="pun .<span class="typ Format32bppArgb<span class="pun );<span class="pln
<span class="typ int<span class="pln scanline <span class="pun =<span class="pln bmData<span class="pun .<span class="typ Stride<span class="pun ;<span class="pln
<span class="typ System<span class="pun .<span class="typ IntPtr<span class="pln <span class="typ Scan0<span class="pln <span class="pun =<span class="pln bmData<span class="pun .<span class="typ Scan0<span class="pun ;<span class="pln
<span class="kwd unsafe<span class="pln
<span class="pun {<span class="pln
<span class="kwd byte<span class="pun *<span class="pln p <span class="pun =<span class="pln <span class="pun (<span class="kwd byte<span class="pun *)(<span class="kwd void<span class="pun *)<span class="typ Scan0<span class="pun ;<span class="pln
<span class="typ int<span class="pln nWidth <span class="pun =<span class="pln b<span class="pun .<span class="typ Width<span class="pun ;<span class="pln
<span class="typ int<span class="pln nHeight <span class="pun =<span class="pln b<span class="pun .<span class="typ Height<span class="pun ;<span class="pln
<span class="kwd for<span class="pln <span class="pun (<span class="typ int<span class="pln y <span class="pun =<span class="pln <span class="lit 0<span class="pun ;<span class="pln y <span class="pun <<span class="pln nHeight<span class="pun ;<span class="pln y<span class="pun ++)<span class="pln
<span class="pun {<span class="pln
<span class="kwd for<span class="pln <span class="pun (<span class="typ int<span class="pln x <span class="pun =<span class="pln <span class="lit 0<span class="pun ;<span class="pln x <span class="pun <<span class="pln nWidth<span class="pun ;<span class="pln x<span class="pun ++)<span class="pln
<span class="pun {<span class="pln
<span class="kwd long<span class="pln <span class="typ Temp<span class="pln <span class="pun =<span class="pln <span class="lit 0<span class="pun ;<span class="pln
<span class="typ Temp<span class="pln <span class="pun +=<span class="pln p<span class="pun [<span class="lit 0<span class="pun ];<span class="pln
<span class="typ Temp<span class="pln <span class="pun +=<span class="pln p<span class="pun [<span class="lit 1<span class="pun ];<span class="pln
<span class="typ Temp<span class="pln <span class="pun +=<span class="pln p<span class="pun [<span class="lit 2<span class="pun ];<span class="pln
<span class="typ Temp<span class="pln <span class="pun =<span class="pln <span class="pun (<span class="typ int<span class="pun )<span class="typ Temp<span class="pln <span class="pun /<span class="pln <span class="lit 3<span class="pun ;<span class="pln
myHistogram<span class="pun [<span class="typ Temp<span class="pun ]++;<span class="pln
<span class="com //locking in 32bppArgb - mode<span class="pln
p <span class="pun +=<span class="pln <span class="lit 4<span class="pun ;<span class="pln
<span class="pun }<span class="pln
<span class="pun }<span class="pln
<span class="pun }<span class="pln
b<span class="pun .<span class="typ UnlockBits<span class="pun (<span class="pln bmData<span class="pun );<span class="pln
<span class="pun }<span class="pln
<span class="kwd catch<span class="pln
<span class="pun {<span class="pln
<span class="kwd try<span class="pln
<span class="pun {<span class="pln
b<span class="pun .<span class="typ UnlockBits<span class="pun (<span class="pln bmData<span class="pun );<span class="pln
<span class="pun }<span class="pln
<span class="kwd catch<span class="pln
<span class="pun {<span class="pln
<span class="pun }<span class="pln
<span class="pun }<span class="pln
<span class="kwd return<span class="pln myHistogram<span class="pun ;<span class="pln
<span class="pun }
Then i have this function that get histogram and make the average of the top <br/>
1000 values per histogram:
<pre class="lang-cs prettyprint prettyprinted
Code:
<span class="kwd public<span class="pln <span class="kwd static<span class="pln <span class="kwd long<span class="pln <span class="typ GetTopLumAmount<span class="pun (<span class="kwd long<span class="pun []<span class="pln histogram<span class="pun ,<span class="pln <span class="typ int<span class="pln amount<span class="pun )<span class="pln
<span class="pun {<span class="pln
<span class="kwd if<span class="pln <span class="pun (<span class="pln histogram<span class="pun .<span class="typ Sum<span class="pun ()<span class="pln <span class="pun <<span class="pln amount<span class="pun )<span class="pln
<span class="kwd return<span class="pln <span class="pun -<span class="lit 1<span class="pun ;<span class="pln
<span class="kwd long<span class="pln result <span class="pun =<span class="pln <span class="lit 0<span class="pun ;<span class="pln
<span class="kwd long<span class="pln counted <span class="pun =<span class="pln <span class="lit 0<span class="pun ;<span class="pln
<span class="kwd for<span class="pln <span class="pun (<span class="typ int<span class="pln i <span class="pun =<span class="pln histogram<span class="pun .<span class="typ Length<span class="pln <span class="pun -<span class="pln <span class="lit 1<span class="pun ;<span class="pln i <span class="pun >=<span class="pln <span class="lit 0<span class="pun ;<span class="pln i<span class="pun --)<span class="pln
<span class="pun {<span class="pln
<span class="kwd if<span class="pln <span class="pun (<span class="pln counted <span class="pun <<span class="pln amount<span class="pun )<span class="pln
<span class="pun {<span class="pln
<span class="kwd long<span class="pln current <span class="pun =<span class="pln <span class="typ Math<span class="pun .<span class="typ Min<span class="pun (<span class="pln histogram<span class="pun [<span class="pln i<span class="pun ],<span class="pln amount <span class="pun -<span class="pln counted<span class="pun );<span class="pln
counted <span class="pun +=<span class="pln current<span class="pun ;<span class="pln
result <span class="pun +=<span class="pln current <span class="pun *<span class="pln i<span class="pun ;<span class="pln
<span class="pun }<span class="pln
<span class="kwd else<span class="pln
<span class="kwd break<span class="pun ;<span class="pln
<span class="pun }<span class="pln
<span class="kwd return<span class="pln result<span class="pun ;<span class="pln
<span class="pun }
This is the scroll event i want that each time i move to the next <br/>
image/bitmap it will show me the current Histogram of the Bitmap in the <br/>
ZedGraph:
<pre class="lang-cs prettyprint prettyprinted
Code:
<span class="kwd private<span class="pln <span class="kwd void<span class="pln trackBar1_Scroll<span class="pun (<span class="kwd object<span class="pln sender<span class="pun ,<span class="pln <span class="typ EventArgs<span class="pln e<span class="pun )<span class="pln
<span class="pun {<span class="pln
trackbarCounter<span class="pun ++;<span class="pln
<span class="kwd if<span class="pln <span class="pun (<span class="pln manualDone <span class="pun ==<span class="pln <span class="kwd true<span class="pun )<span class="pln
<span class="pun {<span class="pln
myTrackPanelss1<span class="pun .<span class="pln trackBar1<span class="pun .<span class="typ Minimum<span class="pln <span class="pun =<span class="pln <span class="lit 0<span class="pun ;<span class="pln
myTrackPanelss1<span class="pun .<span class="pln trackBar1<span class="pun .<span class="typ Maximum<span class="pln <span class="pun =<span class="pln _fi<span class="pun .<span class="typ Length<span class="pln <span class="pun -<span class="pln <span class="lit 1<span class="pun ;<span class="pln setpicture<span class="pun (<span class="pln myTrackPanelss1<span class="pun .<span class="pln trackBar1<span class="pun .<span class="typ Value<span class="pun );<span class="pln <span class="kwd this<span class="pun .<span class="pln pictureBox1<span class="pun .<span class="typ Refresh<span class="pun ();<span class="pln
<span class="pun }<span class="pln
<span class="kwd if<span class="pln <span class="pun (<span class="pln automaticDone <span class="pun ==<span class="pln <span class="kwd true<span class="pun )<span class="pln
<span class="pun {<span class="pln
myTrackPanelss1<span class="pun .<span class="pln trackBar1<span class="pun .<span class="typ Minimum<span class="pln <span class="pun =<span class="pln <span class="lit 0<span class="pun ;<span class="pln
myTrackPanelss1<span class="pun .<span class="pln trackBar1<span class="pun .<span class="typ Maximum<span class="pln <span class="pun =<span class="pln fiAutomatic<span class="pun .<span class="typ Length<span class="pln <span class="pun -<span class="pln <span class="lit 1<span class="pun ;<span class="pln
<span class="kwd long<span class="pun []<span class="pln tt <span class="pun =<span class="pln list_of_histograms<span class="pun [<span class="pln myTrackPanelss1<span class="pun .<span class="pln trackBar1<span class="pun .<span class="typ Value<span class="pun ];<span class="pln
<span class="kwd long<span class="pln res <span class="pun =<span class="pln <span class="typ GetTopLumAmount<span class="pun (<span class="pln tt<span class="pun ,<span class="pln <span class="lit 1000<span class="pun );<span class="pln
<span class="kwd long<span class="pln max <span class="pun =<span class="pln <span class="typ GetHistogramMaximum<span class="pun (<span class="pln tt<span class="pun );<span class="pln
<span class="typ GetHistogramAverage<span class="pun (<span class="pln tt<span class="pun );<span class="pln
setpicture<span class="pun (<span class="pln myTrackPanelss1<span class="pun .<span class="pln trackBar1<span class="pun .<span class="typ Value<span class="pun );<span class="pln <span class="kwd this<span class="pun .<span class="pln pictureBox1<span class="pun .<span class="typ Refresh<span class="pun ();<span class="pln
<span class="pun }<span class="pln
<span class="pun }
Now this is the function in Form1 that im using when i click the menu it will <br/>
show up the ZedGraph control:
<pre class="lang-cs prettyprint prettyprinted
Code:
<span class="kwd private<span class="pln <span class="kwd void<span class="pln histogramGraphsToolStripMenuItem_Click<span class="pun (<span class="kwd object<span class="pln sender<span class="pun ,<span class="pln <span class="typ EventArgs<span class="pln e<span class="pun )<span class="pln
<span class="pun {<span class="pln
<span class="typ HistogramGraphs1<span class="pln <span class="pun =<span class="pln <span class="kwd new<span class="pln <span class="typ Lightnings_Extractor<span class="pun .<span class="typ Histogram_Graphs<span class="pun ();<span class="pln
<span class="typ HistogramGraphs1<span class="pun .<span class="typ Show<span class="pun ();<span class="pln
<span class="typ HistogramGraphs1<span class="pun .<span class="typ FormClosing<span class="pln <span class="pun +=<span class="pln <span class="kwd new<span class="pln <span class="typ FormClosingEventHandler<span class="pun (<span class="typ HistogramGraphs1_FormClosing<span class="pun );<span class="pln
histogramGraphsToolStripMenuItem<span class="pun .<span class="typ Enabled<span class="pln <span class="pun =<span class="pln <span class="kwd false<span class="pun ;<span class="pln
<span class="pun }
And the code of HistogramGraphs:
<pre class="lang-cs prettyprint prettyprinted
Code:
<span class="pln using <span class="typ System<span class="pun ;<span class="pln
using <span class="typ System<span class="pun .<span class="typ Collections<span class="pun .<span class="typ Generic<span class="pun ;<span class="pln
using <span class="typ System<span class="pun .<span class="typ ComponentModel<span class="pun ;<span class="pln
using <span class="typ System<span class="pun .<span class="typ Data<span class="pun ;<span class="pln
using <span class="typ System<span class="pun .<span class="typ Drawing<span class="pun ;<span class="pln
using <span class="typ System<span class="pun .<span class="typ Linq<span class="pun ;<span class="pln
using <span class="typ System<span class="pun .<span class="typ Text<span class="pun ;<span class="pln
using <span class="typ System<span class="pun .<span class="typ Windows<span class="pun .<span class="typ Forms<span class="pun ;<span class="pln
namespace <span class="typ Lightnings_Extractor<span class="pln
<span class="pun {<span class="pln
<span class="kwd public<span class="pln <span class="kwd partial<span class="pln <span class="kwd class<span class="pln <span class="typ Histogram_Graphs<span class="pln <span class="pun :<span class="pln <span class="typ Form<span class="pln
<span class="pun {<span class="pln
<span class="kwd public<span class="pln <span class="typ Histogram_Graphs<span class="pun ()<span class="pln
<span class="pun {<span class="pln
<span class="typ InitializeComponent<span class="pun ();<span class="pln
<span class="kwd this<span class="pun .<span class="typ DoubleBuffered<span class="pln <span class="pun =<span class="pln <span class="kwd true<span class="pun ;<span class="pln
<span class="pun }<span class="pln
<span class="kwd private<span class="pln <span class="kwd void<span class="pln <span class="typ Histogram_Graphs_Load<span class="pun (<span class="kwd object<span class="pln sender<span class="pun ,<span class="pln <span class="typ EventArgs<span class="pln e<span class="pun )<span class="pln
<span class="pun {<span class="pln
<span class="pun }<span class="pln
<span class="pun }<span class="pln
<span class="pun }
What i want is to show in some way two modes in the ZedGraph:
<br/>
<ol>
Histogram per Bitmap. The averages of the top 1000 values from each histogram. </ol>
Each mode will be in a different button click event once its showing only the <br/>
Histogram of each Bitmap. And when i close the ZedGraph and click on another <br/>
button it will show me the top averages 1000 values per histogram.
Maybe there is a way to use my text file on the hard disk im creating with <br/>
all the histograms for example:
<pre class="lang-cs prettyprint prettyprinted
Code:
<span class="pln DANNY VIDEO HISTOGRAM DATA
FORMAT VERSION<span class="pun :<span class="lit 1.00<span class="pln
SOURCE<span class="pun :<span class="pln <span class="pun <<span class="pln MVI_2963<span class="pun .<span class="pln MOV_Automatic<span class="pun ><span class="pln
DATA<span class="pun :<span class="pln
<span class="typ Frame<span class="pln <span class="lit 000000<span class="pun :<span class="pln <span class="lit 17680<span class="pun ,<span class="lit 31263<span class="pun ,<span class="lit 26399<span class="pun ,<span class="lit 20299<span class="pun ,<span class="lit 17361<span class="pun ,<span class="lit 14397<span class="pun ,<span class="lit 12442<span class="pun ,<span class="lit 11780<span class="pun ,<span class="lit 11418<span class="pun ,<span class="lit 11819<span class="pun ,<span class="lit 12180<span class="pun ,<span class="lit 13463<span class="pun ,<span class="lit 15278<span class="pun ,<span class="lit 17829<span class="pun ,<span class="lit 21414<span class="pun ,<span class="lit 25465<span class="pun ,<span class="lit 29902
Frame 000000 is Bitmap number one for example and its histogram. Then there <br/>
is Frame 000001 and many numbers wich its histogram. And so on.
But what i want now is to show the histogram of each Bitmap and the averages <br/>
1000 values per histogram. <hr class="sig danieli
View the full article