To Mark Matched Blue Pixels in 2 Images

2 views (last 30 days)
Murat Kocaman
Murat Kocaman on 29 Aug 2018
Commented: Image Analyst on 4 Sep 2018
Hello,
I would like to mark matched blue pixels in 2 images.
The images are attached. Here, what I want to have is to mark matched points which are blue. (I am not sure if the blue is the correct approach because the colors are not the same)
As a result , I would like to see it as below with the red marks on the matched pixels;
I need to use rgb2hsv convertion but it didn't work.
My current code is:
startingFolder = 'C:\Users\Development\Desktop\dneme';
if ~exist(startingFolder, 'dir')
% If that folder doesn't exist, just start in the current folder.
startingFolder = pwd;
end
defaultFileName = fullfile(startingFolder, '*.jpg');
[baseFileName, folder] = uigetfile(defaultFileName, 'Select a file');
if baseFileName == 0
% User clicked the Cancel button.
return;
end
fullFileName = fullfile(folder, baseFileName)
original = imread(fullFileName);
startingFolder = 'C:\Users\Development\Desktop\dneme';
if ~exist(startingFolder, 'dir')
% If that folder doesn't exist, just start in the current folder.
startingFolder = pwd;
end
defaultFileName = fullfile(startingFolder, '*.jpg');
[baseFileName, folder] = uigetfile(defaultFileName, 'Select a file');
if baseFileName == 0
% User clicked the Cancel button.
return;
end
fullFileName2 = fullfile(folder, baseFileName)
original = imread(fullFileName2);
i1 = imread(fullFileName);
i2 = imread(fullFileName2);
i3 = xor(i1, i2);
imagesc(i3);
d = sum(i3(:)) / numel(i3);
This code seems right way but red points are not at the true positions and i prefer having the result on the input images not black background.
Does anyone have an idea on the subject?
  2 Comments
KALYAN ACHARJYA
KALYAN ACHARJYA on 29 Aug 2018
Can you clarify the question again? What is the input, what result are you expecting? Don't provide the confusing data and terms.
Murat Kocaman
Murat Kocaman on 29 Aug 2018
Yes inputs are the first 2 images:
First image:
Second image:
Result expecting:
I would like to mark matched blue pixels at these 2 input images with red marker.
I hope it is clear now.

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 29 Aug 2018
Edited: Image Analyst on 29 Aug 2018
I'm not sure what you mean by "matched". Like you said, the colors are different. So I guess you'll have to define how close can they be and still be considered "matched". To do that you need to compute the Delta E color difference. For that, use my Delta E program here: https://www.mathworks.com/matlabcentral/fileexchange/31118-color-segmentation-by-delta-e-color-difference
You could also do a pixel-by-pixel delta E. Simply use rgb2lab() on each image, then compute the square root of the sum of the squares of the L, A, and B channels. Then threshold at some value to discriminate between "matched" and "not a close match".
  8 Comments
Murat Kocaman
Murat Kocaman on 4 Sep 2018
Yes I added a mask definition to what you had adviced. I have already tried some other mask definitions but the result was the same.
So should I change that line and find appropriate masking or what?
Image Analyst
Image Analyst on 4 Sep 2018
I suggest you go back to my demo and look at creating a mask from thresholding the delta E image. If you insist on doing the segmentation in RGB color space, then threshold one of the color channels.

Sign in to comment.

Categories

Find more on Particle & Nuclear Physics in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!