How to remove values beyond threshold from certain label?
Show older comments
Dear all,
I have a set of values intValues (data set attached at bottom). From the values I create a binary mask and label each region.
bulkBinaryMask = intValues > 0;
bulkBinaryLabel = bwlabel(bulkBinaryMask);
From "Region 2" I would like to remove any values <-0.05 and >+0.05.
I know how to remove values for whole data set as such:
intValues(intValues<-0.1)= 0.
I was wondering how do I remove values within each region?
To expand on this question for future, lets say, I want to replace the 9th and last values of the region 1 to be 0. How do I do that?
Many thanks in advance and really appreciate your help.
intValues = [0;0;0;0;0;0;0;0;0;0;0;0;0.26244465;0.29007468;0.26653862;0.29302722;0.26668695;0.26518479;0.26084769;0.28639266;0.26425231;0.25237250;0.26585105;0.29383880;0.25984868;0.28605866;0.28393352;0.23753427;0.21833633;0.21159969;0.19674303;0.19256258;0.14822936;0.15898322;0.16137893;0.11557713;0.096215844;0.12425362;0.11965461;0.12414602;0.14914773;0.17779414;0.16764416;0.10261737;0.097361661;0.26717466;0;0;0;0;0;0;0;-0.091555580;-0.014126119;-0.0075604324;-0.010243786;-0.015728250;0.014402754;0.0061065373;-0.034150224;0.033243932;-0.025414338;0.0021870080;-0.017752288;-0.0042569139;0.0010967045;-0.0025044910;-0.0091931168;-0.00098206359;-0.022899218;-0.0093692830;-0.011437733;-0.0084309950;-2.7552773e-05;-0.0043535922;0.0090775713;0.036743760;0.23081724;0;0;0;0;0;0;0;0;0.10118896;0.16281490;0.15751003;0.12994391;0.15854512;0.17712460;0.24465595;0.17683943;0.11180082;0.14216836;0.14462484;0.10606941;0.14113182;0.19906932;0.16165967;0.21997970;0.31712520;0.30911356;0.31779054;0.29921058;0.32097855;0.30999324;0.30381167;0.29537085;0.28719103;0.32213023;0.33997473;0.31646192;0.31416368;0.33734962;0.32147244;0.33623534;0.31780452;0;0;0;0;0;0;0;0];
2 Comments
Image Analyst
on 8 Feb 2018
So as the final result, bo you want a new binary image with only region 2 in there but a new region 2 which does not include any values in that range in the original image? Note that removing original pixels in that range might possibly split region 2 into 2 or more separated regions depending on where the values to be removed lie.
Accepted Answer
More Answers (1)
Birdman
on 8 Feb 2018
I would like to remove any values <-0.05 and >+0.05
To do this at one line, type
intValues=intValues(intValues>=-0.05 & intValues<=0.05);
Categories
Find more on Signal Operations in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!