I have a 64x64 rectangular ROI. I want to place 30 of them in a radial pattern from a set distance from the center of my image. I will then calculate take the FFT of these ROI regions. I can't seem to figure our how to plot the ROIs in a radial pattern. Any starting tips would be greatly appreciated! Let me know if I need to provide more details. Example of what I would like below.

 채택된 답변

Simon Chan
Simon Chan 2021년 10월 2일

0 개 추천

Try using function cart2pol, following is an example
clear; clc;
Ny = 1000;
Nx = 1000;
Nz = 30; % Number of ROIs
rho = 200; % Radius, 200 pixels
theta = linspace(-pi,pi,Nz); % Theta separation
cx = 400; % Your center point, x-coordinates = 400 (example)
cy = 700; % Your center point, y-coordinates = 700 (example)
[x,y] = pol2cart(theta,rho); % Use pol2cart
cx_coord = round(cx-x); % Convert back from polar coordinates
cy_coord = round(cy-y);
ROIsize = 64; % Size of ROI
x1 = round(cx_coord - ROIsize/2); % x start position
x2 = x1 + ROIsize - 1; % x end position
y1 = round(cy_coord - ROIsize/2); % y start position
y2 = y1 + ROIsize - 1; % y end position
plot(cx, cy,'g*');
hold on
for k = 1:Nz
plot(cx_coord, cy_coord, 'b.')
plot([x1(k),x2(k),x2(k),x1(k),x1(k)],[y1(k),y1(k),y2(k),y2(k),y1(k)],'r-');
end
xlim([0 Nx])
ylim([0 Ny])

댓글 수: 7

Russell Chow
Russell Chow 2021년 10월 2일
oh i see. I have never used cart2pol before so i will give it a shot. thank you very much!
Russell Chow
Russell Chow 2021년 10월 2일
@Simon Chan how would I be able to apply an FFT to each of these ROIs and save them in an array?
Russell Chow
Russell Chow 2021년 10월 2일
also is there a way i can use drawrectangle to set the ROIs?
Drawing a rectangle merely draws some graphic in the overlay above the image. It doesn't really "set an ROI". You would need to extract the little image and then call fft2 on it
subImage = grayImage(y1(k) : y2(k), x1(k) : x2(k));
Note that the y's are the first index, not the second.
Russell Chow
Russell Chow 2021년 10월 2일
@Image Analyst thank you! I also used drawrectangle to create the ROIs instead of merely drawing lines.
Image Analyst
Image Analyst 2021년 10월 2일
편집: Image Analyst 2021년 10월 2일
Yes, the drawrectangle() function (unlike plot() and rectangle()) can return an "roi" object class.
Russell Chow
Russell Chow 2021년 10월 3일
@Image Analyst I have a quick question. i created a mask of the roi and i want to take the FFT of this section, however due to the mask, all my values in the roi are just 1. how can i use the pixel values in the roi without making them binary?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

질문:

2021년 10월 2일

댓글:

2021년 10월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by