To Mark Matched Blue Pixels in 2 Images

1 次查看(过去 30 天)
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 个评论
KALYAN ACHARJYA
KALYAN ACHARJYA 2018-8-29
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 2018-8-29
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.

请先登录,再进行评论。

回答(1 个)

Image Analyst
Image Analyst 2018-8-29
编辑:Image Analyst 2018-8-29
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 个评论
Murat Kocaman
Murat Kocaman 2018-9-4
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 2018-9-4
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Particle & Nuclear Physics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by