Comparing multiple images ( via edge detection or strongest gradient between dark and light)
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello guys,
first of all : i am very new to matlab so dont blame me for asking.
I want to compare some pictures ( 5 pictures or so ).I am testing a light,every hour i take a photo and then compare them to see if the'cut-off' did move. And if the 'cut off' moves, I'd like to see how much it shifted.
Every little adive would help me !
( I uploadet the picutre. In my test, the pictures will loke the same. But maybe afters 3 hours the 'cut-off will shift minimal. And thats what i wanna se. Like if i could get a number in the end like 2 == It shifted 2 millimeters.)
THX GUYS !
2 commentaires
Rik
le 7 Juil 2020
Question recovered from Google cache:
Comparing multiple images ( via edge detection or strongest gradient between dark and light)
Hello guys,
first of all : i am very new to matlab so dont blame me for asking.
I want to compare some pictures ( 5 pictures or so ).I am testing a light,every hour i take a photo and then compare them to see if the'cut-off' did move. And if the 'cut off' moves, I'd like to see how much it shifted.
Every little adive would help me !
( I uploadet the picutre. In my test, the pictures will loke the same. But maybe afters 3 hours the 'cut-off will shift minimal. And thats what i wanna se. Like if i could get a number in the end like 2 == It shifted 2 millimeters.)
THX GUYS !
Réponses (2)
Image Analyst
le 7 Mai 2020
I don't know what the "cut-off" is. Is it the shadow line? Do you want the row number of the shadow for every column in the image? Something like
grayImage = imread(filename);
[rows, columns, numberOfColorChannels] = size(grayImage)
if numberOfColorChannels == 3
grayImage = rgb2gray(grayImage);
end
binaryImage = grayImage < someValue; % For example someValue = 100 or whatever.
shadowRows = zeros(1, columns);
for col = 1 : columns
t = find(binaryImage(:, col), 1, 'first')
if ~isempty(t)
shadowRows(col) = t;
end
end
plot(shadowRows, 'b-')
grid on;
0 commentaires
Image Analyst
le 11 Mai 2020
Try this:
clc; % Clear the command window.
fprintf('Beginning to run %s.m.\n', mfilename);
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
baseFileName1 = 'hdg.png';
fullFileName1 = fullfile(pwd, baseFileName1);
grayImage1 = imread(fullFileName1);
[rows, columns, numberOfColorChannels] = size(grayImage1)
if numberOfColorChannels == 3
grayImage1 = rgb2gray(grayImage1);
end
% Display image.
subplot(2, 3, 1);
imshow(grayImage1, []);
impixelinfo
title(baseFileName1, 'FontSize', fontSize);
% Threshold the image.
thresholdValue = 125;
binaryImage = grayImage1 < thresholdValue;
% Take largest blob.
binaryImage = bwareafilt(binaryImage, 1);
% Do a morphological opening to get rid of grid lines.
binaryImage = imopen(binaryImage, true(3));
% Display image.
subplot(2, 3, 4);
imshow(binaryImage, []);
impixelinfo
title(baseFileName1, 'FontSize', fontSize);
shadowRows1 = zeros(1, columns);
for col = 1 : columns
t = find(binaryImage(:, col), 1, 'last')
if ~isempty(t)
shadowRows1(col) = t;
end
end
baseFileName2 = 'hdg1.png';
fullFileName2 = fullfile(pwd, baseFileName2);
grayImage2 = imread(fullFileName2);
[rows, columns, numberOfColorChannels] = size(grayImage2)
if numberOfColorChannels == 3
grayImage2 = rgb2gray(grayImage2);
end
% Display image.
subplot(2, 3, 2);
imshow(grayImage2, []);
impixelinfo
title(baseFileName2, 'FontSize', fontSize);
% Threshold the image.
binaryImage = grayImage2 < thresholdValue;
% Take largest blob.
binaryImage = bwareafilt(binaryImage, 1);
% Do a morphological opening to get rid of grid lines.
binaryImage = imopen(binaryImage, true(3));
% Display image.
subplot(2, 3, 5);
imshow(binaryImage, []);
impixelinfo
title(baseFileName2, 'FontSize', fontSize);
shadowRows2 = zeros(1, columns);
for col = 1 : columns
t = find(binaryImage(:, col), 1, 'last');
if ~isempty(t)
shadowRows2(col) = t;
end
end
subplot(2, 3, 3);
plot(shadowRows1, 'b-')
hold on;
plot(shadowRows2, 'r-')
grid on;
xlabel('Row', 'FontSize', fontSize);
ylabel('Column', 'FontSize', fontSize);
title('Shadow Location', 'FontSize', fontSize);
legend('image 1', 'image 2', 'Location', 'northwest');
% The images are not the same size for some strange reason so we can't subtract the arrays until we match their sizes
if length(shadowRows1) > length(shadowRows2)
shadowRows2(length(shadowRows1)) = shadowRows2(end); % Extend last value out.
else
shadowRows1(length(shadowRows2)) = shadowRows1(end); % Extend last value out.
end
% Plot the difference.
diffRows = shadowRows1 - shadowRows2;
subplot(2, 3, 6);
plot(diffRows, 'b-')
grid on;
xlabel('Row', 'FontSize', fontSize);
ylabel('Vertical Difference', 'FontSize', fontSize);
title('Difference in Shadow Locations', 'FontSize', fontSize);
% Maximize figure.
g = gcf;
g.WindowState = 'maximized'
5 commentaires
Voir également
Catégories
En savoir plus sur Image Data Workflows dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!