How do I make MATLAB to recognize the deltaE function?

I have two images A and B. When running the code that I am using to find colour differences between two images, it keeps telling me: "Unrecognized function or variable 'deltaE'. I tried to read about how to make this function recognized and I believe I have to convert the RGB images into lab values. Yet I keep failing to understand how to do so.

Answers (3)

https://www.mathworks.com/help/images/ref/deltae.html
needs R2020b
You can use sqrt() of the lab colors. There is also an rgb2lab() function that is pretty old.
de = sqrt((L1-L2).^2 + (A1-A2).^2 + (B1-B2).^2)
See attached demos.

9 Comments

Thank you for your response. I am really a beginner with programming and computers. Are L A and B here the lab channels? But I haven't yet been able to transform it to lab colours since I seem to fail to do so. Do I copy and paste those demos into my code? I have little clue to know what to do with all of this.
Yes, they are. Why didn't you use rgb2lab() like I instructed? Try this:
rgbImage1 = imread(filename1);
rgbImage2 = imread(filename1);
lab1 = rgb2lab(rgbImage1);
lab2 = rgb2lab(rgbImage2);
[L1, A1, B1] = imsplit(lab1);
[L2, A2, B2] = imsplit(lab2);
de = sqrt((L1-L2).^2 + (A1-A2).^2 + (B1-B2).^2); % An image
imshow(de, []);
The demos are standalone demos that illustrate various ways to use Delta E color difference. You may modify them as you wish, and incorporate them into your own code if you wish.
It is not working with my code. I must have done something wrong adding it to my code. I am really ignorant with all this stuff. I do see that you answer a lot of question on these forums, I have learned a lot from some answers so wanted to thank you for that anyway aswell! But I don't want to take too much time from someone when I have little clue what I need to do when someone answers my questions.
Why didn't it work? If you don't have imsplit(), you can do it like you did. Otherwise post your code as you have it now, along with your two images.
My knowledge on all of this is to little to communicate to why it didn't work. This is the code I use. This code was made by someone who answered a previous question of mine in which the images are shown in my questions which I used: https://www.mathworks.com/matlabcentral/answers/644365-how-to-transform-a-rgb-matrix-to-a-weighted-adjacency-matrix?s_tid=prof_contriblnk
This is the code that I am using:
A = imread('A.png');
mask = all(A == reshape([255 255 255],1,1,3),3);
mask2 = imerode(mask,ones(3,3));
T = regionprops("table",mask2,"Centroid");
head(T)
m = round(T.Centroid(:,2));
n = round(T.Centroid(:,1));
B = imread('B.png');
B = B(1,:,:);
B = reshape(B,[],3);
for q = 1:length(m)
for r = 1:length(n)
if q ~= r
c = A(m(q),n(r),:);
c = reshape(c,1,3);
c = repmat(c,size(B,1),1);
D = deltaE(c,B);
[D_min,idx] = min(D);
Aw(q,r) = interp1([1 size(B,1)],[0 5],idx);
end
end
end
Can you attach your A and B images if you want me to try that code?
I unfortunately cannot attach the images here due to some reasons, it is a long story. The images A and B are in this link https://www.mathworks.com/matlabcentral/answers/644365-how-to-transform-a-rgb-matrix-to-a-weighted-adjacency-matrix?s_tid=prof_contriblnk
But all in all I would like to also understand how it all works. Are there any books are website where I can learn image analysis programming more in depth? If you have any tips I would higly appreciate it!
I think the best book is "The Image Processing Handbook" by John Russ.
Another free online book is by RIchard Szeliski:

Sign in to comment.

deltaE() function is available in Image processing toolbox. This error message indicates that, most likely, you don't have that toolbox installed. You can run the following line in the command window
ver images
and if you get a warning, it means that you don't have the toolbox installed.

7 Comments

I typed in the command ver images and I did not get a warning. It tells me "Image Processing Toolbox Version 11.1 (R2020a)".
Can you paste the complete error message?
Unrecognized function or variable 'deltaE'.
Error in weighted_matrices (line 25)
D = deltaE(c,B);
Can you show the output of
which deltaE
I'll post the code here. I am using a code that someone else on my other forum post answered for me. I changed the names of the images to A and B for simplicity.
A = imread('A.png');
mask = all(A == reshape([255 255 255],1,1,3),3);
mask2 = imerode(mask,ones(3,3));
T = regionprops("table",mask2,"Centroid");
head(T)
m = round(T.Centroid(:,2));
n = round(T.Centroid(:,1));
B = imread('B.png');
B = B(1,:,:);
B = reshape(B,[],3);
for q = 1:length(m)
for r = 1:length(n)
if q ~= r
c = A(m(q),n(r),:);
c = reshape(c,1,3);
c = repmat(c,size(B,1),1);
D = deltaE(c,B);
[D_min,idx] = min(D);
Aw(q,r) = interp1([1 size(B,1)],[0 5],idx);
end
end
end
Can you attach the image A.png?
They are in this previous post of mine https://www.mathworks.com/matlabcentral/answers/644365-how-to-transform-a-rgb-matrix-to-a-weighted-adjacency-matrix?s_tid=prof_contriblnk

Sign in to comment.

Asked:

on 15 Nov 2020

Commented:

on 16 Nov 2020

Community Treasure Hunt

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

Start Hunting!