Averaging Overlapping Pixels in Sliding Window Operation
Show older comments
Hello,
I'm looking for an efficient way to average overlapping pixels which are result of sliding window operation.
To explain my self, imagine we have a 2D matrix (Image) - I. We operate a sliding window operation of window size of 5x5. Each window undergoes a transform, operation and then back.
Now, a certain pixel, I(i, j) appears in many windows (Actually 25).
I want to average all those 25 pixels (Same pixel just the result using different window).
This is for example a step in the BM3D algorithm.
Does anyone knows about efficient way to this in MATLAB?
The structure should be something like:
- Create the patches of the image (im2col can do that).
- Apply the operation in the patches.
- Average the same pixels from all patches it was involved in.
Thank You.
1 Comment
Now, a certain pixel, I(i, j) appears in many windows (Actually 25).
I think you really mean a certain pixel (i,j). The notation I(i,j) would refer to a pixel value, not a pixel location.
I want to average all those 25 pixels (Same pixel just the result using different window).
Conversely, here, I think you mean 25 pixel values. If the pixel in question is the same pixel each time, there shouldn't be 25 of them. You're saying, I assume, that the same pixel location receives a different value from each of the 25 blocks that it belongs to.
Accepted Answer
More Answers (2)
Image Analyst
on 3 Oct 2014
0 votes
There can be 25 window locations that contain pixel at location (i,j). Each of those windows has one output value and is placed into an output image at different locations corresponding to the center of the window. To average those output values, you'd use imfilter() or conv2() operating on the output image (not the input image).
4 Comments
Royi Avital
on 3 Oct 2014
Edited: Royi Avital
on 3 Oct 2014
Image Analyst
on 3 Oct 2014
Edited: Image Analyst
on 3 Oct 2014
That's a different explanation - now you're saying to average all 25 pixels in a single window centered around (i,j) and what you said before was to look at 25 different windows that contain pixel (i,j): "pixel I(i, j) appears in many windows (Actually 25)." Those are different things - different numbers of windows.
What you just described in your comment is simply the convolution!
output = conv2(double(grayImage), ones(5)/25, 'same');
Royi Avital
on 3 Oct 2014
Image Analyst
on 4 Oct 2014
I have a hard time visualizing what im2col does(). What is your overall objective? To blur the image?
Royi Avital
on 27 May 2017
Edited: Royi Avital
on 27 May 2017
Categories
Find more on Neighborhood and Block Processing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!