Reverse Blurring?
Author |
Message |
scytheblades
|
Posted: Mon May 29, 2006 1:35 pm Post subject: Reverse Blurring? |
|
|
Hey all
First time posting, very impressed with the stuff i've seen here.
Anyways, i'm trying to do a "reverse blurring". The effect i'm trying to get is having an original picture blurred, then not as blurred, until it becomes normal.
I was thinking of a "for descending" to handle the down blurring, but I am getting nowhere. I think this is possible, but am having trouble with making this happen.
Any pointers would be welcome.
THanks,
MikeB |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Albrecd
|
Posted: Mon May 29, 2006 1:46 pm Post subject: (No subject) |
|
|
It would be very helpful if you'd post your code. A desending for loop sounds like the right Idea but we need to know your method of blurring in order to help . |
|
|
|
|
|
TheOneTrueGod
|
Posted: Mon May 29, 2006 1:56 pm Post subject: (No subject) |
|
|
the command "descending" isn't really going to help you in this instance, all that will allow it to do is start at the top left as opposed to the bottom left. (Depending on which one you chose to be your "descending" for count)
What you want to do is check every other pixel (Or every 3rd pixel, or every 5th pixel, or whatever you want, depending on how blurry you want it) and copy that pixels colour to the pixel beside it (Once again, depending on how often you check, you may want to adjust where the new colour).
For this, go check the Turing Walkthrough for View.WhatDotColour. This will give you the pixel colour at a certain co-ordinate. As for the checking every other pixel,
code: |
for i : 1..10 by 2
put i
end for
|
I think thats a good enoug hint |
|
|
|
|
|
Albrecd
|
Posted: Mon May 29, 2006 2:04 pm Post subject: (No subject) |
|
|
TheOneTrueGod wrote: What you want to do is check every other pixel (Or every 3rd pixel, or every 5th pixel, or whatever you want, depending on how blurry you want it) and copy that pixels colour to the pixel beside it
But this wouldn't work for reverse blurring, which is what scytheblades is trying to do.
scytheblades wrote: i'm trying to do a "reverse blurring". The effect i'm trying to get is having an original picture blurred, then not as blurred, until it becomes normal. |
|
|
|
|
|
Cervantes
|
Posted: Mon May 29, 2006 4:20 pm Post subject: (No subject) |
|
|
That's an interesting question. Perhaps how it is done is, for each pixel on your grid, set the new colour of that pixel to the average of the colours of the 8 pixels around it.
Some notes:
- You cannot update the pixel colour immediately, because that would change the results for the pixels all around it. You'd have to store the new colour in a secondary array (or whatever data structure you're using to hold the pixels).
- To compute the average of 8 pixels, you need to use RGB. Find the average red value, the average green value, and the average blue value, then combine those into one new RGB colour.
- The RGB tutorial can be found here: http://www.compsci.ca/v2/viewtopic.php?t=5254
- If you change Turing's colour palette (using RGB.SetColour), the results of whatdotcolour change too. So if I changed the palette to be only in shades of grey, whatdotcolour would return the closest shade of grey to the given pixel.
- Turing's colour pallette can only hold 256 colours at any one time. Thus, your results won't be very pretty. You'll also have to get a good algorithm to redefine the colour palette to get good colours: not the garbage Turing gives you.
|
|
|
|
|
|
codemage
|
Posted: Tue May 30, 2006 9:10 am Post subject: (No subject) |
|
|
Sharpening is logically the opposite of blurring.
So, instead of adding colour information to a pixel from its neighbours, you subtract a small fraction of each neighbour's colour from the original.
This will NOT be able to restore the original image, since blurring permanently destroys some of the original data - but you may be able to come close if the image isn't blurred too much, and if you get the fraction right. |
|
|
|
|
|
Delos
|
Posted: Tue May 30, 2006 10:44 am Post subject: (No subject) |
|
|
As codemage has pointed out, it is pretty much impossible to 'unblur' an image once it has been blurred (think about the maths of averages. There are several combinations of numbers that could yield the same average, hence the problem). However, for your problem, could could do the following:
- start with your original image
- blur it as many times as you need, storing each blur in memory
- present the images in reverse order to achieve your effect
Note that blurring can be *very* slow in Turing. I haven't tried out the new 4.1 yet, but I'm told it is a little faster w.r.t. graphics...so you might not want to do the blurring on the fly. You could just as easily prerender your pics, save them, and use import them during the programme. Not as pretty, but it works. |
|
|
|
|
|
|
|