Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
n704bv  
#1 Posted : Tuesday, November 6, 2007 7:31:43 AM(UTC)
n704bv

Rank: Member

Groups: Member
Joined: 11/6/2007(UTC)
Posts: 1

1) I have an image I need to perform a "Histogram Equalize" on. How can I do that?

Also,

2) How can I "Threshold" an image? I have an image with white letters on a blue and black background, and I want to get rid of all colors except the white letters. Does the ActiveX support this?

Thanks in advance,

Jim

Dmitry  
#2 Posted : Sunday, November 11, 2007 10:57:05 PM(UTC)
Dmitry

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 8/3/2003(UTC)
Posts: 1,070

Thanks: 1 times
Was thanked: 12 time(s) in 12 post(s)
Hello,

1. Histogram equalization is available in Graphics Mill for ActiveX. The desired functionality is represented by the IColorAdjustment.AutoLevels method.

2. There is no threshold implementation in Graphics Mill for ActiveX. But you can implement it by yourself easily. I have prepared small code sample which illustrates how to do it

Code:
  ' Threshold
  Dim threshold As Byte
  threshold = 250

  ' Load source bitmap
  Dim bitmap As New GraphicsMill.bitmap
  bitmap.LoadFromFile "c:\c1rr-aurigma.jpg"
  
  ' Convert bitmap to grayscale
  bitmap.Data.ConvertTo8bppGrayscale
  
  ' Apply threshold using low-level access to bitmap
  bitmap.LockData
  Dim arrSrcRow() As Byte
  Dim I As Long
  Dim J As Long
  Dim ptrSrcRow As Long
  
  ReDim arrSrcRow(0 To bitmap.Data.Stride - 1)
  ptrSrcRow = VarPtr(arrSrcRow(0))
    
  For J = 0 To bitmap.Data.Height - 1
     CopyMemory ByVal ptrSrcRow, ByVal bitmap.Data.Scan0 + J * bitmap.Data.Stride, bitmap.Data.Stride
     For I = 0 To bitmap.Data.Width - 1
       If arrSrcRow(I) < threshold Then
          arrSrcRow(I) = 0
       End If
    Next
    CopyMemory ByVal bitmap.Data.Scan0 + J * bitmap.Data.Stride, ByVal ptrSrcRow, bitmap.Data.Stride
  Next
  bitmap.UnlockData
  
  ' Prepare destination image
  bitmap.ColorAdjustment.Invert
  bitmap.Effects.MinimumFilter 1
  bitmap.Data.ConvertTo1bppIndexed
  
  ' Save destination image
  bitmap.SaveToFile "c:\1.png"

Edited by user Tuesday, December 15, 2009 10:45:11 AM(UTC)  | Reason: Not specified

Sincerely yours,

Dmitry Sevostyanov

UserPostedImage Follow Aurigma on Twitter!

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.