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 (최근 30일)

답변 (1개)

Image Analyst
Image Analyst 2015년 2월 27일
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
Amir
Amir 2015년 2월 27일
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 2015년 2월 27일
What is the Euclidean distance method? Describe it. To set a single pixel, just set it
rgbImage(row, column, :) = [r,g,b];

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by