Changing color of pixels around certain pixels
Show older comments
So I have an image named "0001.tif". I managed to import the image and do basic manupulations and save it.
What I am strugeling with is that when a pixel (that satisfies a certain criteria) is detected, the pixels in a 5 pixel radius should become white. In other words, these surrounding pixels' RGB values should change to 255.
Note: There can be more than one set of white pixels in the original image.
img = imread(append('0001.tif'));
R = img(:,:,1);
G = img(:,:,2);
B = img(:,:,3);
RGB = sqrt(im2double(R).^2+im2double(G).^2+im2double(B).^2);
idx = RGB<0.3;
R(idx) = 255;
G(idx) = 255;
B(idx) = 255;
imgNew(:,:,1) = R;
imgNew(:,:,2) = G;
imgNew(:,:,3) = B;
imwrite(imgNew,append('0001Processed.tif'));
Is there any way to acomplish this while using vectorization and without having to run through a nested for loop?
Accepted Answer
More Answers (0)
Categories
Find more on Morphological Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!