Welcome Guest Search | Active Topics | Members

Image Color Average - Update for VB .NET? Options
zymm
Posted: Monday, November 05, 2007 12:52:22 PM
Rank: Member
Groups: Member

Joined: 11/5/2007
Posts: 3
Points: 0
I tried converting this function up to VB .NET but it doesn't seem to want to work.. so many references seem to have changed since the version that this code was made for:

http://www.aurigma.com/Forums/Topic62-3-1.aspx

Could someone possibly provide a .NET version of this?

Thanks!
Dmitry
Posted: Monday, November 05, 2007 10:20:01 PM
Rank: Advanced Member
Groups: Administration , Member

Joined: 8/3/2003
Posts: 586
Points: 588
Hello,

API of Graphics Mill for .NET is not fully compatible with Graphics Mill for ActiveX.

The main concept of algorithm is correct but there should be changes in code lines for getting histogram. In .NET version you should use Bitmap.Statistics.GetSumHistogram(Int32).

Please, try it out.


Sincerely yours,
Dmitry Sevostyanov.
Alex Kon
Posted: Wednesday, November 07, 2007 12:25:33 AM
Rank: Advanced Member
Groups: Administration , Member

Joined: 1/31/2005
Posts: 386
Points: 403
Hi,

Here is an equivalent of the mentioned ActiveX sample:
Code:
'Loading source image
Dim bitmap As New Aurigma.GraphicsMill.Bitmap("x:/tests/Rgb24.jpg")
bv.Bitmap = bitmap

'Get histogram for each channel to calculate average
'intensity of an appropriate channel.

Dim histogram As Aurigma.GraphicsMill.Histogram
Dim avgRed, avgGreen, avgBlue As Integer

histogram = bitmap.Statistics.GetSumHistogram(Aurigma.GraphicsMill.ColorChannel.Red)
avgRed = System.Math.Round(histogram.Mean)
histogram.Dispose()

histogram = bitmap.Statistics.GetSumHistogram(Aurigma.GraphicsMill.ColorChannel.Green)
avgGreen = System.Math.Round(histogram.Mean)
histogram.Dispose()

histogram = bitmap.Statistics.GetSumHistogram(Aurigma.GraphicsMill.ColorChannel.Blue)
avgBlue = System.Math.Round(histogram.Mean)
histogram.Dispose()

'After we calculate average intensities of each channel,
'combine them into one RGB color.
Dim color As Aurigma.GraphicsMill.Color = Aurigma.GraphicsMill.Color.FromRgb(avgRed, avgGreen, avgBlue)

'Display this color. Let's draw the square 30x30 filled with average color
'we calculated.

Dim g As Aurigma.GraphicsMill.Drawing.GdiGraphics = bitmap.GetGdiGraphics()
Try
        Dim brush As New Aurigma.GraphicsMill.Drawing.SolidBrush(color)
        g.FillRectangle(brush, 0, 0, 100, 100)
Finally
         g.Dispose()
End Try


Best wishes, Alex.
zymm
Posted: Wednesday, November 07, 2007 4:28:17 AM
Rank: Member
Groups: Member

Joined: 11/5/2007
Posts: 3
Points: 0
Great! That works just fine.

Now, I've dug up another 'classic' from your forums:

http://www.aurigma.com/Forums/Topic77-3-1.aspx

This one doesn't seem to be .NET 2.0, would it be possible to have this one in the latest format?

Thanks a lot.
Alex Kon
Posted: Friday, November 09, 2007 2:31:19 AM
Rank: Advanced Member
Groups: Administration , Member

Joined: 1/31/2005
Posts: 386
Points: 403
Hello,

You can find the updated version of the sample in this topic.

Best wishes, Alex.
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

YAFVision Theme Created by Jaben Cargman (Tiny Gecko)
Yet Another Forum.net version 1.9.1.6 running under Cuyahoga.
Copyright © 2003-2006 Yet Another Forum.net. All rights reserved.