0

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?

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by quuba
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]?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.