1 Replies - 5450 Views - Last Post: 08 March 2011 - 08:40 AM Rate Topic: -----

#1 jonana  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 26-February 11

Image processing

Posted 07 March 2011 - 09:50 PM

How are you guys, i am currently working on image processing code using track bars to emboss, sharpen, brighten and apply negative effects to an image. But now i want the track bar slider to be on center during the form load and it to reduce to effects when the user slides it to the left. my code for embossing is:
Private Sub trbEmboss_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles trbEmboss.ValueChanged
        Dim bmap As Bitmap
        bmap = New Bitmap(pbEdited.Image)
        pbEdited.Image = bmap
        Dim tempbmp As New Bitmap(pbEdited.Image)
        Dim i, j As Integer
        Dim DispX As Integer = 1, DispY As Integer = 1
        Dim red, green, blue As Integer

        With tempbmp
            For i = 0 To .Height - 2
                For j = 0 To .Width - 2
                    Dim pixel1, pixel2 As System.Drawing.Color
                    pixel1 = .GetPixel(j, i)
                    pixel2 = .GetPixel(j + DispX, i + DispY)
                    red = Math.Min(Math.Abs(CInt(pixel1.R) - CInt(pixel2.R)) + 128, 255)
                    green = Math.Min(Math.Abs(CInt(pixel1.G) - CInt(pixel2.G)) + 128, 255)
                    blue = Math.Min(Math.Abs(CInt(pixel1.B)/> - CInt(pixel2.B)/>) + 128, 255)
                    bmap.SetPixel(j, i, Color.FromArgb(red, green, blue))
                Next

                If i Mod 10 = 0 Then
                    pbEdited.Invalidate()
                    pbEdited.Refresh()
                    Me.Text = Int(100 * i / (pbEdited.Image.Height - 2)).ToString & "%"
                    'pbEmboss.Value = Int(100 * i / (PictureBox1.Image.Height - 2))
                End If


            Next
        End With
        pbEdited.Refresh()
        Me.Text = "Done embossing image"


Anyone with an idea, please help me and thank you in advance.

This post has been edited by macosxnerd101: 07 March 2011 - 09:51 PM
Reason for edit:: CODE TAGS!!! USE THEM!!!


Is This A Good Question/Topic? 0
  • +

Replies To: Image processing

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8937
  • View blog
  • Posts: 33,462
  • Joined: 12-June 08

Re: Image processing

Posted 08 March 2011 - 08:40 AM

Are you receiving the error from this post
http://www.dreaminco...mage-processing

or is this just how to make a center = 0 valued track bar?

If it's the latter then it's a pretty quick function if you think about for a minute.

You can make a quick function that inputs the total length of the track bar on a 0 to x scale and the currently selected value on that track bar.

The function then would find the center index which should be....? x/2 right?

If the value selected on the track bar equals this center index then return 0. Center is zero, right?

Everything else is determined by the current value minus the center index.

Seems pretty straight forward.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1