954,554 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

An improved blur method

I'm supposed to modify this method ( http://pastebin.com/6xF1pN51 ) to this (translated):

"A faster algorithm to compute the average can be done by looping through the entire image in two passes in each session and make a one-dimensional mean value.

In the first pass compute the mean value of the y-axis (one dimension) and in the second calculate the mean in x direction (one dimension).
The combined effect of the two one-dimensional mean values becomes a two-dimensional mean value."

http://pastebin.com/Rvw2ZSak is what i've done.

It works but the results are a bit off if I compare it to the real method, not sure if i've done it right..


---
> Picture X = new Picture(FileChooser.pickAFile())
> Picture Y = new Picture(FileChooser.pickAFile())

> X.blur(2)
> Y.blur2(2)

> Y.getPixel(50,50)
Pixel red=40 green=74 blue=50

> X.getPixel(50,50)
Pixel red=41 green=75 blue=50

--
X and Y == same image of course.
Any ideas?

Kremlan
Newbie Poster
7 posts since Nov 2010
Reputation Points: 7
Solved Threads: 0
 

line:
Color newColor = new Color(r / count, g / count, b / count);
introduces rounding error for each color component

A faster algorithm uses this line two times (rows and columns separately) for smaller number of cells to compute and introduces cumulative rounding error (two roundings)

[side effect of separation of the dimensions of space -> bug grows, time decreases]?

quuba
Posting Pro
573 posts since Nov 2008
Reputation Points: 123
Solved Threads: 106
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: