Filter löschen
Filter löschen

How to split image based on sectors.

1 Ansicht (letzte 30 Tage)
SHISHIR PARAMATHMA RAO
SHISHIR PARAMATHMA RAO am 3 Jan. 2017
I have an image that I need to segment.
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.
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.

Akzeptierte Antwort

Guillaume
Guillaume am 3 Jan. 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
  1 Kommentar
SHISHIR PARAMATHMA RAO
SHISHIR PARAMATHMA RAO am 3 Jan. 2017
This is very nice way of doing it. But the only drawback is in all the masks, the tips are not touching. But I'm sure I can handle that. Thanks.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by