Message Boards Message Boards

0
|
4389 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

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
2 Replies

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]]];
ListLinePlot[pdata[[Last@FindShortestTour[pdata]]]]

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];
Graphics[eurLines]

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

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

--SH

POSTED BY: Sander Huisman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract