1D projection of image and cross correlation

조회 수: 7 (최근 30일)
Vivek
Vivek 2022년 11월 9일
답변: Gokul Nath S J 2023년 5월 26일
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에서 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