How to mask the data of no information?

1 回表示 (過去 30 日間)
Amjad Iqbal
Amjad Iqbal 2022 年 9 月 21 日
コメント済み: Amjad Iqbal 2022 年 9 月 22 日
Dear Matlab experts,
I need to mask out data with no information and want to keep data for only targets of interest.
I have attached one image in which data with no information is masked out and retain with target information.
I have attached .mat file, could you please guide on how to mask the information of no use and get only target region?
Thank you!
Best Regards,
Amjad
load('two_targets.mat'); % data
imagesc(intensity,[-45 0]);
I need to keep target area as given in image below and maskout information of no use for spatial mean operation.
I used to cut data or keep points of target but it affects spatial mean operation.
  3 件のコメント
Walter Roberson
Walter Roberson 2022 年 9 月 21 日
What do you mean by "spatial mean" for this purpose?
What are the boundaries you want to mask with? Your .mat file does not contain anything that looks like a mask. Is the rule that two circles have to be constructed, both with center at half-height, with the two touching at half-width? If so then we would need to know the radius to use.
Amjad Iqbal
Amjad Iqbal 2022 年 9 月 21 日
From .mat file we can have this image named *output* given below.
Now I need to keep information of these two circular targets, according to the colormap its value varies roughlt from -20 to 0
I want to keep this information and mask out rest of the information below -45 to -20 with NaN as given in image above
having white background and two targets.
After that I need to apply sliding window for spatial mean operation.

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

採用された回答

Chunru
Chunru 2022 年 9 月 22 日
websave("two_targets.mat", "https://www.mathworks.com/matlabcentral/answers/uploaded_files/1132000/Two_targets.mat");
load('two_targets.mat'); % data
imagesc(intensity,[-45 0]);
intensity(intensity<-20) = nan;
figure
imagesc(intensity,[-45 0]);
  2 件のコメント
Walter Roberson
Walter Roberson 2022 年 9 月 22 日
3 x 3 sliding window (sliding one pixel at a time)
websave("two_targets.mat", "https://www.mathworks.com/matlabcentral/answers/uploaded_files/1132000/Two_targets.mat");
load('two_targets.mat'); % data
imagesc(intensity,[-45 0]);
intensity(intensity<-20) = nan;
imagesc(intensity,[-45 0]);
[min(intensity(:)), max(intensity(:))]
ans = 1×2
-19.9535 0
smoothed = blockproc(intensity, [1 1], @(block) mean(block.data(:), 'omitnan'), 'Border', [1 1], 'TrimBorder', false);
imagesc(smoothed);
[min(smoothed(:)), max(smoothed(:))]
ans = 1×2
-19.9535 0
Amjad Iqbal
Amjad Iqbal 2022 年 9 月 22 日
@Chunru and @Walter Roberson Thank you dear both!
It helps me a lot and work perfecly, and I learnt somthing new, I really appriciate your inputs

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

その他の回答 (0 件)

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by