Compare two images( Gold standard black vs regular black) using RGB?
1 view (last 30 days)
I have two images. I am comparing one to a gold standard pure black image from edmunds. I'm not sure how I would go about comparing them. I think I want a sort of correction factor that can say how dark a specific pigment is in relation to another.
Here is the code for 12 images that we at the lab are using now.
str = 'C:\Users\Jake\Desktop\MATLAB IMAGES\IMAGES\Edmund-polymer comparison_ABR\'; % Purpose???
imagefiles = dir('C:\Users\Jake\Desktop\MATLAB IMAGES\IMAGES\Edmund-polymer comparison_ABR\*.jpg'); % accesses folder
nfiles = length(imagefiles); % Number of files found
for i = 1:nfiles
currentfilename = [str imagefiles(i).name]; % sets file name with string
currentimage = imread(currentfilename); % reads image
subplot(2,nfiles,i); % plots image with (?) and (?)
imshow(currentfilename); % shows image
subplot(2,nfiles,i+12); % plots below (?) and (i +12?)
imshow(currentimage(:,:,3)); %shows the image at the plot location
% YOLO TOTALLY WORKED AND I JUST WINGED IT, TIME TO CELEBRATE
% 1 next step needs each pic to have name
% 2 ENLARGE
% 3 How to compare mathematically?? (correction factor that patil
% discussed for noise??)
% 4 format axes? somehow
%Split into RGB Channels
Red = currentimage(:,:,1);
Green = currentimage(:,:,2);
Blue = currentimage(:,:,3);
%Get histValues for each channel
[yRed, x] = imhist(Red);
[yGreen, x] = imhist(Green);
[yBlue, x] = imhist(Blue);
%Plot them together in one plot
plot(x, yRed, 'Red', x, yGreen, 'Green', x, yBlue, 'Blue');
title_text = imagefiles(i).name;
title(title_text, 'Fontsize', 6, 'Position', [120,2.7*10^6]);
xlabel('Color'); % how to autoformat
ylabel('# of Pixels'); % how to autoformat
Prasad Mendu on 7 Jul 2016
The MATLAB function "immse" compares two images using the color values (RGB) to calculate the Mean Squared Error (MSE) of two images.
For example it is executed as:
err = immse(X,Y)
Refer to the link below for more information on this: