필터 지우기
필터 지우기

How to use this code?

조회 수: 1 (최근 30일)
Dinyar
Dinyar 2012년 3월 24일
댓글: Ryan liu 2020년 6월 13일
I have obtained some code for image comparison. A function 'correspondPixels' is called during the process but the code in the .m file is all commented out. There is a correspondPixels.cc file but it has too many errors when I try to mex it so I was hoping the correspondPixels.m file would work. I uncommented it and added 'function' at the start as shown below, however, I get an error when this function is called:
??? Undefined function or variable "match1".
Error in ==> correspondPixels at 30 length(find(match1)) + length(find(match2))
Any help would be much appreciated!
-Dinyar
Code:
function [match1,match2,cost,oc] = correspondPixels(bmap1,bmap2,maxDist,outlierCost)
%
% Compute minimum-cost correspondance between two boundary maps.
%
% The cost of corresponding two pixels is equal to their Euclidean
% distance. Two pixels with dist>maxDist cannot be corresponded,
% with cost equal to outlierCost.
%
% INPUTS
% bmap1 MxN matrix, 1=boundary, 0=non-boundary.
% bmap2 MxN matrix.
% [maxDist=0.01] Maximum distance allowed between matched
% pixels, as a fraction of the image diagonal.
% [outlierCost=100]
% Cost of not matching a pixel, as a multiple
% of maxDist.
%
% OUTPUTS
% match1 MxN integer matrix of correspondances for map1.
% match2 MxN integer matrix of correspondances for map2.
% [cost] The cost of the assignment.
% [oc] The outlier cost in units of pixels.
%
% The output match matrices provide indices of the correspondance, as
% given by sub2ind. Indices of zero denote outliers. The following
% expressions may be useful:
%
length(find(bmap1)) + length(find(bmap2))
%The number of pixels to match.
length(find(match1)) + length(find(match2))
%The number of corresponded pixels.
length(find(bmap1&~match1)) + length(find(bmap2&~match2))
%The number of outliers.
[find(match1) match1(find(match1))]
%Kx2 list of the K assignment edges.
sortrows([match2(find(match2)) find(match2)])
%The same Kx2 list of assignment edges.
cost - oc * (length(find(bmap1&~match1)) + length(find(bmap2&~match2)))
% The assignment cost discluding outliers.
%
% See also csaAssign.
%
% David Martin <dmartin@eecs.berkeley.edu>
% January 2003
  댓글 수: 1
Ryan liu
Ryan liu 2020년 6월 13일
Heyyyyy! Do you resolve this problem? I also met this one when do benchmarks in BSDS500 dataset. Could you please give me some help plz? :P

댓글을 달려면 로그인하십시오.

답변 (1개)

Wayne King
Wayne King 2012년 3월 24일
I think we're missing something here because match1 and match2 are supposed to be output arguments of the function you show, but they are used inside of the function before they have any value assigned to them.
length(find(match1)) + length(find(match2))
The above line occurs before match1 and match2 are computed. Because they are not computed inside the function, nor are they input arguments, you get the error you see.
  댓글 수: 1
Dinyar
Dinyar 2012년 3월 24일
Yeah, I see what you mean. To be honest I find the whole block of code perplexing. How can an addition happen when there is no equals sign etc.
I don't really know how mex files work but I had a thought that maybe it was related to why the code initially came completely commented out?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by