
Correcting Images without Histogram Wrapping?

jjweimer
Function CorrectRedwGreen(th, sf) variable th, sf DFREF rd = root:rawimages wave/SDFR=rd redch, redch_corrected, grnch duplicate/FREE grnch grnchth MatrixOP/O grnchth = grnch - th grnchth = grnchth < 0 ? 0 : grnchth MatrixOP/O redch_corrected = redch - sf*grnchth return 0 end
Basically, I am removing a threshold from the green and then subtracting a fraction of the threshold-corrected green channel from the red. The test to reset the green channel is my way to try to avoid what I call as a "wrapping" problem in the histogram. I want the negative grayscale values to go to zero, not be reset to the other side of the histogram color (grayscale).
Unfortunately, it does not work. I suspect the wrapping is already done at the subtraction.
What is the correct way to handle this?
I have encountered that problem also in may forays into image processing.
One suggestion instead of
MatrixOP/O grnchth = grnch - th
you use
grnchth = max((grnch-th),0)
That will prevent then wrapping at the subtraction point, albeit it will probably be a lot slower that using a matrixop.
Andy
April 25, 2016 at 08:45 am - Permalink
This is not so slow. I imagine that MultiThread may come in handy somewhere. But that is alphabetically after MatrixOP, and my brain can only learn one new command at a time any more. :-)
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
April 25, 2016 at 01:10 pm - Permalink
If you are already using MatrixOP, what's the point of using such slow expressions?
Try:
A.G.
WaveMetrics, Inc.
May 2, 2016 at 11:52 am - Permalink
Well, that is another new one for me. Thanks!
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
May 2, 2016 at 05:38 pm - Permalink