フィルターのクリア

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 Center および File ExchangeLogical についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by