Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addition of Breadley AdaptiveThreshold #725

Merged
merged 30 commits into from
Apr 3, 2020

Conversation

SimantoR
Copy link
Contributor

@SimantoR SimantoR commented Oct 5, 2018

Adaptive Threshold

Description

Added Bradley Adaptive Threshold, tweaked from the original published paper by Derek Bradley of Carleton University and Gerhard Roth of National Research Council of Canada. It has been tested on the sample document used in the paper.

TODO

  • Add optimization techniques
  • Add unit test
  • Test on different variety of document images

/// </summary>
public TPixel Lower { get; set; }

public unsafe void Apply(Image<TPixel> source, Rectangle sourceRectangle)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why unsafe?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh! forgot to remove that, was doing some experimenting but since there are 2DArray pool I didn't implement it. Will remove it asap.

# Inherited from ImageProcessor
# Minor changes to variables
# Minor Tweaks
@codecov
Copy link

codecov bot commented Oct 5, 2018

Codecov Report

Merging #725 into master will increase coverage by 0.05%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #725      +/-   ##
==========================================
+ Coverage   82.32%   82.37%   +0.05%     
==========================================
  Files         681      684       +3     
  Lines       29438    29522      +84     
  Branches     3325     3330       +5     
==========================================
+ Hits        24234    24318      +84     
  Misses       4515     4515              
  Partials      689      689              
Flag Coverage Δ
#unittests 82.37% <100.00%> (+0.05%) ⬆️
Impacted Files Coverage Δ
...ageSharp/Processing/AdaptiveThresholdExtensions.cs 100.00% <100.00%> (ø)
...cessors/Binarization/AdaptiveThresholdProcessor.cs 100.00% <100.00%> (ø)
...Binarization/AdaptiveThresholdProcessor{TPixel}.cs 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fedf5b7...ee016f6. Read the comment docs.

@SimantoR
Copy link
Contributor Author

One question does arise from the attempt to implement Parallelism into this algorithm:
Since there are 2 identical loops that needs to be performed in series, should they be individually implement into their own Parallel loops? It seems like the logical thing to do

@SimantoR SimantoR closed this Oct 13, 2018
@SimantoR SimantoR reopened this Oct 13, 2018
@JimBobSquarePants
Copy link
Member

Haven't forgotten about this. Will get it merged eventually!

Copy link
Member

@JimBobSquarePants JimBobSquarePants left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of questions on stuff I don't understand.

@JimBobSquarePants
Copy link
Member

@SimantoR This is next on my todo list for review and will helping you finish it off.

@JimBobSquarePants JimBobSquarePants added this to the 1.0.0 milestone Jan 24, 2019
@zmmille2
Copy link

Any update on this? Would really like to use it in a project I've got going on.

@SimantoR
Copy link
Contributor Author

SimantoR commented Jun 1, 2019

Any update on this? Would really like to use it in a project I've got going on.

@zmmille2
Hi there. It's Eid time and I've been looking forward to getting this packaged and ready for ImageSharp. Feel free to add anything to the fork for this PR here. It currently is greatly outdated and no unit test has been implemented for this. I'm going to update the repo to be concurrent with the current version but I do need help with the unit tests.

@brianpopow
Copy link
Collaborator

If the only thing left here are unit tests, i can do that. Will take test images from the original paper. For example:

input

output

works great.

@brianpopow brianpopow self-assigned this Apr 2, 2020
@JimBobSquarePants
Copy link
Member

Yeah @brianpopow that would be great!

TPixel pixel = pixelRow[x];
pixel.ToRgba32(ref rgb);

var x1 = (ushort)Math.Max(x - this.startX - this.clusterSize + 1, 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This cast limits our range. If x or y are greater than ushort.MaxValue we end up with the wrong offset.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

somehow i managed to miss that

Copy link
Member

@JimBobSquarePants JimBobSquarePants left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thanks for finishing this off 👍

@JimBobSquarePants JimBobSquarePants merged commit 557b1c5 into SixLabors:master Apr 3, 2020
@SimantoR
Copy link
Contributor Author

SimantoR commented Apr 6, 2020

That's great to see. I just saw the activity on this PR. I'm so glad this got finished!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants