MATLAB: Change color in image

image processing

please refer the image below…..
is it possible to remove those boxes from that image…..
and also, is it possible to change the color of those boxes……
for example i want red box to appear yellow….
and the blue circle to appear red…. is it possible….
please do reply

Best Answer

Why don't you have access to the original image? If you don't, for some strange reason, then you can find the pixels by first extracting the individual color planes, then median filtering them and replacing the colored pixels with the median filtered pixels. It will work a lot better if you have the original uncompressed image, rather than the blurry one you uploaded, which does not have sharp graphics.
rgbImage = imread(fullFileName);
% Get the dimensions of the image. numberOfColorBands should be = 3.
[rows columns numberOfColorBands] = size(rgbImage);
% Display the original color image.
subplot(2, 2, 1);
imshow(rgbImage);
axis on;
title('Original Color Image', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
% Then do a median filter on each one.
medianRed = medfilt2(redChannel, [7 7]);
medianGreen = medfilt2(greenChannel, [7 7]);
medianBlue = medfilt2(blueChannel, [7 7]);
% Display the image.


subplot(2, 2, 2);
imshow(medianRed);
title('Red Median Image', 'FontSize', fontSize);
% Then find the pure color pixels.
thresholdValue = 40;
pureRed = redChannel >= thresholdValue & greenChannel < thresholdValue & blueChannel < thresholdValue;
pureGreen = redChannel < thresholdValue & greenChannel >= thresholdValue & blueChannel < thresholdValue;
pureBlue = redChannel < thresholdValue & greenChannel < thresholdValue & blueChannel >= thresholdValue;
% Display the image.
subplot(2, 2, 3);
imshow(pureRed);
title('Red Mask Image', 'FontSize', fontSize);
% Then replace each pure color with the median from that channel.
redChannel(pureRed) = medianRed(pureRed);
greenChannel(pureGreen ) = medianGreen(pureGreen );
blueChannel (pureBlue ) = medianBlue(pureBlue );
% Construct the new color image
rgbImageFixed = cat(3, redChannel, greenChannel, blueChannel);
% Display the image.
subplot(2, 2, 4);
imshow(rgbImageFixed);
title('Fixed RGB Image', 'FontSize', fontSize);