Best way to calculate color difference score
50 次查看(过去 30 天)
显示 更早的评论
Let's say I have an nxn block of pixels with RGB values and another nxn blocks of pixels with RGB values. If I want to compare color similarity of the block what should I do? Currently, I convert to the L*a*b colorspace and compute the deltaE between each pixel in the block element-wise. After that, I sum up all the differences to find a "score" for the entire block. What could be improved?
回答(2 个)
Image Analyst
2024-1-15
That's basically correct. What could possibly be improved is the image capture part, but you don't say anything about that. Are the images captured by a digital camera? If so you'll need to do a color calibration first. Otherwise you may find there are color differences when there actually are no color differences in your sample and it's just due to the lighting changes or exposure differences between the two snapshots. See attached seminar. Using a target, like the Calibrite Color Checker Chart, you take a picture of it. It has known LAB values. You then use a least squares regression to develop a transform to turn measured RGB values into calibrated LAB values. This is the best way, rather than just blindly using rgb2lab. You can then use this transform to calibrate any image taken with the same parameters as the image of the color checker chart you used to develop the transform with.
You might also need to do a background correction. All lenses have shading, meaning that the center of the image is brighter than the edges. This needs to be corrected for (usually by taking a "blank shot" of a uniform scene with uniform lighting) or else you'll get different colors for your sample depending on where in the scene the region of interest is located. The background correction should be done before the color calibration.
0 个评论
Sulaymon Eshkabilov
2024-1-15
Here are a few points to consider:
Your approach of converting the RGB values to the LAB colorspace and computing the deltaE between each pixel in each block of n-by-n is a good starting point for comparing color similarity. But there are a few more improvements to consider:
- Weighted Differences: Instead of simply summing up all the differences, you can assign different weights to each pixel based on their importance or perceptual significance. E.g., you can give more weight to pixels in the center of the block or pixels with higher saturation values.
- Color Histograms: Instead of comparing individual pixel values, you can compute color histograms for each block and compare the histograms. This approach captures the distribution of colors in the block and can provide a more robust measure of color similarity.
- Structural Similarity Index (SSIM): The SSIM metric takes into account both the luminance and structural information of the images. It compares local patterns of pixel intensities and can be used to measure the similarity between blocks of pixels.
All the best.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!