Hello!
I've been trying for 2 days using the updateAndRepaintWindow function in my code, but it won't work! Here's my code: private class MyChangeListener implements ChangeListener { public void stateChanged(ChangeEvent changeEvent) { JSlider slider = (JSlider) changeEvent.getSource(); // Need to divide the value with 100 so it turns to a float value (from int, because JSlider uses only int) multiplierForThreshold = (float) (slider.getValue() / 100.0); findMultiplierTextField.setText(Float.toString(multiplierForThreshold)); if (!slider.getValueIsAdjusting()) { // Threshold the image with the value of multiplierForThreshold which has been chosen by JSlider // I've created the StackThresholder class myself. In brief, it sets a threshold for a image stack StackThresholder myStackThresholder = new StackThresholder(multiplierForThreshold); imp = myStackThresholder.threshold (originalImages, 9); // Making the image show up only one time if(showCounter == 0) { imp.show(); showCounter++; } // Makes the images using black-white mode somehow imp.setStack(imp.getStack ()); imp.updateAndRepaintWindow(); // imp.show(); } } } It works fine to update the image sequence by using "imp.show();", but I don't want it to pop-up a new window everytime a choose a new "multiplierForThreshold". So, how can I make this work with "imp.updateAndRepaintWindow();" instead? // Litanol |
Hi Litanol,
imp.setStack(imp.getStack()) kills the threshold of the current image. The threshold is held only by the ImageProcessor that you get by imp.getProcessor(). ImagePlus.setStack replaces this ImageProcessor by a new one. Also note that an ImagePlus, even if containing a stack, can hold only one ImageProcessor, so the threshold is the same for all slices. When changing the slice, only the data in imp.getProcessor() are changed, its other properties remain the same. Of course, if you want to APPLY a threshold, i.e. convert the image to binary, you can do this with different values for each slice. Michael ________________________________________________________________ On 3 Jun 2010, at 21:28, Litanol wrote: > Hello! > > I've been trying for 2 days using the updateAndRepaintWindow > function in my > code, but it won't work! > Here's my code: > > private class MyChangeListener implements ChangeListener > { > public void stateChanged(ChangeEvent changeEvent) > { > JSlider slider = (JSlider) changeEvent.getSource(); > > // Need to divide the value with 100 so it turns to a float > value (from > int, because JSlider uses only int) > multiplierForThreshold = (float) (slider.getValue() / 100.0); > > findMultiplierTextField.setText(Float.toString > (multiplierForThreshold)); > > if (!slider.getValueIsAdjusting()) { > > // Threshold the image with the value of > multiplierForThreshold > which has been chosen by JSlider > // I've created the StackThresholder class myself. In > brief, it > sets a threshold for a image stack > StackThresholder myStackThresholder = new > StackThresholder(multiplierForThreshold); > imp = myStackThresholder.threshold (originalImages, 9); > > // Making the image show up only one time > if(showCounter == 0) > { > imp.show(); > showCounter++; > } > > // Makes the images using black-white mode somehow > imp.setStack(imp.getStack ()); > > imp.updateAndRepaintWindow(); > // imp.show(); > } > } > } > > > It works fine to update the image sequence by using "imp.show();", > but I > don't want it to pop-up a new window everytime a choose a new > "multiplierForThreshold". > > So, how can I make this work with "imp.updateAndRepaintWindow();" > instead? > > > // Litanol > -- > View this message in context: http://imagej.588099.n2.nabble.com/ > Problems-with-updateAndRepaintWindow-tp5136553p5136553.html > Sent from the ImageJ mailing list archive at Nabble.com. |
Free forum by Nabble | Edit this page |