How to blur an image

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • wajerupali
    New Member
    • Oct 2006
    • 4

    #1

    How to blur an image

    Please guide me about showing bluring effect (incresing..and at end image feds) for a picture / image bos in Timer event.
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Originally posted by wajerupali
    Please guide me about showing bluring effect (incresing..and at end image feds) for a picture / image bos in Timer event.
    Just a quick thought off the top of my head...

    What about looping through the pixels using the Point() function, and setting each chunk of, say, four pixels, to the average colour of all four? In other words, say the values of the first few pixels in your image were...
    5 10 15 20
    8 12 10 38
    You could try setting them to...
    9 9 21 21
    9 9 21 21
    I imagine you'd get better results if you split the values into R/G/B components first, then averaged each of them, then combine the average values to produce the actual colour.

    If nobody comes up with a better answer (unlikely) and if I can find the time (very unlikely) I'll try to throw together a bit of sample code to demonstrate this idea. And to see whether it works, I suppose - remember I've just made this up on the fly.

    Comment

    • wajerupali
      New Member
      • Oct 2006
      • 4

      #3
      This code works on similar lines to produce blur effect. Take 3 picture boxes and picture 1 finaly has the effect

      Picture1.Pictur e = Picture2.Pictur e
      Dim barheight As Integer, barno As Integer, i As Long
      Dim r As Single
      r = h / w
      barheight = 200
      On Error Resume Next
      barno = w / barheight + 300
      For i = 1 To barheight + 100
      For j = 0 To barno
      Picture1.PaintP icture Picture3.Pictur e, j * barheight, 0, i, h, j * barheight, 0, i, h
      Picture1.PaintP icture Picture3.Pictur e, 0, r * j * barheight, w, i * r, 0, r * j * barheight, w, i * r
      Next
      DoEvents
      Next

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        Originally posted by wajerupali
        This code works on similar lines to produce blur effect. Take 3 picture boxes and picture 1 finaly has the effect
        ...
        I'll have to see if I can find time to try out this code. However, just at a glance it looks to me as though you are working with "twips". This is all very well, but I think you'll find things execute considerably faster if you work with pixels. The number of twips per pixel varies depending on your setup, but in my case it's 15. That means for every one pixel shown on the screen, you could be doing calculations for 225 points.

        If you're unfamiliar with how it all works, just try setting the Scalemode property ti "3 - pixel". And you may need to use properties such as ScaleHeight instead of Height, and so on.

        Comment

        • Killer42
          Recognized Expert Expert
          • Oct 2006
          • 8429

          #5
          Originally posted by wajerupali
          This code works on similar lines to produce blur effect. Take 3 picture boxes and picture 1 finaly has the effect
          ...
          I had to change a few things around to get it to run, and it did produce an interesting checkerboard sort of effect as it filled in the picture. But I don't see any blurring, just a copy of the original image.

          Comment

          Working...