Create ROIs with a radius and at a 20° angle
5 次查看(过去 30 天)
显示 更早的评论
Good day,
I hope someone can help me here
I have a DICOM image (Phanton) and I need 18 ROIs (15X15) along a radius (see attached picture)
The radius and center of the phantom are known
Please give me ideas on how to do this
Warm greetings
Latifa
0 个评论
采纳的回答
Image Analyst
2022-7-3
See the FAQ
then adapt it like this. Modify my adaptation to use sizes of your choosing.
grayImage = imread('cameraman.tif');
imshow(grayImage);
hold on;
[rows, columns, numberOfColorChannels] = size(grayImage);
xCenter = columns/2;
yCenter = rows/2;
allTheta = 0 : 20 : 359;
radius = 110;
% Show the circle
viscircles([xCenter, yCenter], radius, 'Color','y', 'LineWidth', 2);
boxWidth = 28;
for k = 1 : length(allTheta)
% Get this theta
theta = allTheta(k);
% Get the point on the circle
x = radius * cosd(theta) + xCenter;
y = radius * sind(theta) + yCenter;
% Get the upper left
xul = x - boxWidth/2;
yul = y - boxWidth/2;
pos = [xul, yul, boxWidth, boxWidth];
rectangle('Position', pos, 'EdgeColor', 'r', 'LineWidth', 2)
axis square;
grid on;
end
You can use pos with imcrop() if you want to crop out that little box into its own subimage.
subImage = imcrop(grayImage, pos);
Or you can get the lower right coordinates from
xul = round(x - boxWidth/2);
yul = round(y - boxWidth/2);
xlr = round(xCenter + boxWidth/2);
ylr = round(yCenter + boxWidth/2);
subImage = grayImage(yul : yur, xul : xur);
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!