Image processing help. Regarding pixel values and not needing to click on diagram to select pixel.
1 次查看(过去 30 天)
显示 更早的评论
From what I understand, matlab mostly requires us to click on an image and then it will display the resulting pixel RGB value. Is there a way to let the code run through, finding ALL pixel's individual values without having to click? I do not want to select because I want to iterate through the whole picture.
How do I use code to get just R,G and B respectively of a pixel? Like when a pixel is selected, what code will give only R portion of RGB. I wish to compile RGB together meaning adding R, G and B to get my resulting pixel value.
Please help. Thanks.
0 个评论
采纳的回答
Image Analyst
2014-12-26
You can read in an image file with imread(). That will get you ALL the image pixel values without having to click on anything.
rgbImage = imread(fullFileName);
To split apart an RGB image into the individual color channels, you can do this:
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
To recombine them into an RGB image again, do this:
% Recombine separate color channels into a single, true color RGB image.
rgbImage = cat(3, redChannel, greenChannel, blueChannel);
7 个评论
Image Analyst
2014-12-28
编辑:Image Analyst
2014-12-28
They must be uint8. What does this reveal if you put it right before the second disp():
whos I
whos RED
whos GREEN
whos BLUE
whos total_value
whos array
Try casting to uint16 before summing.
total_Value = uint16(RED) + uint16(GREEN) + uint16(BLUE);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!