polar-computing / 3DSeals

0 stars 2 forks source link

Inversion based on overall dark/light #3

Open aborowicz opened 8 years ago

aborowicz commented 8 years ago

We're working on the decision to create a normal binary or an inverted binary as a means of detecting relevant spots in animals that are dark vs. light. Intermediate animals will use both.

To this end, we need to find a way to mask out the background, so the inversion switch is on hold.

swyngaard commented 8 years ago

Masking out the background is definitely a good idea. It will reduce false patch matches from the extraneous noise. It may be worth looking at the technique presented here.

I'm currently in North Carolina and will have more time to flesh out the code when I'm back in California next week.

aborowicz commented 8 years ago

We actually had remarkable success by running another gamma adjustment at ~gamma = 8.0, then running cv2.findContours which returns just one pretty decent contour around the seal. Now we're working out how to get the points of that contour into a polygon.

aborowicz commented 8 years ago

Have code to put into end of back_extract so it returns the % white of the mask (basically how big is the seal in pixels). Similar code to put into watershed following the gamma_search call. Takes the binary output from that function and calculates again the % white / % white from mask. Basically gives the amount of white on the seal in the pre-processed binary image.

Need to feed this into the inversion decision tree:

If seal is mostly dark, no inversion needed (reasonable patches are all white). If seal is mostly light, invert (reasonable patches will be black otherwise) If seal is at some intermediate percentage, run both normal, and inverted (to capture both black and white spots)

Hard to implement before having a way to store patches, which sort of leads into database implementation. Need to be able to run normal, store patches, then run again inverted and store those patches as well, either lumping all together, or somehow annotated with the fact that some are white, some are dark to avoid false positives from white patches matching dark patches.

Right now the code is just sitting in watershed saving the % to img_dark but not using it again.