How can I take the rgb value of an image and color correct to an original rgb value?

9 ビュー (過去 30 日間)
I am needing to write a code that takes the rgb value of a reference square in an image, and color correct it to the orginal rgb value of the reference square.
I will have various images with this reference square that will change colors depending on how the sunlight hits it, so I need to correct the whole image back to the original color. Is there a code that can be written to do this? Additionally, I mainly am focused on the blue values, but how will the change in values be stored?
Thanks

採用された回答

Image Analyst
Image Analyst 2023 年 6 月 6 日
You forgot to attach your reference image and the image that needs correction.
Basically you need to segment the image to find the square in both images, then assign the reference image colors to the test image. Assuming you've done the segmentation and have the square masks, you then do this.
% Split test and reference image into component color channels.
[rTest, gTest, bTest] = imsplit(testImage);
[rRef, gRef, bRef] = imsplit(refImage);
% Assign mean color from ref image to test image, but only in the square region.
rTest(testSquaremask) = mean(rRef(refSquareMask));
gTest(testSquaremask) = mean(gRef(refSquareMask));
bTest(testSquaremask) = mean(bRef(refSquareMask));
% Rebuild test image from component color channels.
testImage = cat(3, rtest, gTest, bTest);
The pixels in square region of the test image will be the same (uniform) color for all pixels in the square.
Or you can simply copy and paste like in the attached demo.
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeModify Image Colors についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by