Win a copy of Java EE 8 High Performance this week in the Java/Jakarta EE forum!
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Sheriffs:
Saloon Keepers:
Bartenders:

Solving Box Blur Filter with radius

Ranch Hand
Posts: 579
6
Hi,

I am working on solving a problem based on box blur filter. I am given a pixel matrix of size (n x n) along with width and height of an image. I am given x-axis coordinate and y-axis coordinate of current pixel to be processed. I am also given a radius in which I have to apply the blur function.

Here is what I understand so far. I have to iterate the width and height of the image. for each position I need to check if I am within radius range and then apply some calculation for blurring of pixel. I believe we have to average out the pixel values. Again not sure how that works.

Would someone please explain the relation between pixel matrix and blur radius. I searched quite a bit to find some article which explains this, but did not find much. Mostly they give horizontal and vertical blur functions, which I do not need.

Here is sample data for my processing :

Thanks

Rancher
Posts: 2767
32
• 1
How is this a java programming problem?

If you have an algorithm you are trying to code in java, please post the algorithm and the code you have written and ask some questions about the problems you are having writing code to follow the algorithm.

s ravi chandran
Ranch Hand
Posts: 579
6

Norm Radder wrote:How is this a java programming problem?

If you have an algorithm you are trying to code in java, please post the algorithm and the code you have written and ask some questions about the problems you are having writing code to follow the algorithm.

I do not have the algorithm yet. I am still trying to figure out how to solve it.

Here is the code I have so far :

From an article I found in this link, I get that I have to average out pixel value for given (x, y) coordinate. But I do not know how to get the radius range from this matrix and get the average pixel value.

Rancher
Posts: 2767
32

I do not have the algorithm yet. I am still trying to figure out how to solve it.

It is important to get a design/algorithm before trying to write any code.

s ravi chandran
Ranch Hand
Posts: 579
6

I do not have the algorithm yet. I am still trying to figure out how to solve it.

It is important to get a design/algorithm before trying to write any code.

Agreed on that point. I also was looking at that aspect.

Would someone please explain the relation between pixel matrix and blur radius. I searched quite a bit to find some article which explains this, but did not find much. Mostly they give horizontal and vertical blur functions, which I do not need

I am unable to find a generic algorithm which doesn't discuss about specific type of filtration. Maybe I am not looking at right place, but not sure where to look for it.

Saloon Keeper
Posts: 3726
47
• X 2

s ravi chandran wrote:Would someone please explain the relation between pixel matrix and blur radius. I searched quite a bit to find some article which explains this, but did not find much.

You have two matrices, your image or pixels (NxN), and the convolution (in your example 5x5). The size of the convolution (box) matrix can be derived from the radius where
height = width = 2 x Radius + 1
divisor = width x height
All positions in the convolution matrix are set to '1'. After all the pixels are multiplied by the convolution values the sum is then divided by the divisor.

s ravi chandran
Ranch Hand
Posts: 579
6

Carey Brown wrote:

s ravi chandran wrote:Would someone please explain the relation between pixel matrix and blur radius. I searched quite a bit to find some article which explains this, but did not find much.

You have two matrices, your image or pixels (NxN), and the convolution (in your example 5x5). The size of the convolution (box) matrix can be derived from the radius where
height = width = 2 x Radius + 1
divisor = width x height
All positions in the convolution matrix are set to '1'. After all the pixels are multiplied by the convolution values the sum is then divided by the divisor.

Thanks for the response. I have solved the problem.