Re: Programming Question
Posted by Gabriel Landini on Apr 04, 2009; 8:03am
URL: http://imagej.273.s1.nabble.com/Programming-Question-tp3693097p3693098.html
On Saturday 04 April 2009, David William Webster wrote:
> I have a question about how ImageJ/Java passes computational results out
> of a method. For example, the GaussianBlur class contains the void method
> blurFloat with an argument ImageProcessor ip. In this method, the pixels
> values in ip are copied into a float array using (float[]) pixels = (float
> []) ip.getPixels(). The array pixels is then used in subsequent
> computations. But, I dont see how the final results are communicated back
> to ip as there is no ip.setPixels() in this method. I see this many places
> and know its some sort of OOP thing, but I cant figure it out. Can
> someone tell me how ip gets the updated pixel values.
I think (please correct if I am wrong) that by getting the pixels into an
array with ip.getPixels(), you are accessing the image processor directly, so
if you change the array, you are effectively changing the image pixels.
No need to update the processor, but you might have to update the ImagePlus
being shown with imp.updateAndDraw() at the end of the processing.
Cheers,
G.