How to split image based on sectors.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
SHISHIR PARAMATHMA RAO
el 3 de En. de 2017
Comentada: SHISHIR PARAMATHMA RAO
el 3 de En. de 2017
I have an image that I need to segment.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/159383/image.png)
The segments will be something like the above image. I may need to vary the number segments based on the angle. (Here I have taken roughly 22.5 degrees for each segment. I figured that I would generate multiple masks like the one shown below (with the tips touching of course) for each sector.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/159384/image.png)
But I am not sure how to go about.
I am trying to do this to analyze the content in each of these sectors and I would be required to change the angles for each image.
Any help in this direction will be greatly appreciated. Thanks in advance.
0 comentarios
Respuesta aceptada
Guillaume
el 3 de En. de 2017
Here is one way of doing it:
%width: width of mask images to generate, in pixels
%height: height of mask images to generate, in pixels
%anglestep: angle of segments, in degrees
width = 256; height = 256;
anglestep = 22.5;
[y, x] = ndgrid((1:height) - floor(height/2), (1:width) - floor(width/2)); %cartesian coordinates of each pixel
pixelangle = mod(atan2d(y, x), 180); %convert to angle in range [0, 180]
segment = discretize(pixelangle, 0:anglestep:180); %discretize into segment number
masks = arrayfun(@(sid) segment == sid, 1:ceil(180/anglestep), 'UniformOutput', false); %convert to masks
%display masks
for m = 1:numel(masks)
figure; imshow(masks{m}); title(sprintf('mask %d', m));
end
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!