How would we use Euclidean Distance Method to assign colours to specific pixels of an image ? For eg. i want to add rainbow in the given image !

1 view (last 30 days)

Answers (1)

Image Analyst
Image Analyst on 27 Feb 2015
First get an image of a rainbow. Then get a binary mask of where it is in the image. Then separate your two images into color channels.
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
Do the above for each color image. Then do
redChannel(binaryMask) = rainbowRed(binaryMask);
greenChannel(binaryMask) = rainbowGreen(binaryMask);
blueChannel(binaryMask) = rainbowBlue(binaryMask);
rgbout = cat(3, redChannel, greenChannel, blueChannel);
By the way a rainbow in that image would look totally unrealistic. Do you know when you get rainbows? Actually that was my very first homework problem in optics graduate school. We had to find the angle of a rainbow. It's 42 degrees. You need the sun at your back and rain or mist in front of you.
  2 Comments
Amir
Amir on 27 Feb 2015
Sorry, this is not required , i need to access the pixels using Euclidean distance method specifically and then have to assign colours to them .
Image Analyst
Image Analyst on 27 Feb 2015
What is the Euclidean distance method? Describe it. To set a single pixel, just set it
rgbImage(row, column, :) = [r,g,b];

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!