How to filter out annular data from square matrix

Have a square matrix...501 by 501...Z=501×501
Need to filter out an annular data 20 to 150 centered at (251,251)

 採用された回答

Image Analyst
Image Analyst 2018 年 7 月 7 日

2 投票

See the FAQ for creating a circle:
Then to get row and column indexes for your matrix, simply round, making sure that x is the second dimension, not the first because arrays are indexes as array(y, x) NOT array(x,y)
rows = round(y);
columns = round(x);
for k = 1 : length(rows)
Z(rows(k), columns(k)) = 0; % Filter to have whatever value you want them to have.
end

3 件のコメント

Bhowmik.U
Bhowmik.U 2018 年 7 月 7 日
編集済み: Image Analyst 2018 年 7 月 8 日
Thanks a lot Sir, it works like cream! Problem solved
A last help I shall request in this thread
I converted the image to pixel format as in figure. I have a 20x20 matrix of UU_avg (attached Excel file) I am also sharing the code which I use to plot..and the resultant image (png).
*However, the resultant plot (in the same enclosed word file) shows only 2 axes..the other two seems to be non-existent
Is there a way out?*
code:
im=surf(UU_avg,'EdgeColor','none','LineStyle','none');
view(-90,90);
xtick = [0, 2.5, 7.5, 10, 12.5, 17.5, 20];
ytick = [0, 2.5, 7.5, 10, 12.5, 17.5, 20];
xticklabels = {'-150','-100', '-50', '0','50', '100', '150'};
yticklabels ={'-150','-100', '-50', '0','50', '100', '150'};
set(gca, 'XTick', xtick);
set(gca, 'YTick', ytick);
set(gca, 'YTickLabel', yticklabels);
set(gca, 'XTickLabel', xticklabels);
hh=colorbar;
title(hh,'%','FontSize',14,'fontweight','bold');
set(gca,'FontSize', 14,'fontweight','bold');
set(gca,'Linewidth',3);
axis tight;
box on;
Image Analyst
Image Analyst 2018 年 7 月 8 日
Looks fine to me
Probably a rendering issue. Look at the opengl() function and try some different things.
Bhowmik.U
Bhowmik.U 2018 年 7 月 9 日
Thanks again Sir!

サインインしてコメントする。

その他の回答 (1 件)

Bhowmik.U
Bhowmik.U 2018 年 7 月 7 日

0 投票

Thanks for the suggestion..however I tried on similar lines but that yielded concentric boxes of data..rather than circles...

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by