-
Notifications
You must be signed in to change notification settings - Fork 210
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
Threshold module, not working yet #123
Conversation
Ooh, yikes. This is all messed up; i was pretty sure i was working from master but it looks like i was working from gh-pages... i'll fix this. |
4e86708
to
3e608e2
Compare
There, rebased and cleaned it up. |
@@ -25,7 +31,13 @@ module.exports = function ImageThreshold(options) { | |||
}).then(function (imageData) { | |||
image = new Image(); | |||
image.onload = function onLoad() { | |||
if (options.output) options.output(image); | |||
this.output = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this
is being used in the wrong context; The output needs to be set for the "step" object. Like this:
function draw (inputImage) {
var step = this;
...
...
...
image = new Image();
image.onload = function onLoad() {
step.output = {
format: input.type,
src: image.src
}
options.step.output = step.output.src;
callback();
UI.onComplete(options.step);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, let's refactor existing modules to save this
into var step
to avoid this ambiguity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, i see that existing modules are already this way! Great, it must just be that the Threshold module wasn't.
canvas.width = inputImage.naturalWidth; | ||
canvas.height = inputImage.naturalHeight; | ||
canvas.width = image.naturalWidth; | ||
canvas.height = image.naturalHeight; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will work only on browsers, right? I think it's pretty easy to write a threshold module - we could as well do it without using the native Image and Canvas classes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be done without the native Image and Canvas classes to ensure Node.js support.
The issue was that the output of the step was not being set as a property of "step"; A problem of scope. I think this brings more focus on #122. It sure is really confusing to create a module. I shall look into it.
OK -- i mean, we can achieve this using PixelManipulation, for example. Shall I refactor for that? Also - we should have a section in Contributing Modules that talks about Node/Browser compatibility with this in mind, so it's more clear to people, and we can also link to that section when people submit modules like this. We can have some possible solutions in that section too. Adding this suggestion to #122. |
Yes I think that's an awesome idea!! It'll make contributing clearer; yes,
pixel manipulation can do that :-)
…On Tue, Sep 26, 2017, 04:21 Jeffrey Warren ***@***.***> wrote:
OK -- i mean, we can achieve this using PixelManipulation, for example.
Shall I refactor for that?
Also - we should have a section in Contributing Modules that talks about
Node/Browser compatibility with this in mind, so it's more clear to people,
and we can also link to that section when people submit modules like this.
We can have some possible solutions in that section too. Adding this
suggestion to #122
<#122>.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#123 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AT0xnMj2tvQFJsuSmYO5DVls--zjX9mvks5smC6EgaJpZM4PhoQ0>
.
|
Will it be okay for me to do this? |
Sure, yes please!
…On Oct 13, 2017 6:25 AM, "Chinmay Pandhare" ***@***.***> wrote:
Will it be okay for me to do this?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#123 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AABfJ1gm2a2aTbp9sFwpDaUwhDIrlUD9ks5srzqZgaJpZM4PhoQ0>
.
|
IntroductionHave been doing some research on this and I came across the following :
I wanted to have a look at the algorithm so as to make a node-and-browser compatible version. I think there is much more to thresholding than we had currently implemented. There's Full RGB Quantization, Plane-by-plane RGB Quantization, etc. NotesSingle Channel ThresholdingWhen there is only one channel, per pixel the channel value is made into max or min based on whether it is above a certain threshold value. Multiple Channel (Color Input, Color Output) ThresholdingWhen there are multiple channels,
Multiple Channels (Color Input, Black/White Output) Thresholding
Method 1 above segments the image as per how the camera stores it, but not how a human would view it. Method 2 is how a human brain would analyze the image. Further StepsSo what do you think we should do, @jywarren ? All of these, some of these? |
Let's start with just one, perhaps the easiest one, and we can leave these
great docs for the next person who wants to take the next step. Sound good?
…On Oct 18, 2017 1:32 AM, "Chinmay Pandhare" ***@***.***> wrote:
Introduction
Have been doing some research on this and I came across the following :
- https://in.mathworks.com/help/images/ref/multithresh.html
- http://ieeexplore.ieee.org/document/5445591/
- https://en.wikipedia.org/wiki/Thresholding_(image_processing)
I wanted to have a look at the algorithm so as to make a node-and-browser
compatible version.
I think there is much more to thresholding than we had currently
implemented.
There's Full RGB Quantization, Plane-by-plane RGB Quantization, etc.
Notes Single Channel Thresholding
When there is only one channel, per pixel the channel value is made into
max or min based on whether it is above a certain threshold value.
Multiple Channel (Color Input, Color Output) Thresholding
When there are multiple channels,
- The above can be done per channel. (Plane by Plane RGB Quantization)
- OTSU's Method can be used. (Full RGB Quantization)
Multiple Channels (Color Input, Black/White Output) Thresholding
- Method 1 : Separate thresholds for R,G,B,A and then AND them
- Method 2 : Convert to HSLA and then do the above
Method 1 above segments the image as per how the camera stores it, but not
how a human would view it. Method 2 is how a human brain would analyze the
image.
Further Steps
So what do you think we should do, @jywarren <https://github.com/jywarren>
? All of these, some of these?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#123 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AABfJ7l9ApddXP2UnkRvsIyfVX63fg2Hks5stY1ugaJpZM4PhoQ0>
.
|
Sounds good. I'll try to implement the HSLA B/W one then.
…On Wed, Oct 18, 2017, 18:48 Jeffrey Warren ***@***.***> wrote:
Let's start with just one, perhaps the easiest one, and we can leave these
great docs for the next person who wants to take the next step. Sound good?
On Oct 18, 2017 1:32 AM, "Chinmay Pandhare" ***@***.***>
wrote:
> Introduction
>
> Have been doing some research on this and I came across the following :
>
> - https://in.mathworks.com/help/images/ref/multithresh.html
> - http://ieeexplore.ieee.org/document/5445591/
> - https://en.wikipedia.org/wiki/Thresholding_(image_processing)
>
> I wanted to have a look at the algorithm so as to make a node-and-browser
> compatible version.
>
> I think there is much more to thresholding than we had currently
> implemented.
>
> There's Full RGB Quantization, Plane-by-plane RGB Quantization, etc.
> Notes Single Channel Thresholding
>
> When there is only one channel, per pixel the channel value is made into
> max or min based on whether it is above a certain threshold value.
> Multiple Channel (Color Input, Color Output) Thresholding
>
> When there are multiple channels,
>
> - The above can be done per channel. (Plane by Plane RGB Quantization)
> - OTSU's Method can be used. (Full RGB Quantization)
>
> Multiple Channels (Color Input, Black/White Output) Thresholding
>
> - Method 1 : Separate thresholds for R,G,B,A and then AND them
> - Method 2 : Convert to HSLA and then do the above
>
> Method 1 above segments the image as per how the camera stores it, but
not
> how a human would view it. Method 2 is how a human brain would analyze
the
> image.
> Further Steps
>
> So what do you think we should do, @jywarren <
https://github.com/jywarren>
> ? All of these, some of these?
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <
#123 (comment)
>,
> or mute the thread
> <
https://github.com/notifications/unsubscribe-auth/AABfJ7l9ApddXP2UnkRvsIyfVX63fg2Hks5stY1ugaJpZM4PhoQ0
>
> .
>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#123 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AT0xnD15iAYbtdhfTxgIdjHE0vGEzj0rks5stfqxgaJpZM4PhoQ0>
.
|
Threshold module added already in #722. |
Hi, @ccpandhare -- just going through the steps here to add a module again -- re-adding the thresholding module -- and ran into some trouble. I see the error:
Any idea what I'm missing here? This is also a good "shakedown test" possibly related to #122 before we announce this more widely and completely standardize the module format. Thanks!