Filter löschen
Filter löschen

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 !

3 Ansichten (letzte 30 Tage)

Antworten (1)

Image Analyst
Image Analyst am 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 Kommentare
Amir
Amir am 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 am 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];

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by