Win a copy of Murach's Java Programming this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Solving Box Blur Filter with radius  RSS feed

 
s ravi chandran
Ranch Hand
Posts: 561
6
Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Norm Radder
Rancher
Posts: 2036
26
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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: 561
6
Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Norm Radder
Rancher
Posts: 2036
26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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: 561
6
Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Norm Radder wrote:
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.
 
Carey Brown
Bartender
Posts: 2696
41
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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: 561
6
Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Enjoy the full beauty of the english language. Embedded in this tiny ad:
Thoughts on deprecation in Java
https://coderanch.com/t/683016/java/Deprecation-Java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!