|
Hi,
My group is trying to expand the B & C popup window (ConstrastAdjuster plugin) to have an additional slider bar for Gamma adjustment of images.
We managed to add a Gamma slider to B & C popup, but it is not working properly. When you move the Gamma slider, the change is not gradual (as the sliders work for the brightness & contrast) and is sort of ON or OFF.
Below is the code we added to the ContrastAdjuster plugin (B & C Window). Is there something wrong with our calculations for Gamma and/or usage of the built-in Gamma function in ImageJ?
Thanks!
CODE ADDED
// variable declaration
int contrast, brightness, gammav;
Scrollbar minSlider, maxSlider, contrastSlider, brightnessSlider, gammaSlider;
// The code that adds the slider to the Pop-up plugin
// gamma slider
if (!balance)
{
gammaSlider = new Scrollbar(Scrollbar.HORIZONTAL, sliderRange/2, 1, 0, sliderRange);
c.gridy = y++;
c.insets = new Insets(2, 10, 0, 10);
gridbag.setConstraints(gammaSlider, c);
add(gammaSlider);
gammaSlider.addAdjustmentListener(this);
gammaSlider.addKeyListener(ij);
gammaSlider.setUnitIncrement(1);
if (windowLevel)
addLabel("Window: ", windowLabel=new TrimmedLabel(" "));
else
addLabel("Gamma", null);
}
//The function that does the gamma adjustments
void adjustGamma(ImagePlus imp, ImageProcessor ip, int gvalue)
{
double slope;
double center = min + (max-min)/2.0;
double range = defaultMax-defaultMin;
double mid = sliderRange/2;
if (gvalue<=mid)
slope = gvalue/mid;
else
slope = mid/(sliderRange-gvalue);
if (slope>0.0)
{
min = center-(0.5*range)/slope;
max = center+(0.5*range)/slope;
}
//setMinAndMax(ip, min, max);
double gval = gvalue;
imp.getProcessor().gamma(gval);
if (RGBImage) doMasking(imp, ip);
//updateScrollBars(gammaSlider);
}
---------------------------------
We have the perfect Group for you. Check out the handy changes to Yahoo! Groups.
|