MATLAB Answers

How to extract RGB information from an segmented image excluded white background.

조회 수: 5(최근 30일)
Leow Bin
Leow Bin 22 Jul 2017
댓글: Image Analyst 22 Jul 2017
Hi, I am working on project about image processing. I would like to know about how to extract the RGB information from an segmented image excluded the white background. I only need the RGB value for my region of interest, and I don't want the white pixels RGB value to exist in my data file. Thank you.

  댓글 수: 0

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

채택된 답변

Image Analyst
Image Analyst 22 Jul 2017
Get a mask of where white is, then extract pixels from where it's not white
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
whiteMask = redChannel == 255 & greenChannel == 255 & blueChannel == 255;
redValues = redChannel(~whiteMask);
greenValues = greenChannel(~whiteMask);
blueValues = blueChannel(~whiteMask);

  댓글 수: 2

Leow Bin
Leow Bin 22 Jul 2017
Thanks for your kindly help~that's the exactly what I needed.
Image Analyst
Image Analyst 22 Jul 2017
Note, if white is just bright areas, then you don't have to use just pure 255, it can be any values above some intensity that you consider "white", so for example you can do:
whiteMask = redChannel >= 200 & greenChannel >= 225 & blueChannel >= 230;

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

추가 답변(1개)

KALYAN ACHARJYA
KALYAN ACHARJYA 22 Jul 2017
편집: KALYAN ACHARJYA 22 Jul 2017
You can directly calculate the R G B from the image, Apply If R=255, G=255, B=255, then ignore the region else ...do your program. Similar Image is needed for more clarification.
Please note: I am beginner in Matlab

  댓글 수: 1

Leow Bin
Leow Bin 22 Jul 2017
Hi, I am understand about the concept just I don't know how to implement in matlab syntax. Thank you anyway.

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

Community Treasure Hunt

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

Start Hunting!

Translated by