# Why is imcolordiff not symmetric and what is output range?

5 ビュー (過去 30 日間)
Ryan Fogarty 2022 年 6 月 25 日
コメント済み: Ryan Fogarty 2022 年 6 月 29 日
Hello, I was trying to use the imcolordiff() function to determine color distance between histopathology patches (separated via k-means). I was attempting to use imcolordiff as a distance function to optimize a preprocessing step on whole slide images. But I need to determine the range of the output variable dE (which might be [0,148.471]). But was hoping to know that number exactly. In attempting to determine the range (with values such as [0,0,0] and [0,255,0]), I noticed that imcolordiff is not symmetric. I.e. imcolordiff(c1,c2) != imcolordiff(c2,c1). I tried individual pixels as well as creating small 400x400 patches. Quick code example demonstrating:
i1=[0,0,0];
i2=[255,0,0];
% Shouldn't the following 2 be equal?
imcolordiff(uint8(i1),uint8(i2))
ans = single 117.3272
imcolordiff(uint8(i2),uint8(i1))
ans = single 56.3068
c1=uint8(reshape(ones(400*400,1)*i1(1,:),400,400,3));
c2=uint8(reshape(ones(400*400,1)*i2(1,:),400,400,3));
diff1=imcolordiff(c1,c2);
diff2=imcolordiff(c2,c1);
% Shouldn't the following 2 be equal?
max(diff1(:))
ans = single 117.3272
max(diff2(:))
ans = single 56.3068
TLDR: Why is the distance function imcolordiff not symmetric (or perhaps the correct term is commutative)? Is this a bug? I also discovered the deltaE function does appear to be symmetric. Also what is the range of the output for both of these functions (given R,G,B uint8 input)?
Thank you,
Ryan

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

### 採用された回答

Image Analyst 2022 年 6 月 25 日
No it's not a bug. The color space is not uniform so determining the color difference depends on where the reference color is.
I don't know the possible range but in general a dE of 0 means no color difference, a dE of 1 is just barely noticeable, a dE of 5 is definitely easily noticeable, and delta E's more than 15 or 20 are huge differences, so much so that they're probably a completely different color, like blue vs. yellow, or red vs. green.
Note that the values are not calibrated, which is why I probably won't use them. They depend on your RGB being sRGB I believe, and use theoretical "book" formulas so your values won't match those of your spectrophotometer if you measure your object with a spectrophotometer. A spectrophotometer is considered the best possible, gold standard instrument for measuring color difference. It WILL be right. Not so with a digital image. Let's say you take a picture of a scene - a bowl of oranges say. Now you want to get the CIE LAB color values so you run your image through rgb2lab and get an LAB image. Now let's say you reduce your exposure by half so that all the digital values were half of before. Now your LAB values are half of before. But your scene didn't change at all! So basically you can make your scene have whatever LAB you want be adjusting the exposure and color of lighting. So how can you get the "true" lab values? You have to calibrate by putting in a known standard, like the Calibrite Color Checker chart and make up a transform that transforms actual RGB values into known, calibrated, true LAB values.
##### 4 件のコメント表示非表示 3 件の古いコメント
Ryan Fogarty 2022 年 6 月 29 日
Ok, I see now. Thank you both for the clarification.

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

R2022a

### Community Treasure Hunt

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

Start Hunting!

Translated by