필터 지우기
필터 지우기

How to apply spatially-varying blur to an image?

조회 수: 10 (최근 30일)
xiaojuezi
xiaojuezi 2020년 10월 18일
댓글: Image Analyst 2020년 10월 19일
Hi
I have an image of size 128x128, and an associated a blur map, where each element defines the size of the blur kernel. How can I apply this blur map to the image so that each pixel is blurred differently?
Thank you very much.
  댓글 수: 2
Matt J
Matt J 2020년 10월 18일
How is it enough to know the size of the local blur kernel? What about its shape?
xiaojuezi
xiaojuezi 2020년 10월 18일
I think any smoothing filter can be applied, for example a standard Gaussian filter.

댓글을 달려면 로그인하십시오.

답변 (1개)

Image Analyst
Image Analyst 2020년 10월 18일
See my manual convolution demo. You'll need to change it to make the inner loops change their starting and ending values depending on the size of the blur window you read from your blur map (which hopefully is composed of only odd numbers). Should be really, really easy with only about 2 lines needing to be added
  1. call blurmap = imread(filename) to read in your blur image.
  2. get the blur window width between the second and third for loop by reading the blurmap at that row and column:windowWidth = blurmap(row, column)
and two to be modified -- the limits on the inner two for loops.
But let me know if you can't figure it out and attach your blur image.
  댓글 수: 2
xiaojuezi
xiaojuezi 2020년 10월 18일
Thank you very much for your answer and your script! I have one question, I think the limits of the two outer for loop also need to be changed. How do you decide these limits since each pixel now has a different windowSize?
Image Analyst
Image Analyst 2020년 10월 19일
Yes, good point. Depends on how much work you want to go into to handle the edge effects. One way is to just determine the starting and ending rows and columns by getting the max of the whole blur map and use that. What's wrong with that? I mean how much difference does it make REALLY to be more accurate near the edges? Probably won't make a noticeable difference so just go with the easiest route, which is to use the largest window.
What's the use case? Why do you want the blur to vary by location anyway?

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by