Create narrow band of pixels under gray region
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Nataliya
am 28 Apr. 2018
Beantwortet: Image Analyst
am 28 Apr. 2018
I want to create a narrow band of pixels (white pixels) neighbouring the lower side of gray region. Please see the attached image.
The expected output would be like:
How can I do this? Please help. Thanks.
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 28 Apr. 2018
Threshold for black.
mask = grayImage == 0;
Extract the two largest regions
mask = bwareafilt(mask, 2);
Then find the centroid or bounding box
props = regionprops(mask, 'Centroid');
and extract the lower black region. See if you can do this yourself.
Call imerode() to shrink it. Then XOR the shrunken region with the original region to get just the edges.
mask = imerode(lowerMask, true(9)); % Increase from 9 to get a wider white region.
mask = xor(mask, lowerMask);
Then set those pixels in the original image to white:
grayImage(mask) = 255;
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Modify Image Colors finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!