如何使用vb.net组合直方图中的bin? [英] How to combine no of bin in histogram using vb.net?

查看:62
本文介绍了如何使用vb.net组合直方图中的bin?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是贝拉。我想问一下如何使用vb.net将0-255bin的像素值组合成0-10 bin?有人可以纠正我的编码吗?这是正确的吗?

I'm Bella. Do I want to ask how to combine pixel value from 0-255bin into 0-10 bin using vb.net? can someone correct my coding? Is it correct?

        Dim HDr As Long() = New Long(255) {}
        Dim HDg As Long() = New Long(255) {}
        Dim HDb As Long() = New Long(255) {}

        GetHistogram(New Bitmap(PictureBox1.Image), HDr, HDg, HDb)

        'setup the chart
        With Chart1.ChartAreas(0)
            .AxisX.Title = "Pixel"
            .AxisX.MajorGrid.LineColor = Color.LightBlue
            .AxisX.Minimum = 0
            .AxisX.Interval = 1


            .AxisY.Title = "Frequency"
            .AxisY.MajorGrid.LineColor = Color.LightGray
            .AxisY.Minimum = 0
            .AxisY.Interval = 0.1


            .BackColor = Color.FloralWhite
            .BackSecondaryColor = Color.White
            .BackGradientStyle = GradientStyle.HorizontalCenter
            .BorderColor = Color.Blue
            .BorderDashStyle = ChartDashStyle.Solid
            .BorderWidth = 1
            .ShadowOffset = 2

            'draw the chart
            Chart1.Series.Clear()
            Chart1.Series.Add("Red")
            Chart1.Series("Red").ChartType = DataVisualization.Charting.SeriesChartType.Column
            Chart1.Series("Red").Color = Color.Red
            Chart1.Series("Red").IsVisibleInLegend = False

            For i As Integer = 0 To 9
                Chart1.Series("Red").Points.AddY(HDr(i) / 70000) --> Im not sure for this part.
            Next

        End With

    End Sub

谢谢。

问候,

Bella

推荐答案


我想问一下如何使用vb.net将0-255bin的像素值组合成0-10 bin?有人可以纠正我的编码吗?这是正确的吗?

I want to ask how to combine pixel value from 0-255bin into 0-10 bin using vb.net? can someone correct my coding? Is it correct?

什么是HDr? 如果它是256个分档并且你想要创建10个分箱,则代码将类似于:

What is HDr?  If it is the 256 bins and you want to create 10 bins then the code would be something like:

Dim Bins10 As Integer(9)

Dim Bins10 As Integer(9)

For I As Integer = 0到255

  Bins10(CInt(I / 25.5))+ = HDr(I)

Next I

For I As Integer = 0 to 255
  Bins10(CInt(I / 25.5)) += HDr(I)
Next I

然后使用Bins10填充Y数据点。

Then use Bins10 to populate the Y data points.


这篇关于如何使用vb.net组合直方图中的bin?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆