How to remove additional padding

조회 수: 29 (최근 30일)
Aina Diyana
Aina Diyana 2020년 10월 24일
답변: drummer 2020년 10월 24일
I had made a correlation between two surface image and the result seem to have additional padding. May someone help me to get the original size back.
%read image
A = imread('SURFACE A.png');
B = imread('SURFACE _B.png');
% cross correlation
c = normxcorr2(A(:,:,1),B(:,:,1));

답변 (1개)

drummer
drummer 2020년 10월 24일
Hi, didn't go through with your images nor the output of normxcorr2, but perhaps this example could help you with a workaround.
clc
A = zeros(4, 4);
for i = 2 : (size(A, 1) - 1)
for j = 2 : (size(A, 1) - 1)
A(i, j) = rand;
end
end
A % it mimics your output c, with the padding.
A(A == 0) = []; % if the padding of your output c is zero, that would work.
A = reshape(A, [], 2)
Cheers

카테고리

Help CenterFile Exchange에서 Geometric Transformation and Image Registration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by