Skip to content
This repository has been archived by the owner on Nov 19, 2020. It is now read-only.

Fix ZhangSuenSkeletonization error #1268

Closed
wants to merge 5 commits into from

Conversation

IsBrad
Copy link

@IsBrad IsBrad commented Mar 14, 2018

Fix for bug https://github.com/accord-net/framework/issues/1267

From report:

The ZhangSuenSkeletonization class will cause a StackOverflowException when running on large(ish) images
This is due to a byte array almost the size of the input image being allocated on the stack.
.NET applications have a default stack size limit of 1mb for 32bit applications and 4mb for 64 bit.
This results in 1026x1026 & 2050x2050 almost exceeding the maximum stack size

The fix is to change this: (line 153)

var del0 = stackalloc byte[delSize]; for (var i = 0; i < delSize; i++) del0[i] = 0xFF;

To this:

var del0 = (byte*)Marshal.AllocHGlobal(delSize).ToPointer();

From testing this does not incur any measurable time penalty

@CLAassistant
Copy link

CLAassistant commented Mar 14, 2018

CLA assistant check
All committers have signed the CLA.

@IsBrad IsBrad closed this Mar 14, 2018
@IsBrad IsBrad reopened this Mar 14, 2018
@fdncred
Copy link
Collaborator

fdncred commented May 3, 2019

Fixed with a previous merge.

@fdncred fdncred closed this May 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants