Posted by
Michael Schmid on
Mar 23, 2018; 6:22pm
URL: http://imagej.273.s1.nabble.com/Problem-with-Maximum-intensity-projection-tp5020309p5020325.html
Hi Fred,
for getting the values along the z direction, e.g. for fitting, you can
do the following:
int nSlices = stack.getSize();
ImageProcessor[] inIps = new ImageProcessor[nSlices];
for (int i=0; i<nSlices; i++)
inIps[i] = stack.getProcessor(i+1);
Calibration cal = imp.getCalibration();
double[] zData = new double[nSlices];
for (int i=0; i<nSlices; i++)
zData[i] = cal.getZ(i);
double[] fitData = new double[nSlices];
for (int y=0; y<height; y++) {
IJ.showProgress((double)y/height);
for (int x=0; x<width; x++) {
double[] params = null;
for (int i=0; i<nSlices; i++)
fitData[i] = inIps[i].getPixelValue(x, y);
// do the fit for fitData over zData
}
}
}
Somewhere I have a Stack_Fitter plugin, I'll upload it to
http://imagejdocu.tudor.luMichael
________________________________________________________________
On 23/03/2018 18:32, Fred Damen wrote:
> Greetings,
>
> I would like to second Kenneth's frustration with my version of fetching the
> requisite values:
>
> for(int iz=0; iz<nz; iz++) {
> IJ.showStatus("NonLinearFit: z="+iz);
> IJ.showProgress(((float)iz)/nz);
>
> for(int ix=0; ix<nx; ix++)
> for(int iy=0; iy<ny; iy++) {
> for(int if=0; if<nf; if++)
> y[if] =
> ((FloatProcessor)is.getProcessor(imp.getStackIndex(1,iz+1,if+1))).getf(ix,iy);
> process(x,y);
> }
> }
>
> Ages ago, I tried using the various getVoxel(s) methods to no avail. If
> memory serves, they would always return the same value. So once I got the
> aforementioned code working I just copy and paste every time I need it; which
> is always.
>
> I would assume that this inner loop can be done extremely more efficiently
> under the hood than through the interface, i.e., repeated calls to
> is.getProcessor and imp.getStackIndex are not free; notice the need for
> showStatus and showProgress. Can the getVoxels and setVoxels methods that
> include the frame dimension be included.
>
> Thanks for listening,
>
> Fred
>
>
> On Fri, March 23, 2018 11:30 am, Kenneth Sloan wrote:
> ...
>> Obligatory question: I tried to use getVoxels - but failed miserably. After a
>> few attempts, I just
>> rolled my own.
>>
>> This is slower than dirt - but I hope it's clear.
>>
>> And, as always - I welcome corrections to my chronic mis-understanding of the
>> API.
>> --
>> Kenneth Sloan
>>
[hidden email]
>> Vision is the art of seeing what is invisible to others.
> ...
>
> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html>
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html