Message Boards Message Boards

Edge detect code gives different outputs


I have often noticed that examples of the past when done in newer versions of Mathematica generate inconsistent results. A prime example related to the following post (Character edge finding):

pic = Thinning@Binarize[GradientFilter[Rasterize[Style["\[Euro]", 
FontFamily -> "Times"], ImageSize -> 200] // Image, 1]]; 
pdata = Position[ImageData[pic], 1];
lcp = ListCurvePathPlot[pdata];

This simple piece of code gives different results in Mathematica 9.0, 10.4 and 11.2 with default options. I have posted the results on StackExchange (click the link to see).

Note: this is not the only example where I have seen differences.

To the WRI quality assurance department: Can you kindly check why similar functions do not behave the same across different versions ?? I think it is more crucial to establish whether the built-in functions are working properly rather than releasing more and more functions without appropriate checks.

POSTED BY: Ali Hashmi
5 months ago

I would guess that Rasterize would be the culprit here… try applying your functions on the same image…


POSTED BY: Sander Huisman
5 months ago

My guess is that the function FindCurvePath and friends never has been very satisfying. This has been reported for earlier versions, and maybe WR is working on it - which might explain the difference in behavior. I would rather use FindShortestTour instead:

pic = Thinning@Binarize[EdgeDetect[Rasterize@Style["\[Euro]", FontFamily -> "Times", 500]]];

Or much better (and without discrepancy to earlier versions! - because there was no ImageMesh ...):

rEur = ColorNegate@Rasterize@Style["\[Euro]", FontFamily -> "Times", 500];
eurLines = MeshPrimitives[ImageMesh[rEur], 1];

In general I think that WR must have the chance of improving things - which will necessarily result in changes of behavior depending on versions.

Regards -- Henrik

POSTED BY: Henrik Schachner
5 months ago

Group Abstract Group Abstract