Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Matlab to Opencv equivalent

Hi guys, Would anybody be able to translate the following Matlab code into equivalent Opencv pseudo code. What it should be doing is cleaning up some edges in an image (image is already just edges but needs to be cleaned up). I've added my comments after // on each line as to what I think it's doing but any help advise would be greatly appreciate. I'm porting to c++ and have never used the Matlab code generator so not sure if that could help?

Matlab function

function image=threshold(edges, lower, upper) edges_1=edges > lower; // threshold the input edges image on the lower value - opencv equivalent return Mat > lower

edges_2=edges > upper; // threshold the input edges image on the higher value - opencv equivalent return Mat > upper

seg_1=bwlabel(edges_1); // connected components???? - Opencv equivalent - connected components but not sure????

seg_2=bwlabel(edges_2); // connected components??? - Opencv equivalent - connected components but not sure????

loc=find(edges_2); // ??? No idea on the equivalent

seg=seg_1(loc); // ?? No idea on equivalent

seg=unique(seg); ?? I think this is getting just inique segments from above but not clear- no idea on opencv equivalent

image=ismember(seg_1, seg); // A check to see is the unique segs are part of se1g?? - no idea on opencv equivalent

Matlab to Opencv equivalent

Hi guys, Would anybody be able to translate the following Matlab code into equivalent Opencv pseudo code. What it should be doing is cleaning up some edges in an image (image is already just edges but needs to be cleaned up). I've added my comments after // on each line as to what I think it's doing but any help advise would be greatly appreciate. I'm porting to c++ and have never used the Matlab code generator so not sure if that could help?

Matlab functionfunction:

function image=threshold(edges, lower, upper)
edges_1=edges > lower;  // threshold the input edges image on the lower value - opencv equivalent return Mat > lower

lower edges_2=edges > upper; // threshold the input edges image on the higher value - opencv equivalent return Mat > upper

upper seg_1=bwlabel(edges_1); // connected components???? - Opencv equivalent - connected components but not sure????

sure???? seg_2=bwlabel(edges_2); // connected components??? - Opencv equivalent - connected components but not sure????

sure???? loc=find(edges_2); // ??? No idea on the equivalent

equivalent seg=seg_1(loc); // ?? No idea on equivalent

equivalent seg=unique(seg); ?? I think this is getting just inique segments from above but not clear- no idea on opencv equivalent

equivalent image=ismember(seg_1, seg); // A check to see is the unique segs are part of se1g?? - no idea on opencv equivalent

equivalent