1D projection of image and cross correlation

11 次查看(过去 30 天)
I would like to project a image in 1D and take a flipped version of it and take the cross correlation . how can I plot the 1D profille and the flipped image overlayed and the crosscorelation in matlab

回答(1 个)

Gokul Nath S J
Gokul Nath S J 2023-5-26
Hi Vivek,
To plot the 1D profile and the flipped image overlaid with the cross-correlation plot in MATLAB, you can use the plot function to plot the 1D profile and flipped image, and the xcorr function to compute the cross-correlation. Here's an example code that shows how to do this:
% Load the image to be flipped and cross-correlated
img = imread('sample_image.png');
% Convert the image to grayscale and resize to a 1D vector
img_gray = rgb2gray(img);
img_vector = double(img_gray(:));
% Flip the image vector
img_flipped = flip(img_vector);
% Compute the cross-correlation between the original and flipped images
[r,lags] = xcorr(img_vector, img_flipped);
% Plot the 1D profile and flipped image overlaid
figure;
plot(1:length(img_vector), img_vector, 'b');
hold on;
plot(1:length(img_flipped), img_flipped, 'r');
legend('Original Image', 'Flipped Image');
xlabel('Pixel Position');
ylabel('Intensity');
title('Original and Flipped Images');
% Plot the cross-correlation
figure;
plot(lags, r);
xlabel('Lag');
ylabel('Cross-Correlation Coefficient');
title('Cross-Correlation between Original and Flipped Images');
with regards,
Gokul Nath S J

类别

Help CenterFile Exchange 中查找有关 Get Started with Image Processing Toolbox 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by