フィルターのクリア

How to put or replace color in rgb/greyscale picture

4 ビュー (過去 30 日間)
Ravin Rayeok
Ravin Rayeok 2020 年 2 月 29 日
コメント済み: Ravin Rayeok 2020 年 2 月 29 日
Hello!
Need some assistance here
Anyone knows how to put the blue color as presented in these pictures below?
Seems like the bubbles blobs (White/grey) has the same rgb value to the other non-bubble area. Black blobs are pores.
  2 件のコメント
Image Analyst
Image Analyst 2020 年 2 月 29 日
Can you explain in words, what properties the blue regions of the gray surround have that the gray regions don't? And why do you want the blue but don't want the gray?
Ravin Rayeok
Ravin Rayeok 2020 年 2 月 29 日
Sorry my question was not clear, may be I can change the picture to simplify.
So how to change color of the picture as following, from white to blue and yellow to green?
Its a picture of different liquid phase in a pore medium.

サインインしてコメントする。

採用された回答

Image Analyst
Image Analyst 2020 年 2 月 29 日
Try this:
rgbImage = imread('image.jpeg');
subplot(2, 1, 1);
imshow(rgbImage);
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
% Get the yellow mask
yellowMask = redChannel > 128 & greenChannel > 128;
% Get the white mask
whiteMask = redChannel > 128 & greenChannel > 128 & blueChannel > 128;
% Make yellow mask green
redChannel(yellowMask) = 0;
greenChannel(yellowMask) = 255;
blueChannel(yellowMask) = 0;
% Make the white mask blue
redChannel(whiteMask) = 0;
greenChannel(whiteMask) = 0;
blueChannel(whiteMask) = 255;
% Recombine separate color channels into a single, true color RGB image.
rgbImage2 = cat(3, redChannel, greenChannel, blueChannel);
subplot(2, 1, 2);
imshow(rgbImage2);
  1 件のコメント
Ravin Rayeok
Ravin Rayeok 2020 年 2 月 29 日
It works! thanks a lot!

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by