MATLAB Circular sliding window and how to get pixel values on diameter in any directions
1 view (last 30 days)
Show older comments
I'm trying to implement an algorithm that needs a circular sliding window, that goes through all the pixels of the image, and for each window I need to extract only pixels that lay on diameters at different angles of the circle.
I try to explain better with the use of the image above. Imagine that this is the result of a circular sliding window, I want to get only the pixel values that lay on the red lines (diameter tilted of pi/8). So far, I wrote these lines of code:
I= imread('lena.png');
I = im2double(I);
h = fspecial('disk',5);
h = h > 0;
dir = pi/8;
o_image = blockproc(I, [1 1], @(x) MMF2D(x,h,dir), 'BorderSize', [5 5],...
'TrimBorder', false, 'PadPartialBlocks', true);
and the function MMF2D:
function [ o_pixel ] = MMF2D( i_block, i_window, i_directions)
%MMF2D Summary of this function goes here
% Detailed explanation goes here
new_block = i_block.data .* i_window;
But from here, I don't know how to continue for getting pixels that lay on the diameter. Any help is greatly appreciated!
0 Comments
Answers (2)
Eduardo García Aráoz
on 24 Dec 2019
Hi Davide,
How are you?
I'm new to MATLAB and I'm just looking for a code that does exactly what you propose in this question, I wanted to know if you managed to solve it and if you could share the code with me.
Thank you very much already!
greetings,
Eduardo.
0 Comments
Image Analyst
on 24 Dec 2019
I suggest you use nlfilter() to scan your image. You will tell it to call a function that sets up your various endpoints, and calls improfile(). This will interpolate values. Otherwise you'll get very quantized values because for small circles, there are not pixels at all the angles you'd want.
2 Comments
Eduardo García Aráoz
on 24 Dec 2019
Thank you very much,
you have an example of this code to see how it works?
Image Analyst
on 24 Dec 2019
Attached is an example of nlfilter.
improfile has an example in the help.
See Also
Categories
Find more on Image Processing Toolbox 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!