bradmartin333 / SEYR

Simple Entropy Yield Routine
MIT License
1 stars 0 forks source link

Poor lighting differentiation between chip & background #130

Closed riversn closed 1 year ago

riversn commented 1 year ago

Low lighting sometimes seems to work best on some samples to differentiate between the chip being present and the background.

For instance, the chip and the background will both 'turn blue' (register as color entropy) at the same threshold values when a user can clearly see a difference still.

It's hard to describe the issue well, but the SEYR color analysis is sometimes able to differentiate between when it's plotting Blue vs Purple in the threshold map, but it'd be better if maybe the regions are separated a bit more somehow.

Very hard to send a sample image set for you to see what we mean.

bradmartin333 commented 1 year ago

hard to know exactly what to test - it seems like the feature might have too many different possible states - meaning it is no longer "present" and "not present", but it is "empty" and "mostly empty". am I on the right track?

riversn commented 1 year ago

No, let me try and get some pictures to explain it - it's really hard to understand without them

bradmartin333 commented 1 year ago

okay - I made a simple but massive change

there is now a tool in the composer called "Entropy Balance" where you pick an RGB color

that color controls the levels of the image that go into the scoring routine: default and legacy is always red (255, 0, 0). if you make it black (0, 0, 0), you get no data. if you make it white (255, 255, 255) you get a much smoother curve than legacy red. you can make it any color in between (no transparency control, though)

riversn commented 1 year ago

Scroll bars for finetuning with default primary option buttons? (Red, Yellow, Blue, Green, etc..). Need a way to test and compare when setting the recipe up.

bradmartin333 commented 1 year ago

standard windows color picker

image

riversn commented 1 year ago

Yeah! That works!

bradmartin333 commented 1 year ago

now the question... do you need one entropy balance per .seyr or one per feature?

bradmartin333 commented 1 year ago

much better values with a bit more blue image

bradmartin333 commented 1 year ago

click the chroma button to change color, then border color reflects it

riversn commented 1 year ago

With this addition, will previous .seryups still work with XferSuite? Will XferSuite still parse the older ver files?

bradmartin333 commented 1 year ago

yes, but that reminds me I need to expose the default color so your team can change it in the XFER-SEYR panel

the exiting color is always Red, and that is the current default. But please test this in the demo .exe (new one coming soon)

riversn commented 1 year ago

For the color selector, is there a way to add an eyedropper so a user could click on a color on the screen to choose the color of the inspection chip? That could be really useful so they don't have to guess at the colors.

bradmartin333 commented 1 year ago

yes, that is possible - but I am not sure you will want the chroma to be the color of the device itself. will know more after testing the newest demo .exe

riversn commented 1 year ago

The outline/box should be a little different. The thick boarder is jarring in contrast to the other boxes boarders around it.

image

Maybe a highlight/background fill would work better. It should definitely be greyed out if it's on the default setting, not bright purple. Change to the chosen color once enabled/changed off of default.

Boarders should be similar to other boxes around it I think

riversn commented 1 year ago

Changing the chroma color setting does not change the threshold map image on the left. I feel like it should. Wouldn't the image on the left change if the color that was being scanned for changed?

riversn commented 1 year ago

Chroma Setting is set to purple by default, can we change it back to whatever color it was originally by default? I thought it was Red (255, 0, 0).

bradmartin333 commented 1 year ago

ya, that was not supposed to make it into the .exe, was just testing

bradmartin333 commented 1 year ago

Changing the chroma color setting does not change the threshold map image on the left. I feel like it should. Wouldn't the image on the left change if the color that was being scanned for changed?

ah, yeah, I cheat and don't actually use the scoring method to generate that image - it is kind of an estimation. I can update it, don't know how challenging/slow it will be

riversn commented 1 year ago

ah, yeah, I cheat and don't actually use the scoring method to generate that image - it is kind of an estimation. I can update it, don't know how challenging/slow it will be

It's a must have, otherwise the user has no clue if they're capturing/scoring the chip, or capturing the background instead.

bradmartin333 commented 1 year ago

ya - okay I got it to work and found a big error in the main calc as well

good news is that is looks really good with your sample pics and a gross color (111, 111, 0) with threshold 41

will make a new demo .exe with fixes

riversn commented 1 year ago

image

This is a very jarring button.

If default, should have no fill (or match background). Text color should be Black, or White, depending on fill color. Not cyan/opposite of the fill

bradmartin333 commented 1 year ago

yeah - I agree, just focused on function right now. I like having it the way it is for debugging - then I will tame it.

riversn commented 1 year ago

image

threshold map does not match the score values being made.

It's saying there's a valid chip but the map suggests the area should be null/missing

riversn commented 1 year ago

Vs this:

image

bradmartin333 commented 1 year ago

the opposite-ness is sort of an indicator of how the magic wand got there, but not exactly

current magic wand is

Bitmap bitmap = (Bitmap)PbxTile.BackgroundImage.Clone();
Point center = ActiveFeature.GetGeometry().Center();
Color c = bitmap.GetPixel(center.X, center.Y);
c = Color.FromArgb(Math.Min(255, c.R + c.B), Math.Min(255, c.G + c.B), 0);

but that is from limited testing

it is important to know that the threshold is only used for null detection, which will kick the score to -10

riversn commented 1 year ago

I think something is wrong with the yellow color, It's not displaying the threshold map correctly compared to the other colors

bradmartin333 commented 1 year ago

there are 2 types of visualizations:

the final score is either chroma or -10, depending on the threshold

riversn commented 1 year ago

Okay, maybe I'm not understanding then - I'm expecting a map on the left to show the pixels that are getting flagged for 'color being present'

Is that not actually what it's displaying?

Also now it's all black, not a scaled purple/light blue/blue/black?

bradmartin333 commented 1 year ago

The main reason for confusion is the current released version's Threshold button. It is a farce and has nothing to do with the final scoring. All it does it apply a 3rd party threshold function using the user's value on all channels - hence the hue that you see.

The new threshold button uses the very same calculations that are used at runtime. You get a greyscale image indicating the chroma image after the threshold is applied.

riversn commented 1 year ago

Sure, but the current display is incorrect...

The score values are correct, the map/image that's being displayed is not.

riversn commented 1 year ago

The map is showing an image that should be failing, but the scores are passing.

And it's only happening with yellow color

bradmartin333 commented 1 year ago

hmm okay - I will isolate the functions and do some debugging. please continue to test the other additions as well as how the chroma performs regardless of the threshold preview. I have a lot of meetings today, so I will be slower.

riversn commented 1 year ago

image

This should not be failing - there's a filled square, in the image, but a lot of white/unfilled space around it - enough to be more than 10%... so it should be a valid count. Idk, there's definitely something going on.

bradmartin333 commented 1 year ago

yeah - I will figure it out... but the contrast looks much better! once I fix it, it should help a lot

bradmartin333 commented 1 year ago

so weird - I am not seeing that issue... consistently getting scores of 20-40

riversn commented 1 year ago

so weird - I am not seeing that issue... consistently getting scores of 20-40

Yes! That's part of the problem!

When it's unfilled, it's seeing a base score for some reason, it's like if there's unfilled there's noise. It should be failing it instead if the map is being displayed correctly.

bradmartin333 commented 1 year ago

my bad - I meant consistent 20-40 scores where there is a chip

consistent -10 score for no chip

image

riversn commented 1 year ago

Try on image 26

bradmartin333 commented 1 year ago

I'll keep a list of bugfixes in this comment:

bradmartin333 commented 1 year ago

took me a while to figure this out - but the duplicate ABC indices in the images dir mess up the image scroller

my guess is that the same grid was run with different origins for a total of 8 times? if not, then I am confused... so many coordinate systems...

anyway these chroma changes are looking good!

bradmartin333 commented 1 year ago

new demo here!!!

riversn commented 1 year ago

Okay, you gotta explain what the different colors in the map now mean.

image

riversn commented 1 year ago

Something is off with the color Green:

It's like green doesn't get counted for any score values. image

Something's also off with white.

riversn commented 1 year ago

When I land on a decent color, I get such better separation now!

Super cool to see! image

bradmartin333 commented 1 year ago

Any issues or it just needs some documentation?

riversn commented 1 year ago

Dark green is messed up image

bradmartin333 commented 1 year ago

using any pure color, besides red, and especially dark pure colors, like that green, will likely not work

bradmartin333 commented 1 year ago

this is the logarithmic linear color space of one of the brighter pics from GIMP

image

the color you select is like a chroma key, but not exactly. you select a color distribution to emphasize in the image pre-threshold. For these images, a bright yellow (255, 255, 0) looks pretty good at the lows and highs and will likely mask out most of the blurry blue blackground.

bradmartin333 commented 1 year ago

it might be best to restrict chroma to a third of the color wheel (> 300 deg or < 60 deg)

image

riversn commented 1 year ago

The one that works the best surprisingly, and on multiple samples, is this darker & lighter grey! image

I guess i'm still confused on how the scoring with the color works.

As I understand it, the chroma button is like a green screen? choose which color and that because the background and is no longer counted as a score value?

But that's kinda backwards thinking. From my understanding of what's actually doing in the threshold map, black = empty, color = filled? But then what do the varying gradients of color mean?

Specifically, the scoring behavior of green and white in the threshold map are slightly different than other colors (lightblue,blue,purple)