Draw multiple circles in one image
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
Hello, everyone,
I need your help. I wanted to draw several circles in one picture and edit them later. Attached is a screen shot. thank you for your help
Latifa
採用された回答
R = 2:2:10 ;
th = linspace(0,2*pi) ;
figure
hold on
for i = 1:length(R)
x = R(i)*cos(th) ;
y = R(i)*sin(th) ;
plot(x,y)
end
axis equal

9 件のコメント
Latifa Bouguessaa
2022 年 7 月 27 日
thanks sir for your help
how can I cut off the individual circles from the image for further processing? is there a function for this?
Latifa Bouguessaa
2022 年 7 月 27 日
編集済み: Walter Roberson
2022 年 7 月 30 日
i tried again but without success
here is my code:
image = imread('cameraman.tif');
figure(1)
imshow(image,'DisplayRange',[]);
xc=128;
yc=128;
theta=linspace(0,2*pi);
c0=1;
r=[10,20,30,40,50];
for i = 1:length(r)
x = r(i)*cosd(theta) + xc;
y = r(i)* sind(theta) + yc;
pos = [x, y];
viscircles([x(i),y(i)],1,'LineStyle','-','LineWidth',1);
%viscircles('Position', pos, 'EdgeColor', 'g', 'LineWidth', 1)
axis square;
grid on;
subimage(:,:,co) = imcrop(image, pos);
co=co+1;
end

Error using images.internal.crop.parseInputsOverTwo>validateRectangle
Input number 2, RECT, is expected to contain 4 elements.
Input number 2, RECT, is expected to contain 4 elements.
Error in images.internal.crop.parseInputsOverTwo (line 54)
validateRectangle(spatial_rect,2);
Error in imcrop (line 104)
images.internal.crop.parseInputsOverTwo(varargin{:});
figure(2)
imshow(subimage,'DisplayRange',[]);
Walter Roberson
2022 年 7 月 30 日
img = imread('cameraman.tif');
figure(1)
imshow(img, 'DisplayRange', []);

[r, c, p] = size(img);
xc = 128;
yc = 128;
r=[10,20,30,40,50];
for i = 1:length(r)
ROI = images.roi.Circle('Center', [xc, yc], 'Radius', r(i));
mask = cast(repmat(createMask(ROI, img), [1, 1, p]), class(img));
masked_img = img .* mask;
subimage{i} = imcrop(masked_img, [xc-r(i), yc-r(i), 2*r(i)+1, 2*r(i)+1]);
end
for i = 1 : length(r)
figure
imshow(subimage{i}); title(string(r(i)));
end





Latifa Bouguessaa
2022 年 7 月 31 日
Latifa Bouguessaa
2022 年 8 月 12 日
Hello everyone.
thank you all for your help.
I still have a few questions though.
how can I call up and edit the individual ROIs from subimage{i}?
next task is to calculate the FFT of each ROI. How can I only edit the values inside the circle.
I thank you in advance
Image Analyst
2022 年 8 月 12 日
"how can I call up and edit the individual ROIs from subimage{i}?" <= you already have subimage{i}, so it's already "called up". To edit it, you assign values to certain rows and columns of it.
"next task is to calculate the FFT of each ROI." <= call ftImage = fft2(subimage{i}); The fft will apply to the entire rectangular image including the black masked off portions.
"How can I only edit the values inside the circle." <= I already told you how to edit the image. Just give row and column values inside the circle and reassign those intensity values.
Latifa Bouguessaa
2022 年 8 月 12 日
I tried to solve the task like this, but it doesn't work, I don't know what the problem is. Here is my code:
for i=1:length(r)
mm = mean(mean(subimage{i}(subimage{i}~=0)));
subimage{i}=(subimage{i}(subimage{i}~=0))-mm;
spe{i}= (abs(fftn(subimage{i}))).^2;
%pixel spacing
Deltax=Spasi(1);
Deltay=Spasi(2);
f=(Deltax*Deltay)/size(subimage{i},1).^2;
w4{i}=mean(spe{1,i});
nps{i}=f*w4{i};
nps{i}=nps{1,i}/sum(nps{i});
spaki=Spasi(1,1);
[q g]=size(nps{i});
%Frequency
frequency=(1/((r(i)+1)*2*spaki));
sumbu=0:frequency:(((g-1)*frequency));
hold on
figure(5)
subplot(3,2,i)
hold on;
plot(sumbu, nps{i}, 'o--')
xlabel('Spatial Frquency ?mm?^-1')
ylabel('NPS)
set(gcf, 'color', 'w')
end
Image Analyst
2022 年 8 月 12 日
I have no idea what you want to do. All professional programmers put comments into their code. Where are yours? Explain every section or line of your code up until the plotting part.
Walter Roberson
2022 年 8 月 12 日
You cannot reliably recreate the roi given just the subimage and comparing it to 0, as interior pixels could be 0.
You could, it is true, take the subimage and fit a circle to it to recreate the roi.
But if you are going to need the roi later, just record the mask variables as well, it saves a lot of trouble.
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Image Arithmetic についてさらに検索
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
