Assign value to a circular mask

6 ビュー (過去 30 日間)
X
X 2014 年 8 月 14 日
回答済み: Dishant Arora 2014 年 8 月 14 日
Hi everyone,
I used the following code to generate a circle mask located at [cX, cY] on a 500 by 500 "film":
cX=200; cY=100; r=30; % radius of the circle width=500; height=500;
[W,H]=meshgrid(1:width, 1:height); mask=sqrt((W-cX).^2+(H-cY).^2)<=r; imshow(mask) colorbar
But for now the circle value = 1, and the rest of the film value = 0; How can I assign specific value (for instance, 5) to the circle value?
Thank you! Sonia

採用された回答

Dishant Arora
Dishant Arora 2014 年 8 月 14 日
Use logical indexing.
circDisk = double(mask); % Converting mask to the type double
circdisk(mask) = 5 % or whatever value you want.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAuthor Block Masks についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by