Azzera filtri
Azzera filtri

1D projection of image and cross correlation

5 visualizzazioni (ultimi 30 giorni)
Vivek
Vivek il 9 Nov 2022
Risposto: Gokul Nath S J il 26 Mag 2023
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

Risposte (1)

Gokul Nath S J
Gokul Nath S J il 26 Mag 2023
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

Categorie

Scopri di più su Image Processing Toolbox in Help Center e File Exchange

Prodotti


Release

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by