How to replicate nearby pixel in the circle to the black background outside the circle

1 view (last 30 days)
Hey everyone,
I have an image below. I want to replicate the colour of the background near the edges in the circle to the background outside of the circle including the 'blue' edges of the circle so that there will not be an obvious colour difference.
I have tried the following code below but I have only managed to get a white background and the blueish-black circular line/edges can be seen.
% Extract the individual red, green, and blue color channels.
redChannel = I(:, :, 1);
greenChannel = I(:, :, 2);
blueChannel = I(:, :, 3);
% If background is less than 45, say it's background.
% Adjust the value as needed to achieve what you want.
thresholdValue = 45;
mask = redChannel <= thresholdValue & greenChannel <= thresholdValue & blueChannel <= thresholdValue;
% Display the mask image.
subplot(2, 2, 2);
imshow(mask);
title('Mask Image', 'FontSize', fontSize);
% Initialize the masked channels.
maskedRed = redChannel;
maskedGreen = greenChannel;
maskedBlue = blueChannel;
% Do the masking - make white where it was black.
maskedRed(mask) = 255;
maskedGreen(mask) = 255;
maskedBlue(mask) = 255;
% Recombine separate masked color channels into a single, true color RGB image.
maskedRgbImage = cat(3, maskedRed, maskedGreen, maskedBlue);
Can anyone please help me in what way would be suitable to replicate the nearby pixel in the circle and replace the black background outside the circle and also the 'blue' edges with it? Thank you in advance!
Best regards

Answers (0)

Community Treasure Hunt

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

Start Hunting!