Click here to Skip to main content
15,610,660 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I have the code below and would like to see change in the image on increments of 10% starting from 0% to 100% when track bar is moved.

Currently the code only gives me one instance of change but not in a progressive manner e.g like in volume control.

How do I apply separate filters so that my track bar can help me achieve these results?
Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll
        Dim sharpness As Single = CSng(TrackBar1.Value / 100) ' no change in brightness
        Me.Cursor = Cursors.WaitCursor
        ' Make a Bitmap32 object.
        Dim bm As New Bitmap(PicBefore.Image)
        Dim bm32 As New Bitmap32(bm)
        ' Subtract from the original image.
        Dim new_bm32 As Bitmap32 = bm32.Unsharp(Bitmap32.BlurFilter5x5Gaussian, 3)
        ' Display the result.
        PicAfter.Image = new_bm32.Bitmap
        Me.Cursor = Cursors.Default
    End Sub
Updated 24-Feb-11 12:47pm
Dalek Dave 24-Feb-11 18:48pm    
Edited for Title Shout, Grammar and Spelling

1 solution

You no not need and should not apply more than one filter in this case, that would be incorrect.

"Unsharp masking" (USM) method does not have just on "sharpness" parameter. It is controlled by three parameters, "Amount", "Radius" and "Threshold", see[^]. So, it needs three track bars, not one. I am unfamiliar with your Bitmap32 class, what is it? It does not look like the method Unsharp is what you need, probably this is only blurring part of the filter.

You should always keep original image before applying the filter. You track bars should control parameters of the filter. The filter should be applied to original image every time track bar position is modified.

For a good Open Source library for image processing look at AForge.NET by Andrew Kirillov:[^], see also his CodeProject articles AForge.NET open source framework[^], Image Processing Lab in C#[^].

Share this answer
Espen Harlinn 24-Feb-11 18:37pm    
Good reply, my 5
Sergey Alexandrovich Kryukov 24-Feb-11 18:50pm    
Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900