Trace a ROI and remove it from image

Hi All
I have the following image . I want to trace the part which is shown in red lines and remove it from the image . but I don't know how I can scan from top to bottom to find the object and remove it. can anyone help me to do this ???
Thanks in advance for helping me
Here is the image attached
here is another image

Answers (1)

See my attached masking demo. It will do that.

6 Comments

Alina tom
Alina tom on 22 Jul 2018
Edited: Alina tom on 22 Jul 2018
Sir I want to scan the image from top to bottom every column and remove the object automatically . not by selecting it from the image. I have seen your demo . it is good but I don't want to use manual tracing object
Since you know the location (columns) of the red lines that you drew, you can simply do
binaryImage(:, column1 : column2) = false;
Sir the main problem is to find the location . I am not able to find these locations. I have just draw these lines by hand
So I'm guessing (since you haven't explained it) that you want to eliminate little blobs attached to the main large blobs with smoothly varying tops. Is that right?
If so, what I'd do is to fit the top rows to a very smooth line with conv() using a very large window. Then I'd compute the absolute different of that curve to the actual curve. Any that are above some threshold distance, I'd toss out (like set to nan or zero or something). Easy - give it a try
windowWidth = 101;
kernel = ones(1, windowWidth);
smoothedTopRows = conv(topRows, kernel, 'same');
diffs = topRows - smoothedTopRows;
badColumns = diffs > 5; % or whatever.
topRows(badColumns) = nan;
That's untested so adapt it if it's not working.
Sir how I can trace the small blob by scanning image from top to bottom?
the small blob has a dark shadow below it . how can we use this information to trace that part and remove it
ALL your blobs have dark regions below them.
You can use bwareafilt() if you want to toss out small blobs.

Sign in to comment.

Asked:

on 22 Jul 2018

Commented:

on 23 Jul 2018

Community Treasure Hunt

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

Start Hunting!