BoofCV icon indicating copy to clipboard operation
BoofCV copied to clipboard

Sauvola delivers black for some radius and images

Open thhart opened this issue 3 years ago • 3 comments

I have observed that Sauvola delivers black images in combination with special radius and special images. Unfortunately it behaves extremely strange and I can not reproduce it in a test environment. However I am 100% sure the input right before the function call is valid. The questionable radius is 4-9 and it only happens on a special image. Maybe it is related to the image modification chain before, but I have to check carefully if I can find some reason. So I can only report here for the records yet.

Code is like this:

GrayU8 sauvola = GThresholdImageOps.localSauvola(gray, null, ConfigLength.fixed(radius), threshold, true); return VisualizeBinaryData.renderBinary(sauvola, invert, null);

thhart avatar Feb 24 '22 18:02 thhart

Could you add this before the call and see if it prints out zero when you have the issue?

var copied = gray.clone()
System.out.println("mean="+ GImageStatistics.mean(copied ));
GrayU8 sauvola = GThresholdImageOps.localSauvola(copied , null, ConfigLength.fixed(radius), threshold, true); return VisualizeBinaryData.renderBinary(sauvola, invert, null);

Next try adding this line before any code is called and see if it fixes the issue.

BoofConcurrency.USE_CONCURRENT = false;

Is this a threaded application? Is it possible another thread is modifying an image while this process is going?

lessthanoptimal avatar Feb 24 '22 19:02 lessthanoptimal

  1. Mean value is ok before
  2. Concurrency on/off no change
  3. No modification going on, I even used the copy for the call

I tried to serialize the questionable image before, so I could reproduce, but it only happens in the complex application chain, maybe there is a dependency conflict, I have to check further I am afraid...

thhart avatar Feb 25 '22 10:02 thhart

any update?

lessthanoptimal avatar Mar 10 '22 02:03 lessthanoptimal