To Mark Matched Blue Pixels in 2 Images
2 次查看(过去 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
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.
回答(1 个)
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 个评论
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 Center 和 File Exchange 中查找有关 Particle & Nuclear Physics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!